A Co-Sequence is a sequence which consists of 8 integers.
And you can execute three types of operations on a Co-Sequence:
Now you are given two Co-Sequence and
. You need to answer the minimum number of operations you need to execute on
to make
be as same as
. Note it may be impossible to make
be as same as
.
You need to solve tasks.
The first line contains an integer – the number of tasks you need to solve.
The first line of each task contains 8 integers – the 8 integers of .
The second line of each task contains 8 integers – the 8 integers of .
All the integers in Co-Sequence must be non-negative and be less than or equal to .
It's guaranteed that:
For each task, output the minimum number of operations you need to execute on to make
is as same as
.
If it's impossible to make be as same as
, output -1 instead.
Note: there are two sample below. "# Sample Input 1/2/3" and "# Sample Output 1/2/3" are not the part of input and output.
They are just for marking that the following content corresponds to which sample.