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:
This does not surprise Peter, since factorials appear quite often in various combinatorial formulae, because represents the number of transpositions of 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.
where all are distinct integer numbers greater than one in the descending order , and are positive integers. Among all the possible representations in this form, Peter is interested in one where is the largest possible number, among those in the one where is the largest possible number; among those in the one where is the largest possible number; among those in the one where is the largest possible number; etc, until the remaining cannot be further represented in this form. Peter does not care about the actual value of . He wants to know what is the factorial-product part of his result.
Input Specification
The first line of the input contains a single integer number and . The second line of the input contains integer numbers separated by spaces. The third line of the input contains integer numbers separated by spaces.
Output Specification
On the first line of the output write a single integer number . Write if the ratio of the given factorial products is not an integer. Write if the ratio is an integer but it cannot be represented in the desired form. Write followed by lines if the ratio can be represented by a factorial product as described in the problem statement. On each of the following lines write two integers and (for ) separated by a space.
Sample Input 1
1 2
6
4 4
Sample Output 1
-1
Sample Input 2
1 2
6
3 4
Sample Output 2
0
Sample Input 3
4 2
9 2 2 2
3 4
Sample Output 3
2
7 1
2 2
Comments