codevs 1250 Fibonacci数列
时间限制: 1 s
空间限制: 128000 KB
题目等级 : 钻石 Diamond
题目描述
Description
定义:f0=f1=1, fn=fn-1+fn-2(n>=2)。{fi}称为Fibonacci数列。
输入n,求fn mod q。其中1<=q<=30000。
输入描述
Input Description
第一行一个数T(1<=T<=10000)。
以下T行,每行两个数,n,q(n<=109, 1<=q<=30000)
输出描述
Output Description
文件包含T行,每行对应一个答案。
样例输入
Sample Input
3
6 2
7 3
7 11
样例输出
Sample Output
1
0
10
数据范围及提示
Data Size & Hint
1<=T<=10000
n<=109, 1<=q<=30000