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

#CC0000036. Quản lý các khoảng đã đánh dấu (Range Module)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Quản lý các khoảng đã đánh dấu (Range Module)

Range Module

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Initially, no real number is tracked. You must process operations on half-open intervals [l,r)[l,r), including ll but excluding rr. addRange l r starts tracking all real numbers in the interval. removeRange l r stops tracking them. queryRange l r asks whether every real number in that interval is currently tracked.

Input

The first line contains QQ. Each of the next QQ lines contains addRange, removeRange, or queryRange followed by l,rl,r.

Output

For each queryRange query, print true when the entire interval is covered, otherwise print false.

Subtasks

  • Subtask 1 (20 points): 1≤Q≤201\le Q\le 20; 1≤l<r≤1091\le l<r\le10^9.
  • Subtask 2 (30 points): 1≤Q≤5001\le Q\le 500; 1≤l<r≤1091\le l<r\le10^9.
  • Subtask 3 (50 points): 1≤Q≤100001\le Q\le 10000; 1≤l<r≤1091\le l<r\le10^9.

Examples

Input

6
addRange 10 20
removeRange 14 16
queryRange 10 14
queryRange 13 15
queryRange 16 17
queryRange 10 20

Output

true
false
true
false

Explanation

Removing [14,16) leaves [10,14) and [16,20). Hence queries [10,14) and [16,17) are true.