Please implement an efficient data structure to support just one operation. Let be the current elements (natural numbers) in the data structure, all different and in increasing order. Given three parameters , , and , you must insert into your data structure. Assume that you start with just one element, with value 0.
Input begins consists of several cases. Each case starts with the number of insertions . Follow triples . Assume , , and . The end of input is indicated with a special case with .
For every operation, if
is a new value, insert
and print I
.
Otherwise, do not insert
and print R
.
Print a line with 10 dashes at the end of each case.
Input
4 5 1 1 3 1 1 2 1 2 3 2 3 5 0 1 1 999999999 1 1 1 2 2 999999999 1 2 999999999 1 3 0
Output
I 5 I 3 R 5 I 11 ---------- R 0 I 999999999 R 0 I 999999998 I 999999996 ----------