CF1546A.AquaMoon and Two Arrays

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

AquaMoon and Cirno are playing an interesting game with arrays. Cirno has prepared two arrays aa and bb , both consist of nn non-negative integers. AquaMoon can perform the following operation an arbitrary number of times (possibly zero):

  • She chooses two indices ii and jj ( 1i,jn1 \le i, j \le n ), then decreases the ii -th element of array aa by 11 , and increases the jj -th element of array aa by 11 . The resulting values at ii -th and jj -th index of array aa are ai1a_i - 1 and aj+1a_j + 1 , respectively. Each element of array aa must be non-negative after each operation. If i=ji = j this operation doesn't change the array aa .

AquaMoon wants to make some operations to make arrays aa and bb equal. Two arrays aa and bb are considered equal if and only if ai=bia_i = b_i for all 1in1 \leq i \leq n .

Help AquaMoon to find a sequence of operations that will solve her problem or find, that it is impossible to make arrays aa and bb equal.

Please note, that you don't have to minimize the number of operations.

输入格式

The input consists of multiple test cases. The first line contains a single integer tt ( 1t1001 \leq t \leq 100 ) — the number of test cases.

The first line of each test case contains a single integer nn ( 1n1001 \leq n \leq 100 ).

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 0ai1000 \leq a_i \leq 100 ). The sum of all aia_i does not exceed 100100 .

The third line of each test case contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n ( 0bi1000 \leq b_i \leq 100 ). The sum of all bib_i does not exceed 100100 .

输出格式

For each test case print "-1" on the only line if it is impossible to make two arrays equal with some sequence of operations.

Otherwise, print an integer mm ( 0m1000 \leq m \leq 100 ) in the first line — the number of operations. Then print mm lines, each line consists of two integers ii and jj — the indices you choose for the operation.

It can be proven that if it is possible to make two arrays equal with some sequence of operations, there exists a sequence with m100m \leq 100 .

If there are multiple possible solutions, you can print any.

输入输出样例

  • 输入#1

    4
    4
    1 2 3 4
    3 1 2 4
    2
    1 3
    2 1
    1
    0
    0
    5
    4 3 2 1 0
    0 1 2 3 4

    输出#1

    2
    2 1
    3 1
    -1
    0
    6
    1 4
    1 4
    1 5
    1 5
    2 5
    2 5

说明/提示

In the first example, we do the following operations:

  • i=2i = 2 , j=1j = 1 : [1,2,3,4][2,1,3,4][1, 2, 3, 4] \rightarrow [2, 1, 3, 4] ;
  • i=3i = 3 , j=1j = 1 : [2,1,3,4][3,1,2,4][2, 1, 3, 4] \rightarrow [3, 1, 2, 4] ;

In the second example, it's impossible to make two arrays equal.

首页