SOLVE
LATER
Let us first describe a Simple Function.
Simple Function(string A,string B){
int answer=0;
for(int dig=1;dig<=9;dig++){
if(string A contains digit dig and string B contains digit dig){
answer=answer*10+dig;
}
return answer;
}
So basically this function receives two strings as an input and returns a value.
Akshara recently gained interest in coding and she came across this interesting question. She had $$2$$ baskets. Each basket contained a few strings. She wanted to find out what is the probability of picking up $$2$$ strings, $$1$$st string from the first basket and the $$2$$nd string from the second basket, such that the value returned from the Simple function would be an even value.
Since she is not that good at Mathematics, she turns to you for help. Please help her in solving this problem!
Input: The first line contains an integer T denoting the number of test cases. The first line of each test case contains 2 integers N1 and N2 denoting the size of first basket and second basket respectively. This is followed up by (N1 + N2) lines. Each line contains a string. The first N1 string correspond to the first basket while the remaining to the second basket.
Output:
For each test case output the required probability correct upto $$3$$ decimal places.
Constraints:
$$1$$ <= T <=$$10$$
$$1$$ <= N1, N2 <= $$10^3$$
$$1$$ <= Length of String <= $$10^3$$
Every String is composed of digits from [$$1$$-$$9$$].
The output of all the combination will be :
Simple(234526,333564)=3456
Simple(8345,333564)=345
Simple(8345,98847675)=458
Simple(234526,98847675)=456
Since 3 of them are even. Probability is = 3/4.