Same Digitwise Product
Statement
Goal
You are given integers n and m.You need to find out if the digitwise products modulo 43 are the same for both of them.
The digitwise product of a number is all digits of a number multiplied together. For example, the digitwise product of 95 would be: 9 * 5 = 45.
The modulo operation returns the remainder or signed remainder of a division. For our example, it would be: 45 mod 43 = 2, so we see that the digitwise product of 95 mod 43 would be 2.
Input
Line 1: The integer n.
Line 2: The integer m.
Line 2: The integer m.
Output
Line 1: One of the digitwise products modulo 43 if the two digitwise products are the same modulo 43, and -1 otherwise.
Constraints
0 ≤ n, m < 2^32
Example
Input
436 89
Output
29
Game modes
Fastest, Shortest
Test cases
Sample Test
Input
436
89
Output
29
Validator 1 Validator
Input
6345
98
Output
-1
Obvious Test
Input
12360
809921
Output
0
Validator 2 Validator
Input
7650
1000007
Output
0
Single Digit Test
Input
1
2
Output
-1
Validator 3 Validator
Input
3
4
Output
-1
Single Digit 2 Test
Input
1
1
Output
1
Validator 4 Validator
Input
0
0
Output
0
Large 1 Test
Input
1747847
2147483649
Output
1
Validator 5 Validator
Input
2147483649
777372
Output
1
Large 2 Test
Input
1344567218
4715856
Output
-1
Validator 6 Validator
Input
527533432
2999918
Output
-1
Solution language
Solution
Stub generator input