Sereja and Subsegment Increasings

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Sereja has an array A that contains n integers: A_{1}, A_{2}, ..., A_{n}. Sereja also has an array B that contains n integers B_{1}, B_{2}, ..., B_{n}. In a single step Sereja can choose two indexes i and j (1 <= i <= j <= n) , and increase all the elements of A with indices between i and j inclusively by one, modulo 4. In other words, we make A_{p} equal to (A_{p} + 1) modulo 4 if p is an integer from the range [i; j].
Now Sereja is interested in the following question: what is the mininal number of steps necessary in order to make the array A equal to the array B.
Input
The first line contains an integer T  the number of the testcases. Then, T tests follow.
The first line of each testcase contains the integer n.
The next line conatins n single space separated integers  A_{1}, A_{2}, ..., A_{n}.
The next line conatin n single space separated integers  B_{1}, B_{2}, ..., B_{n}.
Output
For each testcase output an answer  the mininal number of steps necessary.
Constraints
 1 ≤ T ≤ 10
 1 ≤ n ≤ 10^{5}
 0 ≤ A_{i}, B_{i} ≤ 3
Example
Input: 1 5 2 1 3 0 3 2 2 0 1 0 Output: 1
Author:  sereja 
Tester:  xcwgf666 
Editorial  http://discuss.codechef.com/problems/SEINC 
Tags  greedy, may14, mediumhard, sereja 
Date Added:  11032014 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 