Sounak the Analyst

0

0 votes
Problem

Sounak’s dream has finally come true. He has got a job as an analyst of Kolkata United, the current champions of the Indian Cricket League (ICL). On his very first day, the Coach of Kolkata United has assigned Sounak the following task:

The scores of Batsman A and Batsman B in N1 and N2 matches respectively are given. Coach wants Sounak to find the number of possible pairs (S1,S2) where S1 denotes Batsman A’s score in any of the N1 matches and S2 denotes Batsman B’s score in any of the N2 matches respectively, such that S1<S2.

Coach also mentions Sounak that scores for both batsmen which are prime numbers have actually been wrongly recorded and hence should not be taken under consideration by Sounak during his analysis.

Since this is Sounak’s first task after joining Kolkata United, he is very nervous and fears that he might make a mistake. So he asks you to help him. Please help Sounak to find the required number of possible pairs.

 

Input Format:

The first line of the input contains T, the number of Test Cases. T test cases follow.

The first line of each test case contains two space- separated positive integers N1 and N2 denoting the number of scores to consider for Batsman A and Batsman B respectively.

The next line contains N1 space separated non-negative integers denoting Batsman A’s scores.

The next line contains N2 space separated non-negative integers denoting Batsman B’s scores.

 

Output Format:

The output for each test case contains a single line denoting the required number of possible pairs of scores of Batsman A and Batsman B.

 

Constraints:

1T50

1N1105

1N2105

0S1105

0S2105

Time Limit: 1.55
Memory Limit: 256
Source Limit:
Explanation

Test Case 1: Possible pairs are (1, 6), (4, 6).

Test Case 2: Possible pairs are (8, 10), (8, 10), (8, 12), (8, 12).

Editor Image

?