codeparrot/codecomplex huggingface dataset:
// Problem: 224_B. Array
// Time complexity: linear
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {
    static StringTokenizer st;
    static PrintWriter out = new PrintWriter(System.out,true);
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    public static int nextInt() throws Exception {
        if(st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static long nextLong() throws Exception {
        if(st == null || !st.hasMoreTokens()) st = new StringTokenizer(in.readLine());
        return Long.parseLong(st.nextToken());
    }

    public static void main(String[] args) throws Exception {
        HashSet<Integer> set = new HashSet<>();
        int n = nextInt();
        int k = nextInt();
        int[] m = new int[n];
        int[] d = new int[n];
        for(int i = 0;i < n;i++) m[i] = nextInt();
        int l = -1;
        int r = -1;
        for(int i = 0;i < n;i++) {
            set.add(m[i]);
            d[i] = set.size();
            if(d[i] == k) {
                r = i;
                break;
            }
        }
        if(r == -1) {
            out.println("-1 -1");
            return;
        }

        for(int i = r;i >= 0;i--) {
            set.remove(m[i]);
            if(set.size() == 0) {
                l = i;
                break;
            }
        }
        out.println((l+1)+" "+(r+1));
    }
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class B {

    static BufferedReader in;
    static StringTokenizer st;

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = nextInt();
        int k = nextInt();
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = nextInt();
        }
        Set<Integer> set_1 = new HashSet<Integer>();
        for (int i = 1; i <= n; i++) {
            set_1.add(a[i]);
            if (set_1.size() == k) {
                Set<Integer> set_2 = new HashSet<Integer>();
                for (int j = i; j >= 1; j--) {
                    set_2.add(a[j]);
                    if (set_2.size() == k) {
                        out.print(j + " " + i);
                        out.close();
                        return;
                    }
                }
            }
        }
        out.print("-1 -1");
        out.close();

    }
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class B {

    private void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        
        int[] f = new int[100000 + 2];
        
        int min = Integer.MAX_VALUE;
        int cur = 0;
        int start = 0;
        int from = -1, to = -1;
        
        for (int i = 0; i < n; i++) {
            f[a[i]]++;
            if (f[a[i]] == 1) cur++;
            if (cur == k) {
                while (f[a[start]] > 1) {
                    f[a[start]]--;
                    start++;
                }
                if (i - start + 1 < min) {
                    min = i - start + 1;
                    from = start;
                    to = i;
                }
            }
        }
        pl(from == -1 ? "-1 -1" : ((1 + from) + " " + (1 + to)));
    }

    public static void main(String[] args) {
        new B().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }

    void p(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.flush();
            writer.print(objects[i]);
            writer.flush();
        }
    }

    void pl(Object... objects) {
        p(objects);
        writer.flush();
        writer.println();
        writer.flush();
    }

    int cc;

    void pf() {
        writer.printf("Case #%d: ", ++cc);
        writer.flush();
    }

}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.*;
public class B138 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a[] = new int[100004];
        int b[] = new int[100004];
        int n, m, ans = 0, dau, cuoi=-1;
        n = sc.nextInt();
        m = sc.nextInt();
        for(int i=0;i<100004;i++) a[i] = 0;
        for(int i=0;i<n;i++){
            b[i] = sc.nextInt();
            if(a[b[i]]==0){
                a[b[i]] = 1;
                ans++;
                if(ans==m){
                    cuoi = i+1;
                    break;
                }
            }
        }
        for(int i=cuoi-1;i>=00;i--){
            if(a[b[i]]==1){
                a[b[i]] = 0;
                ans--;
                if(ans==0){
                    System.out.println((i+1)+" "+cuoi);
                    System.exit(0);
                }
            }
        }
        System.out.println("-1 -1");
    }

}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.File;
import java.io.Writer;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author jarek
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int n = in.nextInt(), k = in.nextInt();
        int[] a = IOUtils.readIntArray(in, n);
        Set<Integer> cnt = new HashSet<Integer>();
        int i = 0;
        while (i < n && cnt.size() < k) {
            cnt.add(a[i]);
            if (cnt.size() < k)
                ++i;
        }
        if (cnt.size() < k)
            out.print("-1 -1");
        else {
            int r = i;
            cnt = new HashSet<Integer>();
            while (i >= 0 && cnt.size() < k) {
                cnt.add(a[i]);
                if (cnt.size() < k) --i;
            }
            out.print(i + 1, r + 1);
        }
    }
}

class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader(File f) {
        try {
            br = new BufferedReader(new FileReader(f));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public InputReader(InputStream f) {
        br = new BufferedReader(new InputStreamReader(f));
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void close() {
        writer.close();
    }
}

class IOUtils {

    public static int[] readIntArray(InputReader in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.nextInt();
        return array;
    }

    }
// Problem: 224_B. Array
// Time complexity: linear
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Lokesh Khandelwal aka (codeKNIGHT | phantom11)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n=in.nextInt(),k=in.nextInt();
        int a[]=new int[n];
        int i;
        for(i=0;i<n;i++)
            a[i]=in.nextInt();
        HashSet<Integer> hs=new HashSet<Integer>();
        boolean status=false;
        int index=-1;
        for(i=0;i<n;i++)
        {
            
            hs.add(a[i]);
            if(hs.size()==k)
            {
                index=i;
                status=true;
                break;
            }
        }
        if(!status)
        {
            out.println(-1+" "+ -1);
            return;
        }
        HashSet<Integer> hash=new HashSet<Integer>();
        for(i=index;i>=0;i--)
        {

            hash.add(a[i]);
            if(hash.size()==k)
            {
                break;
            }
        }
        out.println((i+1)+" "+(index+1));
    }
}

class InputReader
{
    BufferedReader in;
    StringTokenizer tokenizer=null;

    public InputReader(InputStream inputStream)
    {
        in=new BufferedReader(new InputStreamReader(inputStream));
    }
    public String next()
    {
        try{
            while (tokenizer==null||!tokenizer.hasMoreTokens())
            {
                tokenizer=new StringTokenizer(in.readLine());
            }
            return tokenizer.nextToken();
        }
        catch (IOException e)
        {
            return null;
        }
    }
    public int nextInt()
    {
        return Integer.parseInt(next());
    }

}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

public class Solver {

    StringTokenizer st;
    BufferedReader in;
    PrintWriter out;

    public static void main(String[] args) throws NumberFormatException,
            IOException {
        Solver solver = new Solver();
        solver.open();
        long time = System.currentTimeMillis();
        solver.solve();
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.out.println("Spent time: "
                    + (System.currentTimeMillis() - time));
        }
        solver.close();
    }

    public void open() throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws NumberFormatException, IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws NumberFormatException, IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }

    public void solve() throws NumberFormatException, IOException {
        int n = nextInt();
        int k = nextInt();
        
        int[] ar = new int[n];
        int[] ex = new int[100005];
        int dif = 0;
        
        for(int i=0;i<n;i++){
            int tmp = nextInt();
            ar[i] = tmp;
            if (ex[tmp]++==0){
                dif++;          
            }           
        }
        
        if (dif<k){
            out.println("-1 -1");
            return;
        }
        
        Arrays.fill(ex, 0);
        dif = 0;
        int right = 0;
        while(dif<k){
            int tmp = ar[right];
            if(ex[tmp]++==0){       
                dif++;
            }
            right++;
        }
        
        int left = 0;
        while (ex[ar[left]]-- > 1) left++;
        
        out.println((left+1)+" "+right);
    }

    public void close() {
        out.flush();
        out.close();
    }

}
// Problem: 224_B. Array
// Time complexity: linear
import java.util.*;
import java.math.*;

public class Main {
    static final long MOD = 1000000007L;
    
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        int res = -1;
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = scan.nextInt();
        }
        BitSet bits = new BitSet();
        int count = 0;
        int end = -1;
        for (int i = 0; i < arr.length; i++) {
            if (!bits.get(arr[i])) {
                bits.set(arr[i]);
                count++;
                if (count == k) {
                    end = i;
                    break;
                }
            }
        }
        if (end == -1) {
            System.out.print("-1 -1");
            return;
        }
        bits = new BitSet();
        count = 0;
        int start = end;
        while (start >= 0) {
            if (!bits.get(arr[start])) {
                bits.set(arr[start]);
                count++;
                if (count == k) {
                    break;
                }
            }
            start--;
        }
        System.out.println((start + 1) + " " + (end + 1));
    }
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.*;
import java.util.*;

public class Main {
	boolean eof;

	public String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "-1";
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(nextToken());
	}

	int NOD(int a, int b) {
		while (a * b > 0) {
			if (a > b) {
				a %= b;
			} else {
				b %= a;
			}
		}
		return a + b;
	}

	void solve() {
		int n = nextInt(), k= nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i){
			a[i] = nextInt() - 1;
		}
		int[] b = new int[100000];
		int p = 0;
		for (int i = 0; i < n; ++i){
			++b[a[i]];
			if (b[a[i]] == 1){
				++p;
			}
			if (k == p){
				int j;
				for (j = 0; j <= i; ++j){
					if (b[a[j]] > 1){
						--b[a[j]];
					} else {
						break;
					}
				}
				out.print((j + 1) + " " + (i + 1));
				return;
			}
		}
		out.print("-1 -1");
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));

			// br = new BufferedReader(new FileReader("input.txt"));
			// out = new PrintWriter(new FileWriter("output.txt"));
			solve();
			br.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;



public class Main {
	static class MyReader{
	    private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    MyReader(Reader r) throws IOException{
	        reader = new BufferedReader(r);
	    }
	    public int nextInt() throws IOException {
	        return Integer.parseInt(nextToken());
	    }
	    public String nextToken() throws IOException {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            tokenizer = new StringTokenizer(reader.readLine());
	        }
	        return tokenizer.nextToken();
	    }
	}
	public static void main(String []args) throws IOException{
		PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));
		MyReader reader = new MyReader(new InputStreamReader(System.in));
		int n = reader.nextInt();
		int k = reader.nextInt();
		int []a = new int[n];
		for (int i = 0; i < n; ++i)
			a[i] = reader.nextInt();
		int j = 0;
		HashMap<Integer,Integer> map = new HashMap<>();
		for (int i = 0; i < n; ++i){
			if (map.containsKey(a[i]))
				map.put(a[i], map.get(a[i])+1);
			else{
				map.put(a[i], 1);
				if (map.size()==k) { j = i+1; break; }
			}
		}
		if (map.size()<k){
			System.out.println("-1 -1");
			return;
		}
		for (int i = 0; i < n; ++i){
			if (map.get(a[i])==1){
				System.out.println(i+1 + " " + j);
				return;
			}
			map.put(a[i], map.get(a[i])-1);
		}
	}
	
}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;


public class B {
	
	static class Scanner
	{
		BufferedReader rd;
		StringTokenizer tk;
		public Scanner() throws IOException
		{
			rd=new BufferedReader(new InputStreamReader(System.in));
			tk=new StringTokenizer(rd.readLine());
		}
		public String next() throws IOException
		{
			while(!tk.hasMoreTokens())
				tk=new StringTokenizer(rd.readLine());
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException
		{
			return Integer.valueOf(this.next());
		}
	}
	
	static int N,K;
	static int[] array=new int[100010];
	
	public static void main(String args[]) throws IOException{
		Scanner sc=new Scanner();
		N=sc.nextInt();
		K=sc.nextInt();
		for(int i=0;i<N;i++)
			array[i]=sc.nextInt();
		TreeMap<Integer,Integer> map=new TreeMap<Integer,Integer>();
		boolean flag=false;
		for(int i=0;i<N;i++){
			if (!map.containsKey(array[i])){
				map.put(array[i], i);
				if (map.size()==K){
					flag=true;
					break;
				}
			}
			else
				map.put(array[i], i);
		}
		if (!flag)
			System.out.println("-1 -1");
		else{
			Set<Integer> s=map.keySet();
			int l=Integer.MAX_VALUE;
			int r=Integer.MIN_VALUE;
			for(int k: s){
				int tmp=map.get(k);
				l=Math.min(l, tmp);
				r=Math.max(r, tmp);
			}
			System.out.println((l+1)+" "+(r+1));
		}
	}

}
// Problem: 224_B. Array
// Time complexity: linear
import java.io.*;
import java.util.*;

public class CodeForces {
    static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    void runCase(int caseNum) throws IOException {
        int n = nextInt();
        int k = nextInt();
        int[] nums = new int[n];
        int distinct = 0;
        int L = -1, R = -1;
        int minLen = Integer.MAX_VALUE;
        int maxNum = 0;

        for (int i = 0; i < n; ++i) {
            nums[i] = nextInt();
            maxNum = Math.max(maxNum,  nums[i]);
        }
        int[] count = new int[maxNum + 1];
        int j = 0;

        for (int i = 0; i < n; ++i) {
            ++count[nums[i]];
            if (count[nums[i]] == 1) {
                ++distinct;
                if (distinct >= k) {
                    for (; j <= i; ++j) {
                        --count[nums[j]];
                        if (count[nums[j]] <= 0) {
                            --distinct;
                            if (distinct < k) {
                                if (i - j < minLen) {
                                    minLen = i - j;
                                    L = j + 1;
                                    R = i + 1;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        out.print(L + " " + R);
    }


    public static void main(String[] args) throws IOException {
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
        new CodeForces().runIt();
        out.flush();
        out.close();
        return;
    }

    static BufferedReader in;
    private StringTokenizer st;
    static PrintWriter out;

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            st = new StringTokenizer(line, " ");
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }


    void runIt() throws IOException {
        st = new StringTokenizer("");

//        int N = nextInt();
//        for (int i = 0; i < N; i++) {
//            runCase(i + 1);
//        }
        runCase(0);

        out.flush();
    }

}