atcoder#ARC123F. [ARC123F] Insert Addition

[ARC123F] Insert Addition

Score : 10001000 points

Problem Statement

For a sequence of integers P=(P1,,PM)P = (P_1, \ldots, P_M), let f(P)f(P) denote the sequence obtained by inserting Pi+Pi+1P_i + P_{i+1} between PiP_i and Pi+1P_{i+1} for each 1iM11\leq i\leq M-1. More formally:

  • Let Qi=Pi+Pi+1Q_i = P_i + P_{i+1} for each 1iM11\leq i\leq M - 1.
  • Let f(P)f(P) be defined as a sequence of 2M12M-1 integers $f(P) = (P_1, Q_1, P_2, Q_2, \ldots, P_{M-1}, Q_{M-1}, P_M)$.

Given are three positive integers aa, bb, and NN where a,bNa, b\leq N. Let us begin with a sequence A=(a,b)A = (a, b) and define a sequence B=(B1,B2,)B = (B_1, B_2, \ldots) as follows.

  • Do the following NN times: replace AA with f(A)f(A).
  • Then, remove from AA all values greater than NN and let BB be the resulting sequence.

Find BL,,BRB_L, \ldots, B_R.

Constraints

  • 1N3×1051\leq N\leq 3\times 10^5
  • 1a,bN1\leq a, b\leq N
  • 1LR10181\leq L\leq R\leq 10^{18}
  • RL<3×105R - L < 3\times 10^5
  • RR is at most the number of elements in the sequence BB.

Input

Input is given from Standard Input in the following format:

aa bb NN

LL RR

Output

Print a line containing BL,,BRB_L, \ldots, B_R, with a space in between.

1 1 4
1 7
1 4 3 2 3 4 1

Initially, A=(1,1)A = (1, 1). The replacements of AA with f(A)f(A) take place as follows.

  • After the first replacement: A=(1,2,1)A = (1, 2, 1).
  • After the second replacement: A=(1,3,2,3,1)A = (1, 3, 2, 3, 1).
  • After the third replacement: A=(1,4,3,5,2,5,3,4,1)A = (1, 4, 3, 5, 2, 5, 3, 4, 1).
  • After the fourth replacement: $A = (1, 5, 4, 7, 3, 8, 5, 7, 2, 7, 5, 8, 3, 7, 4, 5, 1)$.

Thus, we have B=(1,4,3,2,3,4,1)B = (1, 4, 3, 2, 3, 4, 1). We should report the 11-st through 77-th elements of this sequence.

1 1 4
2 5
4 3 2 3

Again, we have B=(1,4,3,2,3,4,1)B = (1, 4, 3, 2, 3, 4, 1). We should report the 22-nd through 55-th elements of this sequence.

2 1 10
5 15
8 3 10 7 4 9 5 6 7 8 9
10 10 10
2 2
10