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 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

Difficulty: interview

Starter code:

Solutions:
n = int(input())
cnt = 0
gems = list(map(int, input().split()))
pearls = set()
for i in range(n):
    if gems[i] not in pearls:
        pearls.add(gems[i])
    else:
        cnt += 1
        pearls = set()
    
if cnt:
    print(cnt)
    first = 0
    second = 0
    pearls = set()
    for i in range(n):
        if gems[i] not in pearls:
            pearls.add(gems[i])
        else:
            if second:
                print(first + 1, second + 1)
                first = second + 1
            second = i
            pearls = set()
    print(first + 1, n)
else:
    print('-1')

n = int(input())
data = list(map(int, input().split()))
answer = []
start = 1
finish = 1
help_set = set()
for i in range(n):
    if data[i] in help_set:
        answer.append([start, finish])
        help_set = set()
        start = finish + 1
        finish += 1
    else:
        finish += 1
        help_set.add(data[i])
if len(answer) == 0:
    print(-1)
elif n == 1:
    print(1)
    print(1, 1)
else:
    answer[-1][-1] = n
    print(len(answer))
    for i in range(len(answer)):
        print(*answer[i])

n = int(input())
data = list(map(int, input().split()))
answer = []
start = 1
finish = 1
help_set = set()
for i in range(n):
    if data[i] in help_set:
        answer.append([start, finish])
        help_set = set()
        start = finish + 1
        finish += 1
    else:
        finish += 1
        help_set.add(data[i])
if len(answer) == 0:
    print(-1)
else:
    answer[-1][-1] = n
    print(len(answer))
    for i in range(len(answer)):
        print(*answer[i])

n = int(input())
data = list(map(int, input().split()))
a = 0
answer = []
start = 1
finish = 1
help_set = set()
for i in range(n):
    if data[i] in help_set:
        answer.append([start, finish])
        help_set = set()
        start = finish + 1
        finish += 1
    else:
        finish += 1
        help_set.add(data[i])
if len(answer) == 0:
    print(-1)
else:
    answer[-1][-1] = n
    print(len(answer))
    for i in range(len(answer)):
        print(*answer[i])

n = int(input())
lst = list(map(int, input().split()))
ans = []
l = 0
r = -1
s = set()
for i in range(n):
    if lst[i] in s:
        ans.append([l + 1, i + 1])
        s = set()
        l = i + 1
        r = i + 1
    else:
        s.add(lst[i])
        
    
if r != n and r != -1:
    ans[-1][1] = n
if r == -1:
    print(-1)
else:
    print(len(ans))
    for i in ans:
        print(*i)


n = int(input())
li = list(map(int,input().split()))
s=set()
ans=[]
l=0
r=-1
for i in range(n):
	if li[i] in s:
		ans.append([l+1,i+1])
		s = set()
		l = i+1
		r=1
	else:
		s.add(li[i])
if r==-1:
	print(-1)
else:
	print(len(ans))
	ans[len(ans)-1][1]=n
	for i in ans:
		print(*i)

#author="_rabbit"
n=int(input())
a=list(map(int,input().split()))
ans=[]
s=set()
flag=False
l=0
for i in range(n):
    if a[i] in s:
        ans.append([l+1,i+1])
        l=i+1
        s=set()
        flag=True
    else:
        s.add(a[i])
if(flag==False):
    print(-1)
else:
    print(len(ans))
    ans[len(ans)-1][1]=n
    for i in ans:
        print(*i)


n = int(input())
li = list(map(int,input().split()))
s=set()
otv=[]
l=0
r=-1
for i in range(n):
	if li[i] in s:
		otv.append([l+1,i+1])
		s = set()
		l = i+1
		r=1
	else:
		s.add(li[i])
if r==-1:
	print(-1)
else:
	print(len(otv))
	otv[len(otv)-1][1]=n
	for i in otv:
		print(*i)


ans = []
s = set()
l = 1
n = input()
for i, e in enumerate(map(int, input().split()), 1):
    if e in s:
        s = set()
        ans += [(l, i)]
        l = i + 1
    else:
        s.add(e)
if ans:
    print(len(ans))
    ans[-1] = ans[-1][0], n
    for a, b in ans:
        print(a, b)
else:
    print(-1)

n = (int(input()))
j = list(map(int,input().split()))
b = 0
e = 0
ans = []
subline = set()
while e < n:
    perl = j[e]
    if perl in subline:
        ans+=[[b+1,e+1]]
        subline = set()
        b = e+1
        e+=1
    else:
        subline.add(perl)
        e+=1;
if len(ans) == 0:
    print(-1)
else:

    ans[-1][1] = n
    print(len(ans))
        
    for i in range(len(ans)):
        print(' '.join(list(map(str,ans[i]))))
        
    


length = int(input())
gems = input().split()

result = []
s = 0
dist = set()
pend_e = 0
pend_s = 0
for i in range(0, length):
    cur = gems[i]
    if cur not in dist:
        dist.add(cur)
    else:
        if pend_e != 0:
            result.append([pend_s, pend_e])
        pend_e = i + 1
        pend_s = s + 1
        s = i + 1
        dist.clear()

if s != 0 and pend_e != length + 1:
    result.append([pend_s, length])

if len(result) == 0:
    print(-1)
else:
    print(len(result))

for r in result:
    print(r[0], r[1])


n = int(input())
a = list(map(int, input().split()))
z = []; p = set()
k1 = 1
for i in range(n):
    if a[i] in p:
        z.append((k1, i+1))
        k1 = i+2
        p = set()
    else:
        p.add(a[i])
if len(z) > 0:
    z[len(z)-1] = (z[len(z)-1][0], n)
    print(len(z))
    for k in z:
        print(k[0], k[1])
else:
    print(-1)


n = int(input())
a = list(map(int, input().split()))
sub = set()
starts = list()
starts.append(1)
for i in range(n):
    if a[i] in sub:
        sub = set()
        starts.append(i+2)
    else:
        sub.add(a[i])
l = len(starts)
if l == 1:
    print(-1)
else:
    print(l-1)
    for i in range(l-2):
        print(starts[i], starts[i+1]-1)
    print(starts[l-2], n)

        


n = int(input())
s = input().split()
initial_pos = 0
ans = 0
ans_list = []
l = set()
for i in range(n):
	if s[i] in l:
		ans += 1
		ans_list.append([initial_pos+1, i+1])
		initial_pos = i+1
		l = set()
	else:
		l.add(s[i])
if ans == 0:
	print(-1)
else:
	if not ans_list[-1][1] == n:
		ans_list[-1][1] = n
	print(ans)
	for i in ans_list:
		print(' '.join(str(e) for e in i))

3

n = int(input())
a = [int(x) for x in input().split()]

r = []
s = set()
l = 0
for i, x in enumerate(a):
  if x in s:
    r.append([l + 1, i + 1])
    l = i + 1
    s = set()
  else:
    s.add(x)
if l == 0:
  print(-1)
else:
  if s:
    r[-1][1] = n
  print(len(r))
  print('\n'.join('{0} {1}'.format(p, q) for (p, q) in r))



'''
Created on Jan 25, 2016

@author: KANDARP
'''
import sys
n=int(sys.stdin.readline());
arr=[int(x) for x in input().split()];
sets=set();
result=[];
ans=0;
l=0;
r=0;
for i in arr:
    if(i in sets):
        ans=ans+1;
        sets.clear();
        result.append([l+1,r+1]);
        l=r+1;
    else:
        sets.add(i);
    r=r+1;
if ans==0:
    print((-1));
else:
    result[len(result)-1]=[result[len(result)-1][0],n];
    print(ans);    
    print(('\n'.join('{0} {1}'.format(p, q) for (p, q) in result)));     





#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 missingdays <missingdays@missingdays>
#
# Distributed under terms of the MIT license.

"""

"""

def good(nums):
    for num in nums:
        if nums[num] > 1:
            return True
    return False

n = int(input())

a = [int(i) for i in input().split()]

s = []

l, r = 0, 0
nums = {}

for i in range(n):
    num = a[i]

    if num in nums:
        break
    else:
        nums[num] = True
else:
    print(-1)
    return

nums = {}

while r < n:
    while r < n:
        num = a[r]

        if num in nums:
            r += 1
            break
        else:
            nums[num] = True

        r += 1

    r -= 1

    s.append([l, r])
    r += 1
    l = r

    nums = {}

length = len(s)

last = s[length-1]

for i in range(last[0], last[1]+1):
    num = a[i]
    if num in nums:
        print(length)
        break
    else:
        nums[num] = True
else:
    s.pop()

    s[length-2][1] = n-1

    print(length-1)

for st in s:
    for c in st:
        print(c+1, end=" ")
    print()



n = int(input())
index = 1
memory = set()
counter = 0
segments = [[0, 0]]
for number in input().split():
    if number not in memory:
        memory.add(number)
    else:
        counter += 1
        segments.append([segments[-1][1] + 1, index])
        memory = set()
    index += 1
segments[-1][1] = n
if counter != 0:
    print(counter)
    segments.remove([0, 0])
    print('\n'.join('{0} {1}'.format(p, q) for (p, q) in segments))
else:
    print(-1)

n = int(input())
d={}
s=input()
s=s.split()
start =0
ans=[]
for i in range(n):
    if s[i] not in d:
        d[s[i]]=1
    else:
        ans.append([start+1,i+1])
        start=i+1
        d={}
if ans==[]:
    print(-1)
else:
    print(len(ans))
    for i in range(len(ans)):
        if i==len(ans)-1:
            print(ans[i][0],n)
        else:
            print(ans[i][0],ans[i][1])

    
    


import sys
n=int(input())
a=list(map(int,input().split()))
b=set()
beg=1
am=0
aml=[]
for i in range(n):
    if a[i] in b:
        aml.append([beg,i+1])
        am+=1
        b=set()
        beg=i+2
    else:
        b.add(a[i])
if am==0:
    print(-1)
    return
if aml[am-1][1]!=n:
    aml[am-1][1]=n
print(am)
for i in range(am):
    print(aml[i][0],aml[i][1])


n = int(input())
ans = list()
s = set()
for i,x in enumerate(map(int, input().split())):
    if not s:
        idx = i+1
    elif x in s:
        ans.append((idx, i+1))
        s = set()
        continue
    s.add(x)
if len(ans):
    ans[-1] = (ans[-1][0], n)
    print(len(ans))
    print('\n'.join('%d %d' % p for p in ans))
else:
    print(-1)

n = int(input())
A = [int(x) for x in input().split()]
s = {A[0]}
left = 1
segments = []
for i in range(1, n):
    if A[i] in s:
        segments.append((left, i+1))
        left = i+2
        s.clear()
    else:
        s.add(A[i])
if len(segments) == 0:
    print(-1)
else:
    segments[-1] = (segments[-1][0], n)
    print(len(segments))
    for l, r in segments:
        print(l, r)


n = int(input())
a = list(map(int, input().split(' ')))

ans = []

s = 0
mark = set([a[0]])
for i in range(1, n):
    if a[i] in mark:
        mark = set()
        ans.append([s+1, i+1])
        s = i+1
    else:
        mark.add(a[i])

if len(ans) == 0:
    print(-1)
else:
    ans[-1][1] = n
    print(len(ans))
    for line in ans:
        print(line[0], line[1])


pearl_count = int(input())
pearls = [int(pearl) for pearl in input().split()]
recorded = set()
intervals = []
begin = 1
for i in range(pearl_count):
    if pearls[i] in recorded:
        intervals.append([begin, i + 1])
        recorded = set()
        begin = i + 2
    else:
        recorded.add(pearls[i])
if intervals:
   intervals[-1][-1] = pearl_count
   print(len(intervals))
   [print(' '.join(map(str, interval))) for interval in intervals]
else:
    print(-1)

def main():
    n, res = int(input()), []
    s, i, fmt = set(), 1, "{:n} {:n}".format
    for j, a in enumerate(input().split(), 1):
        if a in s:
            s = set()
            res.append(fmt(i, j))
            i = j + 1
        else:
            s.add(a)
    if res:
        print(len(res))
        res[-1] = res[-1].split()[0] + ' ' + str(n)
        print('\n'.join(res))
    else:
        print(-1)


def __starting_point():
    main()

__starting_point()