Crystallized

Time limit: 1s Memory limit: 256MB Input: Output:

Task

You are given an integer NN and an integer XX. Display how many subsets of the set {1,2,3,,N}\{1, 2, 3, \dots, N\} have the XOR sum equal to XX.

Input data

The first line contains two integers, NN and XX.

Output data

The first line will contain a single integer, the answer modulo 109+710^9 + 7.

Constraints and clarifications

  • 1N1091 \leq N \leq 10^9
  • 0X1090 \leq X \leq 10^9
  • The XOR sum of the empty set \varnothing is considered to be 00.
  • For 1010 points, N=10N = 10.
  • For another 2020 points, N5 000N \leq 5\ 000.

Example 1

stdin

1 1

stdout

1

Example 2

stdin

3 0

stdout

2

Explanation

There are two subsets with the XOR sum of 00: \varnothing and {1,2,3}\{1, 2, 3\}.

Log in or sign up to be able to send submissions!