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

#CC0000037. Tìm điểm phía trên bên phải (Points)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tìm điểm phía trên bên phải (Points)

Points

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Maintain a changing set of points on the Cartesian plane. add x y adds an absent point (x,y)(x,y); remove x y erases a present point. For find x y, consider only points (u,v)(u,v) satisfying both u>xu>x and v>yv>y. Choose the point with minimum uu, breaking ties by minimum vv. If no point qualifies, output -1.

Input

The first line contains QQ. Each of the next QQ lines is add x y, remove x y, or find x y.

Output

For each find, print the chosen coordinates, or -1 if no point qualifies.

Subtasks

  • Subtask 1 (20 points): 1≤Q≤201\le Q\le 20; 0≤x,y≤1090\le x,y\le10^9; each add adds an absent point and each remove deletes a present point.
  • Subtask 2 (30 points): 1≤Q≤7001\le Q\le 700; 0≤x,y≤1090\le x,y\le10^9; each add adds an absent point and each remove deletes a present point.
  • Subtask 3 (50 points): 1≤Q≤2000001\le Q\le 200000; 0≤x,y≤1090\le x,y\le10^9; each add adds an absent point and each remove deletes a present point.

Examples

Input

7
add 1 1
add 3 4
find 0 0
remove 1 1
find 0 0
add 1 1
find 0 0

Output

1 1
3 4
1 1

Explanation

Point (1,1) is initially the leftmost valid point. After removing it, (3,4) is chosen; adding it back restores (1,1).