There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type a i . Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type. Split the row of the pearls to the maximal number of good segments. Note that each pearl should appear in exactly one segment of the partition. As inputoutput can reach huge size it is recommended to use fast inputoutput methods: for example, prefer to use scanfprintf instead of cincout in C++, prefer to use BufferedReaderPrintWriter instead of ScannerSystem.out in Java.
输入描述:
The first line contains integer n (1 ≤ n ≤ 3·105) — the number of pearls in a row.The second line contains n integers ai (1 ≤ ai ≤ 109) – the type of the i-th pearl.


输出描述:
On the first line print integer k — the maximal number of segments in a partition of the row.Each of the next k lines should contain two integers lj, rj (1 ≤ lj ≤ rj ≤ n) — the number of the leftmost and the rightmost pearls in the j-th segment.Note you should print the correct partition of the row of the pearls, so each pearl should be in exactly one segment and all segments should contain two pearls of the same type.If there are several optimal solutions print any of them. You can print the segments in any order.If there are no correct partitions of the row print the number "-1".
示例1

输入

5<br />1 2 3 4 1<br />5<br />1 2 3 4 5<br />7<br />1 2 1 3 1 2 1<br />

输出

1<br />1 5<br />-1<br />2<br />1 3<br />4 7<br />
加载中...