Deceleration
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

There is a car driving on a number line.

You need to handle the following two types of operations a total of q times:
  1. At the x-th second, add a deceleration plan. After the car has traveled for x seconds, its speed will be halved. Note that there can be multiple deceleration plans at the same second. If there are n deceleration plans in one second, its speed will be reduced to \frac{1}{2^n} of its original speed.

  2. Assuming the car starts from position 0 at time 0 with a speed of 1 and moves in the positive direction, calculate the time it takes to reach position x.

For all operations of the second type, output the result modulo 1,000,000,007.

输入描述:

The first line contains a positive integer q (1 \leq q \leq 5 \times 10^5), representing the number of operations.

The next q lines each contain two integers o and x (o \in \{1,2\}, 1 \leq x \leq 10^9), representing the type of operation and its parameter.

输出描述:

For all operations of the second type, output a single integer on a new line, representing the result modulo 1,000,000,007.

示例1

输入

复制
11
2 1
2 5
2 114514
1 5
2 4
2 6
1 3
2 4
2 5
1 114514
2 1919810

输出

复制
1
5
114514
4
7
5
9
15243944