Time limit: 0.05s
Memory limit: 64MB
Input:
Output:
"the checker is impossible for this one"
Well, Traian needed more problems for the contest, so he thought of this one.
Task
Traian thought of sequences each containing numbers (for each sequence, the number is not necessarily the same) and also thought of a number for each sequence (again, is not necessarily the same for all sequences). He wants you to find a number that is divisible by every number in the sequence and has exactly digits.
Input data
The first line will contain the number , representing the number of sequences. On the -th line, there will be the numbers and . On the -th line, there will be the numbers in the sequence.
Constraints and clarifications
- The sum of the numbers does not exceed
- The sum of the numbers does not exceed
- The required number exists for any of the sequences.
- We denote the sequence by
Example
stdin
9
4 11
113 158 170 96
5 10
22 18 6 30 6
11 9
4 6 5 4 5 3 6 4 5 4 3
6 11
28 9 9 25 6 17
3 10
565 623 621
11 9
2 4 2 3 3 5 4 3 4 4 6
3 10
920 274 410
10 11
3 1 5 7 1 3 5 2 4 7
4 9
30 90 40 26
stdout
10052516160
6000005880
100000020
80000272800
1092944475
900000180
3007566480
50000000400
100002240
Explanation
Check them