Input:
Code: Select all
9
5 18
10000 3
100000 3
45214522 9
2000000000 15
111111111 7
417748545 13
10202010 27
2000000000 3
Code: Select all
5
1679657
57476669
112354598
3400966932
484878943
728021160
11857697
301084278403433
Edit: The outputs are correct, but becare of that n might > 2*10^9