Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

C. Pearls in a Row

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThere 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 input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use scanf/printf instead of cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

Input

The first line contains integer *n* (1 ≤ *n* ≤ 3·10^{5}) — the number of pearls in a row.

The second line contains *n* integers *a*_{i} (1 ≤ *a*_{i} ≤ 10^{9}) – the type of the *i*-th pearl.

Output

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 *l*_{j}, *r*_{j} (1 ≤ *l*_{j} ≤ *r*_{j} ≤ *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".

Examples

Input

5

1 2 3 4 1

Output

1

1 5

Input

5

1 2 3 4 5

Output

-1

Input

7

1 2 1 3 1 2 1

Output

2

1 3

4 7

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/29/2020 19:11:33 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|