Factors

2.3

9 votes
Sorting, Algorithms, Basics of Greedy Algorithms, Greedy Algorithms
Problem

Ben had two numbers and . He factorized both the numbers, that is, expressed and as a product of prime numbers.
                  M = (P1A1)*(P2A2 )*(P3A3)*… *(PNAN)
                  N = (Q1B1)*(Q2B2 )*(Q3B3)*… *(QNBN)

  • Here, * represents multiplication.
  • P1, P...PN  are distinct prime numbers. 
  • Q1, Q...QN are distinct prime numbers.

Unfortunately, Ben has lost both the numbers and but still he has arrays and . He wants to reterive the numbers and but he will not be able to. Your task is to determine the minimum and the maximum number of factors their product (that is, ) could have. Your task is to tell Ben the minimum and the maximum number of factors that the product of and could have.
Since the answer can be large, print modulo .

Input format

  • The first line contains an integer denoting the number of test cases. For each test case:
    • The first line contains an integer denoting the number of elements in arrays and .
    • The second line contains space-separated integers of array .
    • The third line contains space-separated integers of array .

Output format

For each test case, print a single line line containing two integers denoting the minimum and maximum number of factors which a product of and could have.

Constraints

The sum of over all test cases does not exceed 200000.

Sample Input
2
1
2
1
2
2 2
1 3
Sample Output
4 6
24 72
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

First test case:
                         In this test case we can assume M as P12 and N as Q11. Their product will be S=P12.Q11, for minimum number of factors we can assume P1 equal to Q1 and in that case S will be P13 and the number of factors will be 1,P11,P12 and P13. Note that P1 is a prime number. For maximum number of factors we will assume them to be different and factors in that case will be 1,P11,Q11,P12,P11Q11,P12Q11.
Minimum and maximum number of factors are 4 and 6 respectively.

Second test case:

                    M=P12P2 and N=Q11Q23
                       
Their product S=M*N=P12P22Q11Q23 
For minimum number of factors we can assume P1 and Q1 equal and P2 and Q2 equal and S will be P13Q1and number of factors in this case are 24.
Number of factors=(3+1)*(5+1)=24.
Note that we can not assume P1 equal to P2 because that is a constraint in the probelm statement that P1 and P2 are different.
For maximum we can assume P1,P2,Q1 and Q2 different.

 

Editor Image

?