BRIDGE  Building Bridges
The tribe soon discovers that just communication is not enough and wants to meet each other to form a joint force against the terminator. But there is a deep canyon that needs to crossed. Points have been identified on both sides on which bridge ends can be made. But before the construction could be started, a witch Chudael predicted that a bridge can only be built between corresponding end points, i.e. a bridge starting from the i^{th} end point on one side can only end on the i^{th} end point on the other side, where the position of end points is seen in the order in which the points were identified. If not, it would lead to the end of the tribe. The tribe just wants to make as many noncutting bridges as possible, with the constraint in mind. Bridges "cut" if and only if they have exactly one common point that is not an end point.
Input
The first line of the input contains test cases t (1<=t<=50). It is followed by 3*t lines, 3 for each test case. The first line of input for each test case contains the number of end points identified on each side, n (1<=n<=10^{3}). The second line contains xcoordinates of end points identified on the first side and similiarly the third line contains the xcoordinates of corresponding end points identified on the other side. The end points are inputted in the order in which they were identified. The xcoordinates can range between 10^{3} to 10^{3}.
Output
You are required to output a single line for each test case. The line contains a single integer – the maximum number of bridges possible with the constraints explained above.
Example
Input:
34
2 5 8 10
6 4 1 2
3
5 3 10
6 4 1
6
1 2 3 4 5 6
3 4 5 6 1 2
Output:2
2
4
Expalanation: For the first test case, two nonoverlapping bridges can be formed between the 3rd and 4th end points on each side.
Added by:  Troika::Bytes 
Date:  20100218 
Time limit:  0.193s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel Pentium G860 3GHz) 
Languages:  All except: ASMGCC AWK C++14 CLOJ COB F# GO GROOVY NODEJS PERL 6 PYPY PYTH 3.2.3 PYTH 3.2.3 n PY3.4 SCM chicken SED VB.net 
hide comments
anando_du:
20150304 19:11:55
same as BRDGHRD :v :v submitted same code . got AC . ^_^ 

aparajita choudhary:
20150201 14:03:29
Test case for those who are getting WA


Kishlay Raj:
20141230 04:12:39
thanks @shubham garg , really nice test case 

Shubham Garg:
20141219 18:31:49
try these test cases


Infinity:
20140908 10:34:32
what is the worst case complexity


Rishabh Agrawal:
20140904 16:17:33
If bridges cut at an end point, are they considered "cutting" or not.


N0VICE:
20140904 05:23:15
finally AC


Archit Jain:
20140902 21:30:12
finally AC 

Abhishek Kumar:
20130613 03:10:25
*"Bridges "cut" if and only if they have exactly one common point that is not an end point."*


Kushagara:
20130612 00:33:58
@Troika::Bytes: Please do look at the submission 9462513 getting WA tried many test cases still:( 