Simple Problem

5

1 votes
Easy
Problem

Note : Do not use cin/cout for this problem, it might give TLE. use scanf/printf instead.

The task of this problem is very simple.
You will be given two integers N and K.
You have the find out the Nth fibonacci number and then print its Kth digit from the end.

consider following initial conditions :

Fib[1]=1
Fib[2]=1

Input :

First line will contain an integer T(number of testcase).
Each of the next T lines contains two integers N and K.

Output :

For each testcase output the required answer on a new line.

Constraints :

1<=T<=10^6
1<=N<=10^6
1<=K<=15

Sample Input
6
1 1
1 2
1 3
2 10
8 2
10 2
Sample Output
1
0
0
0
2
5
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?