For each query offset into pi and target digit, you print the next matching digit and the 5 after it.
Easy1ImplementationNo attempts yetTime limit1sMemory limit256 MBYour friend Mike is arguing with his classmate Chris about what the last digit of π is. (You and I know there is no such digit, but Chris will not be talked out of it.) Mike's argument is flawed and entertaining at the same time: whatever digit of π you look at, either that digit is a 5, or a 5 occurs somewhere after it.
Cute, and over the portion of π that has been calculated so far the same claim holds at every digit. You are not being asked to prove anything. Mike only wants you to use your computer skills to produce sample data that supports his case.
Each test case gives an offset P into the digits of π and a single digit D. Report the digits of π at offsets Q and R, where
Offsets start at 0, and the digit at offset 0 is the 3 in front of the decimal point.
For example, if P is 3 and D is 2, then Q is 6 and R is 8, so the digits at offsets Q and R are 2 and 5.
P Q R
index: 0 1 2 3 4 5 6 7 8 9 10 11 ...
digit: 3 1 4 1 5 9 2 6 5 3 5 8 ...
The first line contains the number of test cases N (1≤N≤10000).
Each of the next N lines contains two integers:
For each test case, print one line with the digit of π at offset Q followed by the digit of π at offset R, separated by a single space.