Author:  ACM ICPC NEERC 2010 Jury  Time limit:  3 sec  
Input file:  factorial.in  Memory limit:  256 Mb  
Output file:  factorial.out 
Peter is working on a combinatorial problem. He has carried out quite lengthy derivations and got a resulting formula that is a ratio of two products of factorials like this:
p_{1}!p_{2}! ... p_{n}!q_{1}!q_{2}! ... q_{m}!
This does not surprise Peter, since factorials appear quite often in various combinatorial formulae, because n! represents the number of transpositions of n elements — one of the basic combinatorial objects.
However, Peter might have made a mistake in his derivations. He knows that the result should be an integer number and he needs to check this first. For an integer result Peter wants to simplify this formula to get a better feeling of its actual combinatorial significance. He wants to represent the same number as a product of factorials like this.
r_{1}!^{s1} r_{2}!^{s2} ... r_{k}!^{sk} t
where all r_{i} are distinct integer numbers greater than one in the descending order (r_{i} > r_{i+1} > 1), s_{i} and t are positive integers. Among all the possible representations in this form, Peter is interested in one where r_{1} is the largest possible number, among those in the one where s_{1} is the largest possible number; among those in the one where r_{2} is the largest possible number; among those in the one where s_{2} is the largest possible number; etc, until the remaining t cannot be further represented in this form. Peter does not care about the actual value of t. He wants to know what is the factorialproduct part of his result.
The first line of the input file contains two integer numbers n and m (1 ≤ n, m ≤ 1000). The second line of the input file contains n integer numbers p_{i} (1 ≤ p_{i} ≤ 10 000) separated by spaces. The third line of the input file contains m integer numbers q_{i} (1 ≤ q_{i} ≤ 10 000) separated by spaces.
On the first line of the output write a single integer number k. Write k = −1 if the ratio of the given factorial products is not an integer. Write k = 0 if the ratio is an integer but it cannot be represented in the desired form. Write k > 0 followed by k lines if the ratio can be represented by a factorial product as described in the problem statement. On each of the following k lines write two integers r_{i} and s_{i} (for i = 1 ... k) separated by a space.
No.  Input file (factorial.in ) 
Output file (factorial.out ) 

1 


2 


3 

