#P7600. [2018年杭电多校]bookshelf
[2018年杭电多校]bookshelf
bookshelf
Problem Description
Patrick Star bought a bookshelf, he named it ZYG !! Patrick Star has book . The ZYG has layers (count from to ) and there is no limit on the capacity of each layer ! Now Patrick want to put all books on ZYG :
- Assume that the i-th layer has books finally.
- Assume that is the i-th fibonacci number ($f[0] = 0, f[1] = 1, f[2] = 1, f[i] = f[i - 2] + f[i - 1]$).
- Define the stable value of i-th layers .
- Define the beauty value of i-th layers .
- Define the whole beauty value of ZYG (Note: ). Patrick Star wants to know the expected value of if Patrick choose a distribute method randomly !
Input
The first line contain a integer (no morn than 10), the following is test case, for each test case : Each line contains contains three integer .
Output
For each test case, output the answer as a value of a rational number modulo . Formally, it is guaranteed that under given constraints the probability is always a rational number (p and q are integer and coprime, q is positive), such that q is not divisible by . Output such integer a between 0 and that is divisible by .
Sample Input
1
6 8
Sample Output
797202805
Source
2018 Multi-University Training Contest 6