Fiboxor

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Little Square and Little Triangle are having a fight on Valentine’s day again! The reason of this year’s fight? Little Square has said that the Fibonacci sequence is way prettier than the sequence of powers of two (Little Triangle’s favorite). Recall that the Fibonacci sequence is the sequence that begins with 0 and 1, and where subsequent elements are the sum of the two previous elements:

0,1,1,2,3,5,8,13,0, 1, 1, 2, 3, 5, 8, 13, \dots

Little Triangle likes this sequence particularly because you can easily calculate the bitwise exclusive or (XOR) of any subarray. Thus they told Little Square that if they can successfully answer QQ such XOR subarray queries, then they will accept the fact that Fibonacci is better. Little Triangle isn’t cruel though, so they agreed to let Little Square tell them only the value of the subarray XOR modulo 2k2^k each query, due to the fact that the Fibonacci sequence grows exponentially.

In the end, Little Square has to answer QQ queries, each of which contains three integers kk, ll, rr. This query asks us to calculate the XOR of the Fibonacci numbers with indexes in the interval \[l,r]\[l, r] inclusive, indexed from 00, modulo 2k2^k.

Little Square asks for your help in order to win this argument, so they can go back at having a good time on Valentine’s day.

제한

  • 1Q1061 ≤ Q ≤ 10^6
  • 0lr10180 ≤ l ≤ r ≤ 10^{18}
  • 1k201 ≤ k ≤ 20

힌트

Let aba ⊕ b denote the XOR of aa and bb.

In the first query, 0112mod22=2mod4=20 ⊕ 1 ⊕ 1 ⊕ 2 \mod 2^2 = 2 \mod 4 = 2.

In the second query, 358mod24=14mod16=143 ⊕ 5 ⊕ 8 \mod 2^4 = 14 \mod 16 = 14.