Codeforces Round 167 (Div. 1)
E
Dima and Game
Codeforces
2600
原题
← D→
翻译中…

Dima and Anya love playing different games. Now Dima has imagined a new game that he wants to play with Anya.

翻译中…

Dima writes $*n*$ pairs of integers on a piece of paper $(*l*_{*i*}, *r*_{*i*})$ $(1 ≤ *l*_{*i*} < *r*_{*i*} ≤ *p*)$. Then players take turns. On his turn the player can do the following actions:

翻译中…
  1. choose the number of the pair $*i*$ $(1 ≤ *i* ≤ *n*)$, such that $*r*_{*i*} - *l*_{*i*} > 2$;
  2. replace pair number $*i*$ by pair image or by pair image. Notation $⌊*x*⌋$ means rounding down to the closest integer.
翻译中…

The player who can't make a move loses.

翻译中…

Of course, Dima wants Anya, who will move first, to win. That's why Dima should write out such $*n*$ pairs of integers $(*l*_{*i*}, *r*_{*i*})$ $(1 ≤ *l*_{*i*} < *r*_{*i*} ≤ *p*)$, that if both players play optimally well, the first one wins. Count the number of ways in which Dima can do it. Print the remainder after dividing the answer by number $1000000007 (10^{9} + 7)$.

翻译中…

Two ways are considered distinct, if the ordered sequences of the written pairs are distinct.

翻译中…

Input

翻译中…

The first line contains two integers $*n*$, $*p*$ $(1 ≤ *n* ≤ 1000, 1 ≤ *p* ≤ 10^{9})$. The numbers are separated by a single space.

翻译中…

Output

翻译中…

In a single line print the remainder after dividing the answer to the problem by number $1000000007 (10^{9} + 7)$.

翻译中…

样例

Input #1
2 2
Output #1
0
InputCopy OutputCopy
Input #2
4 4
Output #2
520
InputCopy OutputCopy
Input #3
100 1000
Output #3
269568947
InputCopy OutputCopy
题目信息
题号
273E
时间限制
1 s
内存限制
256 MB
标签
动态规划
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。