

Time Limit: 8 sec / Memory Limit: 1024 MB
配点 : 点
問題文
PCT 君は以下の問題を作りました。
Xor Optimization Problem長さ の非負整数列 が与えられる。 の要素を好きな個数選ぶとき、選んだ値の が取りうる最大値はいくらか?
この問題は、Nyaan さんにとっては簡単だったため PCT 君は以下のように改題しました。
Many Xor Optimization Problems長さ かつ全ての要素が 以上 以下である整数列は 通り存在しますが、その全てに対して Xor Optimization Problem を解いた時の解の総和を で割ったあまりを求めてください。
Many Xor Optimization Problems を解いてください。
とは
非負整数 のビット単位 、 は、以下のように定義されます。
- を二進表記した際の () の位の数は、 を二進表記した際の の位の数のうち一方のみが であれば 、そうでなければ である。
一般に 個の非負整数 のビット単位 は と定義され、これは の順番によらないことが証明できます。
制約
- 入力は全て整数である。
入力
入力は以下の形式で標準入力から与えられます。
出力
答えを出力してください。
入力例 1Copy
2 1
出力例 1Copy
3
長さが かつ全ての要素が 以上 以下である整数列全てに対して Xor Optimization Problem を解きます。
- の時の解は
- の時の解は
- の時の解は
- の時の解は
よって、 が解となります。
入力例 2Copy
3 4
出力例 2Copy
52290
入力例 3Copy
1234 5678
出力例 3Copy
495502261
Score : points
Problem Statement
PCT made the following problem.
Xor Optimization ProblemYou are given a sequence of non-negative integers of length : . When it is allowed to choose any number of elements in , what is the maximum possible of the chosen values?
Nyaan thought it was too easy and revised it to the following.
Many Xor Optimization ProblemsThere are sequences of length consisting of integers between and . Find the sum, modulo , of the answers to Xor Optimization Problem for all those sequences.
Solve Many Xor Optimization Problems.
What is bitwise ?
The bitwise of non-negative integers and , , is defined as follows:
- When is written in base two, the digit in the 's place () is if exactly one of and is , and otherwise.
Generally, the bitwise of non-negative integers is defined as . We can prove that this value does not depend on the order of .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1Copy
2 1
Sample Output 1Copy
3
We are to solve Xor Optimization Problem for all sequences of length consisting of integers between and .
- The answer for is .
- The answer for is .
- The answer for is .
- The answer for is .
Thus, the final answer is .
Sample Input 2Copy
3 4
Sample Output 2Copy
52290
Sample Input 3Copy
1234 5678
Sample Output 3Copy
495502261