PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000239. Vườn cây tại nhà (Home Garden)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Vườn cây tại nhà (Home Garden)

Home Garden

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Takahashi owns 1010010^{100} pots, initially without plants. Process QQ operations in order: 1 plants a new plant of height zero in a vacant pot; 2 T advances time by TT days and increases each living plant's height by TT; 3 H removes all plants of height at least HH and reports their count. Planting and harvesting take no time.

Input

The first line contains integer QQ. The next QQ lines each contain 1, 2 T, or 3 H as described, with integer T,HT,H.

Output

For each type-3 operation, print the number of plants removed on its own line.

Subtasks

  • Subtask 1 (20 points): 1≤Q≤801\le Q\le 80; 1≤T,H≤1091\le T,H\le 10^9 whenever present; at least one type-3 operation.
  • Subtask 2 (30 points): 1≤Q≤2⋅1051\le Q\le 2\cdot10^5; 1≤T,H≤1091\le T,H\le 10^9 whenever present; at least one type-3 operation; all type-1 operations precede every type-2 or type-3 operation.
  • Subtask 3 (50 points): 1≤Q≤2⋅1051\le Q\le 2\cdot10^5; 1≤T,H≤1091\le T,H\le 10^9 whenever present; at least one type-3 operation.

Examples

Input

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

Output

1
1
0

Explanation

After four days the first plant is 4 tall. The second starts at zero. Harvesting at 4 removes the first. Three days later the remaining plant reaches 3 and is removed. The final harvest is empty.