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();

    }
}


import java.io.*;
import java.util.*;

public class B {
    public static void main(String[] args) throws Exception {
        new B().solve();
    }

    void solve() throws IOException {
        BufferedReader in = new BufferedReader(new
                InputStreamReader(System.in));
        // Scanner sc = new Scanner(System.in);

        String[] sp = in.readLine().split(" ");

        int n = Integer.parseInt(sp[0]);
        int k = Integer.parseInt(sp[1]);
        int[] a = new int[n];
        sp = in.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sp[i]);
        }

        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        int r = 0;
        map.put(a[r], 1);
        while (map.size() < k) {
            r++;
            if (r == n) {
                // ng
                System.out.println("-1 -1");
                return;
            }
            if (map.containsKey(a[r])) {
                map.put(a[r], map.get(a[r]) + 1);
            } else {
                map.put(a[r], 1);
            }
        }
        int l = 0;
        while (map.get(a[l]) > 1) {
            map.put(a[l], map.get(a[l]) - 1);
            l++;
        }
        System.out.println((l + 1) + " " + (r + 1));
    }
}

//


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));
    }
}


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();
    }

}


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");
    }

}


        import java.io.*;
        import java.math.BigInteger;
        import java.util.*;

        public class Main {

            static final double eps = 1e-8;

            public static void main(String[] args) throws IOException {
                try {

                       int n = nextInt();
                       int k = nextInt();
                       int[] a = new int[n];
                       int[] d = new int[n];
                       int[] dr = new int[n];
                       boolean used[] = new boolean[100001];
                       a[0] = nextInt();
                       used[ a[0] ] = true;
                       d[0] = 1;
                       for(int i = 1; i < n; i++)
                       {
                           a[i] = nextInt();
                           if(!used[ a[i] ])
                           {
                               used[ a[i] ] = true;
                               d[i] = d[i - 1] + 1;
                           }
                           else
                           {
                               d[i] = d[i - 1];
                           }
                       }
                       Arrays.fill(used, false);

                       int r = Arrays.binarySearch(d, k);

                       if(r < 0)
                       {
                           pw.println("-1 -1");
                           return;
                       }

                       while( r > 0 && d[r] == d[r - 1] )
                           r--;

                       used[ a[r] ] = true;
                       dr[r] = 1;
                       for(int i = r - 1; i >= 0; i--)
                       {
                           if(!used[ a[i] ])
                           {
                               used[ a[i] ] = true;
                               dr[i] = dr[i + 1] + 1;
                           }
                           else
                           {
                               dr[i] = dr[i + 1];
                           }
                       }

                       int l = 0;

                       while(l < n - 1 && dr[l] == dr[l + 1] && r - l >= k)
                           l++;

                       pw.println(l + 1 + " " + (r + 1));
                }
                finally {
                    pw.close();
                }
            }

            static Scanner sc = new Scanner(System.in);
            static PrintWriter pw = new PrintWriter(System.out);
            static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
            static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            static StringTokenizer st ;
            static int nextInt() throws IOException {
                in.nextToken();
                return (int) in.nval;
            }
            static long nextLong() throws IOException {
                in.nextToken();
                return (long) in.nval;
            }
            static double nextDouble() throws IOException {
                in.nextToken();
                return in.nval;
            }
            static String next() throws IOException {
                in.nextToken();
                return in.sval;
            }
            static void outArray(int[] O) {
                for(int i = 0; i < O.length - 1; i++)
                    pw.print(O[i] + " ");
                pw.println(O[O.length - 1]);
            }
        }


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

    }


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());
    }

}


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();
    }

}


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));
    }
}


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();
	}
}


import java.util.Map;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.io.BufferedWriter;
import java.util.Locale;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.util.Set;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jacob Jiang
 */
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();
        int k = in.nextInt();
        int[] a = in.nextIntArray(n);
        if (k == 1) {
            out.println("1 1");
            return;
        }
        int left = -1, right = -1;
        Counter<Integer> counter = new Counter<Integer>();
        while (true) {
            right++;
            if (right == n) {
                out.println("-1 -1");
                return;
            }
            counter.add(a[right]);
            if (counter.size() >= k)
                break;
        }
        while (true) {
            left++;
            if (counter.get(a[left]) == 1)
                break;
            counter.add(a[left], -1);
        }
        out.printLine(left + 1, right + 1);
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c & 15;
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public int[] nextIntArray(int count) {
        int[] result = new int[count];
        for (int i = 0; i < count; i++) {
            result[i] = nextInt();
        }
        return result;
    }

    }

class OutputWriter {
    private PrintWriter writer;

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

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

    public void print(Object obj) {
        writer.print(obj);
    }

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

    public void println(String x) {
        writer.println(x);
    }

    public void print(char c) {
        writer.print(c);
    }

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

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

    public void printLine(Object... items) {
        printItems(items);
        println();
    }

}

class Counter<T> extends HashMap<T, Long> {
    public void add(T obj, long count) {
        put(obj, get(obj) + count);
    }

    public void add(T obj) {
        put(obj, get(obj) + 1L);
    }

    public Long get(Object key) {
        return containsKey(key) ? super.get(key) : 0L;
    }
}


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);
		}
	}

}


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));
		}
	}

}


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();
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: Alexey
 * Date: 16.09.12
 * Time: 19:29
 * To change this template use File | Settings | File Templates.
 */
public class stub implements Runnable {
    public static void main(String[] args) {
        new stub().run();
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer st;

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

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

    private void solve() throws IOException {
        int[] cnt = new int[(int) 1e6];
        int n = nextInt();
        int k = nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }

        int cur = 0;
        int left = 0;
        int i = left;
        while (i < n && cur != k) {
            if (cnt[a[i]] == 0) {
                cur++;
            }
            cnt[a[i]]++;
            i++;
        }
        i--;
        if (cur != k) {
            out.println("-1 -1");
            return;
        }
        int right = i;
        while (cnt[a[left]] > 1) {
            cnt[a[left]]--;
            left++;
        }
        out.println((left + 1) + " " + (right + 1));
    }

    public void run() {
        try {
            solve();
            out.close();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Parser p = new Parser(System.in);
		PrintWriter pw= new PrintWriter(System.out);

		int n = p.nextInt();
		int k = p.nextInt();

		int[] a = p.nextIntArray(n);
		int [] pos = new int[100001];
		Arrays.fill(pos,-1);
		int cnt = 0;
		for(int i=0; i<n; ++i){
			int e = a[i];
			if( pos[e] == -1 ){
				++cnt;
			}
			pos[e] = i;
			if( cnt == k){
				break;
			}
		}
		if( cnt < k){
			pw.println("-1 -1");
			pw.close();
			return;
		}
		int min = 1000000;
		int max = -1;
		for(int i=0; i<100001; ++i){
			if(pos[i] != -1 && pos[i] < min ){
				min = pos[i];
			}
			if( pos[i] > max){
				max = pos[i];
			}
		}
		++min;
		++max;

		pw.println(min+" "+max);
		pw.close();
	}

	static class Parser{

		StringTokenizer st;
		BufferedReader br;

		public Parser(InputStream is){
			this.br = new BufferedReader( new InputStreamReader(is));

		}

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

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

		public String nextString(){
			return nextToken();
		}

		public int[] nextIntArray(int s){
			int[] a = new int[s];
			for(int i=0; i<s; ++i){
				a[i] = nextInt();
			}
			return a;
		}

		public int[][] nextIntTable(int r, int c){
			int[][] a = new int[r][c];
			for(int i=0; i<r; ++i){
				a[i] = nextIntArray(c);
			}
			return a;
		}

		private String nextToken() {
			if( st == null || ! st.hasMoreTokens() ){
				try{
					st = new StringTokenizer( br.readLine());
				}catch( Exception e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

	}
}


import java.util.Arrays;
import java.util.Scanner;

public class B {

    void run(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();
        int[] a = new int[n+1];
        for(int i=1;i<=n;i++)a[i]=sc.nextInt();
        int[] c = new int[100001];
        int num = 0;
        int ri = -1, rj = -1;
        int s = 1, t = 0;
        while(t<n){
            t++;
            if(c[a[t]]==0){
                num++;
            }
            c[a[t]]++;
            for(;k<=num;s++){
                if(ri==-1 || rj-ri+1>t-s+1){
                    ri = s; rj = t;
                }
                c[a[s]]--;
                if(c[a[s]]==0){
                    num--;
                }
            }
        }
        System.out.println(ri+" "+rj);
    }

    void debug(Object...o){
        System.out.println(Arrays.deepToString(o));
    }

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


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Sunits789
 */
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();
        int k=in.nextInt();
        int arr[]=new int[n];
        in.getArray(arr);
        int ansl=-1;
        int ansr=n;
        int occ[]=new int[100100];
        boolean f[]=new boolean[n];
        Arrays.fill(occ,0);
        Arrays.fill(f,true);
        int pk=0;
        for (int l=0,r=0;r<n&&l<n;){
            int num=arr[r];
            if(f[r]){
                f[r]=false;
                occ[num]++;
                if(occ[num]==1){
                    pk++;
                }
            }
            //System.out.println(l+" "+r+" "+pk+" "+k);
            if(pk<k){
                r++;
            }
            else if (pk==k){
                if((r-l)<=(ansr-ansl)){
                    ansl=l+1;
                    ansr=r+1;
                }
                num=arr[l];
                occ[num]--;
                if(occ[num]==0){
                    pk--;
                }
                l++;
            }
            else {
                num=arr[l];
                occ[num]--;
                if(occ[num]==0){
                    pk--;
                }
                l++;
            }
        }
        if(ansl==-1){
            ansr=-1;
        }
        out.println(ansl+" "+ansr);
    }
}

class InputReader{
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream){
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }
    public String next(){
        while (tokenizer == null||!tokenizer.hasMoreTokens()){
            try{
                tokenizer = new StringTokenizer(reader.readLine());
            }
            catch (IOException e){
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

    public void getArray(int arr[]){
        for(int i=0;i<arr.length;i++){
            arr[i]=nextInt();
        }
    }

    }


import java.util.*;
public class Main {

    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");
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;

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

class TaskB {
	public void solve(int testNumber, StreamInputReader in, PrintWriter out) {
        int N = in.readInt();
        int K = in.readInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++)
            A[i] = in.readInt();

        int num = 0;
        int left = 0;
        int right = 0;
        int[] seen = new int[100005];
        while(right < N && num < K) {
            if(seen[A[right]] == 0)
                num++;
            seen[A[right]]++;
            right++;
        }
        right--;

        if(num == K) {
            while(seen[A[left]] > 1) {
                seen[A[left]]--;
                left++;
            }

            out.print((left + 1) + " " + (right + 1));
            return;
        }
        out.print("-1 -1");
	}
}

class StreamInputReader extends InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar, numChars;

    public StreamInputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    }

abstract class InputReader {

    public abstract int read();

    public int readInt() {
        return Integer.parseInt(readString());
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class CF224B {

    public static void main(String[] args) throws Exception {
        new CF224B().solve();
    }

    private void solve() throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        final int MAX_A = 100000;
        int[] freq = new int[MAX_A+1];
        int numDistinct = 0;
        int r = -1;
        for (int i = 0; i < n; i++) {
            int t = a[i];
            freq[t]++;
            if (freq[t] == 1) {
                numDistinct++;
            }
            if (numDistinct == k) {
                r = i;
                break;
            }
        }
        if (r == -1) {
            System.out.println("-1 -1");
            return;
        }
        int l;
        for (l = 0; l < r; l++) {
            int t = a[l];
            freq[t]--;
            if (freq[t] == 0) {
                break;
            }
        }
        System.out.println((l+1) + " " + (r+1));
    }

}


import java.util.Scanner;
import java.util.TreeMap;

public class B {

    static Scanner in;

    static void put(TreeMap<Integer, Integer> m, int key) {
        if (m.containsKey(key)) {
            m.put(key, m.get(key) + 1);
        } else {
            m.put(key, 1);
        }
    }

    static void remove(TreeMap<Integer, Integer> m, int key) {
        if (!m.containsKey(key))
            return;
        m.put(key, m.get(key) - 1);
        if (m.get(key) == 0) {
            m.remove(key);
        }
    }

    public static void main(String[] args) {
        in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int i = 0;
        while (i + 1 < n && a[i + 1] == a[0]) {
            i++;
        }
        int left = i;
        TreeMap<Integer, Integer> used = new TreeMap<Integer, Integer>();
        for (; i < n; i++) {
            put(used, a[i]);
            if (used.size() == k) {
                while (used.get(a[left]) > 1) {
                    remove(used, a[left]);
                    left++;
                }
                System.out.println(left + 1 + " " + (i + 1));
                return;
            }
        }
        System.out.println("-1 -1");
    }

}


import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Code implements Runnable {

    public static void main(String[] args) throws IOException {
        new Thread(new Code()).start();
    }

    private void solve() throws IOException {
        taskB();
    }

    private void taskB() throws IOException {
        int n = nextInt(), k = nextInt();
        int[] arr = new int[n];

        for(int i = 0; i < n; ++i)  arr[i] = nextInt();

        int i = 0;
        while(i < n - 1 && arr[i] == arr[i + 1])    ++i;

        if(k == 1)
            writer.println(1 + " " + 1);
        else if(k == 2 && i == n - 2)
            writer.println(n - 1 + " " + n);
        else {
            if(i == n - 1)
                writer.println(-1 + " " + -1);
            else {
                int l = i;
                Map<Integer, Integer> set = new HashMap<Integer, Integer>(n);
                while(i < n && set.size() < k) {
                    if(set.containsKey(arr[i])) set.put(arr[i], set.get(arr[i]) + 1);
                    else    set.put(arr[i], 1);
                    i += 1;
                }
                if(set.size() < k)  writer.println(-1 + " " + -1);
                else {
                    while(l < i && i - l > k && set.get(arr[l]) > 1) {
                        set.put(arr[l], set.get(arr[l]) - 1);
                        l += 1;
                    }
                    writer.println((l + 1) + " " + i);
                }
            }
        }
    }

    private class Pair<E extends Comparable, V extends Comparable> implements Comparable<Pair<E, V>> {
        public Pair(E first, V second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair<E, V> obj) {
            if(first.equals(obj.first))  return second.compareTo(obj.second);
            return first.compareTo(obj.first);
        }

        @Override
        public boolean equals(Object obj) {
            Pair other = (Pair)obj;
            return first.equals(other.first) && second.equals(other.second);
        }

        public E first;
        public V second;
    }

    @Override
    public void run() {
        try {
            if(in.equals(""))   reader = new BufferedReader(new InputStreamReader(System.in));
            else    reader = new BufferedReader(new FileReader(in));

            if(out.equals(""))  writer = new PrintWriter(new OutputStreamWriter(System.out));
            else    writer = new PrintWriter(new FileWriter(out));
            solve();
        } catch(IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
                writer.close();
            } catch(IOException e) {
                e.printStackTrace();
            }
        }
    }

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

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

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

    private float nextFloat() throws IOException {
        return Float.parseFloat(nextToken());
    }

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

    private String in = "", out = "";
    private BufferedReader reader;
    private PrintWriter writer;
    private StringTokenizer st;
}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;

public class B
{
	BufferedReader in;
	PrintStream out;
	StringTokenizer tok;
	public B() throws NumberFormatException, IOException
	{
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new FileReader("in.txt"));
		out = System.out;
		run();
	}
	void run() throws NumberFormatException, IOException
	{
		int n = nextInt();
		int k = nextInt();
		int[] num = new int[n];
		for(int i = 0; i < n; i++)
			num[i] = nextInt();
		int[] cant = new int[100001];
		int cnt = 0;
		int r = 0;
		for(; r < n; r++)
		{
			if(cant[num[r]]==0)cnt++;
			cant[num[r]]++;
			if(cnt==k) break;
		}
		if(cnt<k)
		{
			out.println("-1 -1");
			return;
		}
		int l = 0;
		for(; l < r; l++)
		{
			cant[num[l]]--;
			if(cant[num[l]]==0)cnt--;
			if(cnt<k) break;
		}
		out.println((l+1)+" "+(r+1));
	}
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		new B();
	}
	String nextToken() throws IOException
	{
		if(tok ==null || !tok.hasMoreTokens()) tok = new StringTokenizer(in.readLine());
		return tok.nextToken();
	}
	int nextInt() throws NumberFormatException, IOException
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws NumberFormatException, IOException
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws NumberFormatException, IOException
	{
		return Double.parseDouble(nextToken());
	}
}


import java.io.*;
import java.util.*;

public class C138B
{

    private static StringTokenizer st;

    public static void nextLine(BufferedReader br) throws IOException
    {
        st = new StringTokenizer(br.readLine());
    }

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

    public static String next()
    {
        return st.nextToken();
    }

    public static long nextLong()
    {
        return Long.parseLong(st.nextToken());
    }
    /**
     * @param args
     */
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        nextLine(br);
        int n = nextInt();
        int k = nextInt();
        int[] a = new int[n];
        nextLine(br);
        for (int i = 0; i < n; i++) a[i] = nextInt();

        int bp = 0, fp = 0, count = 0;
        boolean good = false;
        int[] mark = new int[100001];
        for (fp = 0; fp < n; fp++)
        {
            if (mark[a[fp]] == 0)
            {
                count++;
            }
            mark[a[fp]]++;
            if (count == k)
            {
                good = true;
                break;
            }
        }
        if (!good)
        {
            System.out.println("-1 -1");
            return;
        }
        for (bp = 0; bp < fp; bp++)
        {
            if (mark[a[bp]] > 1)
            {
                mark[a[bp]]--;
            }
            else break;
        }
        System.out.println((bp+1) + " " + (fp+1));
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class B {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt();
        if (k > n) {
            System.out.println(-1 + " " + -1);
            return;
        }
        int[] v = new int[100010];
        int cnt = 0;
        for (int i = 0; i < k; i++) {
            if (v[a[i]] == 0) {
                cnt++;
            }
            v[a[i]]++;

        }
        int i = k;
        while (cnt < k && i < n) {
            if (v[a[i]] == 0) {
                cnt++;
            }
            v[a[i]]++;
            i++;
        }
        if (cnt != k) {
            System.out.println(-1 + " " + -1);
        } else {
            int st = 0;
            while (st < n && st < i && v[a[st]] > 1) {
                v[a[st]]--;
                st++;
            }
            System.out.println((st+1) + " " + (i));
        }
    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer st;

        public InputReader() throws IOException {
            in = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer(in.readLine());
        }

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

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

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

}


import java.util.Scanner;

public class BB {
public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int a[]=new int[n+1];
    boolean used[]=new boolean[100009];
    for (int i = 1; i <=n; i++) {
        a[i]=sc.nextInt();
    }
    int cnt=0;
    int id=0;
    for (int i = 1; i <=n; i++) {
        if(!used[a[i]]){
            cnt++;
        used[a[i]]=true;
        }
        if(cnt==k){
            id=i;
            break;
        }
    }
    boolean x[]=new boolean[100005];
    int y=0;
    int id1=0;
    if(id==0){
        System.out.println(-1+" "+-1);
            return;
    }
    for (int i =id; i >=1; i--) {
        if(!x[a[i]]){
            y++;
            x[a[i]]=true;
        }
        if(y==k){
            id1=i;
            break;
        }
    }
    System.out.println(id1+" "+id);
}
}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.HashMap;

public class B {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
//		System.setIn(new FileInputStream("b.in"));
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		String[] parts = bf.readLine().trim().split("[ ]+");
		int N = Integer.parseInt(parts[0]);
		int K = Integer.parseInt(parts[1]);

		int[] nums = new int[N];
		int idx = 0;

		String line = bf.readLine();
		for(int i = 0; i < line.length(); i++) {
			char c = line.charAt(i);
			if(c == ' ') idx++;
			else {
				int d = c - '0';
				nums[idx] = 10 * nums[idx] + d;
			}
		}

		int from = -1, to = -1;
		HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			Integer q = count.get(nums[i]);

			if(q == null) count.put(nums[i], 1);
			else count.put(nums[i], q + 1);

			if(count.size() == K) {
				to = i;
				break;
			}
		}

		if(count.size() < K) {
			System.out.println("-1 -1");
			return;
		}

		for(from = 0; from <= to; from++) {
			Integer q = count.get(nums[from]);

			if(q == 1) count.remove(nums[from]);
			else count.put(nums[from], q - 1);

			if(count.size() < K) break;
		}

		System.out.println((from + 1) + " " + (to + 1));

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class BT {

    static BufferedReader in = new BufferedReader(new InputStreamReader(
            System.in));
    static StringTokenizer str;
    static String SK;

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

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

    public static void main(String[] args) throws IOException {
        int n, k;
        n = nextInt();
        k = nextInt();
        HashSet<Integer> hs = new HashSet<Integer>();
        HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();

        int[] ar = new int[n];
        int ii = 0, jj = -1;
        for (int i = 0; i < n; i++) {
            ar[i] = nextInt();

            Integer iii = hm.get(ar[i]);
            if(iii!=null)
            hm.put(ar[i], ++iii); else hm.put(ar[i], 1);
            hs.add(ar[i]);
            if (hs.size() == k) {
                jj = i;
                break;
            }
        }
        if (jj == -1) {
            System.out.println(-1 + " " + (-1));
            System.exit(0);
        }
        for (int i = 0; i < ar.length; i++) {
            Integer iii = hm.get(ar[i]);
            if (iii != null && iii - 1 > 0) {
                hm.put(ar[i], --iii);
                ii++;
            } else {
                break;
            }
        }
        System.out.println((ii+1) + " " + (jj+1));

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.Vector;

public class B {
	static Vector<Integer> primes;

	public static void main(String[] args) throws IOException {
		InputReader myScanner = new InputReader();
		int n = myScanner.nextInt(), k = myScanner.nextInt();
		myScanner.hasNext();
		int all[] = new int[n];
		boolean numbers[] = new boolean[100100];
		int diff[] = new int[n];
		all[0] = myScanner.nextInt();
		diff[0] = 1;
		numbers[all[0]] = true;
		int r = -1;
		if (k == 1)
			r = 1;
		for (int i = 1; i < all.length; i++) {
			all[i] = myScanner.nextInt();
			diff[i] = diff[i - 1];
			if (!numbers[all[i]]) {
				if (r == -1 && diff[i] + 1 == k)
					r = i + 1;
				numbers[all[i]] = true;
				diff[i]++;
			}
		}
		if (r == -1)
			System.out.println(-1 + " " + -1);
		else {
			numbers = new boolean[100010];
			int l = 0, cnt = 1;
			numbers[all[r - 1]] = true;
			if (k == 1)
				System.out.println(1 + " " + 1);
			else {
				for (int i = r - 2; i >= 0; i--) {
					if (!numbers[all[i]]) {
						numbers[all[i]] = true;
						cnt++;
					}
					if (cnt == k) {
						l = i + 1;
						break;
					}
				}

				System.out.println(l + " " + r);
			}
		}
	}

	static class InputReader {
		BufferedReader buff;
		StringTokenizer tok;
		String cur;

		public InputReader() throws IOException {
			buff = new BufferedReader(new InputStreamReader(System.in));
			tok = new StringTokenizer(cur = buff.readLine());
		}

		public boolean hasNext() throws IOException {
			if (!tok.hasMoreElements()) {
				cur = buff.readLine();
				if (cur == null)
					return false;
				tok = new StringTokenizer(cur);
			}
			return true;
		}

		public String next() throws IOException {
			while (!tok.hasMoreElements())
				tok = new StringTokenizer(cur = buff.readLine());

			return tok.nextToken();
		}

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

		public long nextLong() throws NumberFormatException, IOException {
			while (!tok.hasMoreElements())
				tok = new StringTokenizer(cur = buff.readLine());

			return Long.parseLong(next());
		}
	}

}


import java.io.DataInputStream;
import java.io.InputStream;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class B {

    public static void main(String[] args) throws Exception {
        Parserdoubt2333 s = new Parserdoubt2333(System.in);

        int n = s.nextInt();
        int k = s.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = s.nextInt();

        }

        TreeMap<Integer, Integer> tree = new TreeMap<Integer,Integer>();

        int left = 0;
        int right = 0;

        for (right = 0; right < a.length; right++) {
            if(tree.containsKey(a[right]))
                tree.put(a[right], tree.get(a[right]) + 1);
            else
                tree.put(a[right],1);
            if(tree.size() == k)
                break;
        }

        if(tree.size() < k){
            System.out.println("-1 -1");
            return ;
        }
//      System.out.println(right);
        for (left = 0; left < a.length; left++) {
            int val = tree.get(a[left]);
            val--;
            if(val > 0)
                tree.put(a[left],val);
            if(val == 0)
                break;

        }
        left++;
        right++;
        System.out.println(left + " "+right);
    }

}

class Parserdoubt2333
{
   final private int BUFFER_SIZE = 1 << 18;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public Parserdoubt2333(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }
   public String nextString() throws Exception
   {
       StringBuffer sb=new StringBuffer("");
       byte c = read();
       while (c <= ' ') c = read();
       do
       {
           sb.append((char)c);
           c=read();
       }while(c>' ');
       return sb.toString();
   }
   public char nextChar() throws Exception
   {
       byte c=read();
       while(c<=' ') c= read();
       return (char)c;
   }
   public int nextInt() throws Exception
   {
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   public long nextLong() throws Exception
   {
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
          ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;
   }
   private void fillBuffer() throws Exception
   {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
   }

   private byte read() throws Exception
   {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
   }
}


import java.util.*;

public class TaskB {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int k = s.nextInt();
        int[] nums = new int[100000 + 10];

        int first = -1, last = -1;
        Set<Integer> dif = new TreeSet<Integer>();

        s.nextLine();
        for (int i = 0; i < n; i++) {
            nums[i] = s.nextInt();
            dif.add(nums[i]);
            if (dif.size() == k) {
                last = i;
                break;
            }
        }

        dif.clear();

        for (int i = last; i >= 0; i--) {
            dif.add(nums[i]);
            if (dif.size() == k) {
                first = i;
                break;
            }
        }

        if (last == -1)
            System.out.print("-1 -1");
        else
            System.out.print(Integer.toString(first + 1) + " "  + Integer.toString(last + 1));
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class B {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		Scanner scan = new Scanner(System.in);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n  = Integer.parseInt(st.nextToken());
		int k  = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		int[] a = new int[n];
		for(int i = 0 ; i  <n;i++)
			a[i] = Integer.parseInt(st.nextToken());

		int l = 0, r = 0;
		int[] t = new int[100001];
		int kk = 0;
		int min = 1 << 25 , ll =-1 , rr = -1;
		while(r < n)
		{
			int x = a[r++];
			t[x]++;
			if(t[x] == 1)
				kk++;
			while(r < n && kk < k)
			{
				x = a[r++];
				t[x]++;
				if(t[x] == 1)
					kk++;
			}
			while(kk == k && l < r)
			{
				x = a[l];
				if(t[x] == 1)
					break;
				t[x]--;
				l++;
			}
			if(kk == k)
			{
				int m = r-l+1;
				if(m < min)
				{
					ll = l+1;
					rr = r;
					min = m;
				}
			}
		}
		System.out.println(ll +" "+rr);
	}

}


import java.util.*;
public class b {
public static void main(String[] args)
{
    Scanner input = new Scanner(System.in);
    int n = input.nextInt(), k = input.nextInt();
    int[] data = new int[n];
    for(int i = 0; i<n; i++)
        data[i] = input.nextInt();
    int[] freq = new int[100001];
    int count = 0;
    for(int i = 0; i<n; i++)
    {
        if(freq[data[i]] == 0)
            count++;
        freq[data[i]]++;
    }
    if(count<k)
        System.out.println("-1 -1");

    else
    {
        int start = 0;
        for(int i = 0; i<n; i++)
        {
            //System.out.println(i + " " + count + " " + freq[data[i]]);
            if(count > k)
            {
                freq[data[i]]--;
                if(freq[data[i]] == 0)
                    count--;
            }
            else
            {
                if(freq[data[i]] > 1)
                {
                    freq[data[i]]--;
                }
                else
                {
                    start = i;
                    break;
                }
            }
        }
        int end = n-1;
        for(int i = n-1; i>=0; i--)
        {
            if(freq[data[i]] == 1)
            {
                end = i;
                break;
            }
            else
                freq[data[i]]--;

        }
        start++;
        end++;
        if(start<= end)
        System.out.println(start + " " + end);
        else
            System.out.println(-1 + " " + -1);
    }
}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Tibor
 */
public class test{

//   static java.io.InputStreamReader converter = new java.io.InputStreamReader(System.in);
//    static java.io.BufferedReader in = new java.io.BufferedReader(converter);
//
//    public static String readLine() {
//        String s = "";
//        try {
//
//            s = in.readLine();
//        } catch (Exception e) {
//            System.out.println("Error! Exception: " + e);
//        }
//        return s;
//    }
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(
            new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);

//    static {
//        in.ordinaryChars('-', '-');
//        in.ordinaryChars('+', '+');
//        in.wordChars('-', '-');
//        in.wordChars('+', '+');
//    }
    static int nextInt() {
        try {
            in.nextToken();
        } catch (IOException ex) {
            Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
        }
        return (int) in.nval;
    }

    static String nextString() {
        try {
            in.nextToken();
        } catch (IOException ex) {
            Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex);
        }
        return in.sval;
    }

    public static void main(String args[]) throws Exception {
        int n = nextInt();
        long k = nextInt();
        long a[] = new long[n + 1];
        Map<Long, Long> drb = new HashMap<Long, Long>();
        int elso = 1;
        long sk = 0;
        long sm = 0;
        long minjo = Long.MAX_VALUE;
        long minjoh = Long.MAX_VALUE;
        Vector<long[]> ret = new Vector<long[]>();
        for (int i = 1; i <= n; i++) {
            a[i] = nextInt();
            if (/*a[i - 1] <= a[i]*/true) {
                sm += a[i];
                if (drb.containsKey(a[i])) {
                    drb.put(a[i], drb.get(a[i]) + 1);
                } else {
                    drb.put(a[i], (long) 1);
                    sk++;
                }
                while (sk > k || drb.get(a[elso]) > 1) {
                    long s = drb.get(a[elso]);
                    if (s == 1) {
                        drb.remove(a[elso]);
                        sk--;
                    } else {
                        drb.put(a[elso], s - 1);
                    }
                    sm -= a[elso];
                    elso++;
                }
                if (sk == k) {
                    if (minjo > sm) {
                        minjo = sm;
                        ret.clear();
                        minjoh = i - elso;
                    }
                    if (minjo == sm) {
                        if (minjoh > i - elso) {
                            ret.clear();
                            minjoh = i - elso;
                        }
                        ret.add(new long[]{elso, i});
                    }
                }
            } else {
                elso = i;
                drb.clear();
                drb.put(a[i], (long) 1);
                sk = 1;
                sm = a[i];
                if (k == 1) {
                    if (minjo > sm) {
                        minjo = sm;
                        ret.clear();
                    }
                    if (minjo == sm) {
                        ret.add(new long[]{elso, i});
                    }
                }
            }
        }

        for (long[] r : ret) {
            System.out.print(r[0] + " ");
            System.out.print(r[1] + " ");
            break;
        }
        if (ret.size() == 0) {
            System.out.print(-1 + " ");
            System.out.print(-1 + " ");
        }
    }
}


import java.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{

	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	//
    //	static long sum=0;
	// int a,b,c;
	// 1000000007 (10^9+7)
	//static int mod = 1000000007;
    //static int dx[]={1,-1,0,0};
	//static int dy[]={0,0,1,-1};
    //static long H,L;

public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	Reader sc = new Reader(System.in);
  // while( ){
	   int  n=sc.nextInt(),m=sc.nextInt(),a[]=new int[n];
	   int b[]=new int[100000+1], r=n+1;
	for(int i=0;i<n;i++)a[i]=sc.nextInt();
		// db(a);
		int s=0,t=-1, sum=0;
		int as=0,at=0;
	for(;;){
		while(t<n-1 && sum<m){
			t++;
			if( b[ a[t] ]<1 ){sum++; }
			 b[a[t]]++;
	}
		db(s,t,sum);
		if( sum<m )break;
		as=s;at=t;
		r=min(r,t-s+1);
		if( b[ a[s] ]==1 ){sum--; }
	//	if(t==n-1)break;
		 b[a[s]]--;
		 s++;
	}

	if( n<r )System.out.println("-1 -1");
	else System.out.println(as+1+" "+(at+1));
}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}

}

/*
class P implements Comparable<P>{
//	implements Comparable<P>

	int x;
	boolean b;
	P(int x,boolean b){
		this.x=x;
		this.b=b;
	}

	   public int compareTo(P y){

		  return  x-y.x;

		   }

}
//*/
class Reader
{
	private BufferedReader x;
	private StringTokenizer st;

	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}


import java.io.*;
import java.util.*;

public class Array224B {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		int[] array = new int[n];
		int[] visited = new int[100002];
		st = new StringTokenizer(f.readLine());
		for(int i=0;i<n;i++){
			array[i] = Integer.parseInt(st.nextToken());
		}
		int count = 0;
		int begin = array[0];
		while(count<n && array[count] == begin){
			count++;
		}
		count--;
		int kcount = 1;
		visited[array[count]]++;
		int bindex = count;
		boolean good=true;
		count++;
		while(kcount<k){
			if(count==n){
				System.out.println("-1 -1");
				good=false;
				break;
			}
			if(visited[array[count]]==0){
				kcount++;
			}
			visited[array[count]]++;
			count++;
		}
		if(good&&k!=1){
		for(int i=bindex;i<count;i++){
			if(visited[array[i]]==1){
				break;
			}
			bindex++;
			visited[array[i]]--;
		}
		for(int i=count-1;i>bindex;i--){
			if(visited[array[i]]==1){
				break;
			}
			count--;
			visited[array[i]]--;
		}
		}
		if(k==1){
			System.out.println("1 1");
		}
		else if(good){
			System.out.println(bindex+1+" "+count);
		}
	}
}


import java.io.*;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;

public class Array implements Runnable {

    void solve() throws IOException {
        int n = readInt();
        int k = readInt();
        int a[] = new int[n];
        int startIdx = 0;
        int endIdx = -1;
        Map<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i = 0; i < n; i ++) {
            a[i] = readInt();
            if(map.containsKey(a[i]))
                map.put(a[i], map.get(a[i]) + 1);
            else
                map.put(a[i], 1);
            if(map.size() == k && endIdx == -1) {
                endIdx = i;
                break;
            }
        }

        if(endIdx != -1) {
            while(startIdx < n && map.get(a[startIdx])>1) {
                map.put(a[startIdx], map.get(a[startIdx]) - 1);
                startIdx ++;
            }
            startIdx ++;
            endIdx   ++;
        } else
            startIdx = -1;

        out.println((startIdx)+" "+(endIdx));

    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

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

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
            if (System.getProperty("ONLINE_JUDGE") != null) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader("/Users/shenchen/input.txt"));
                out = new PrintWriter("/Users/shenchen/output.txt");
            }
            Locale.setDefault(Locale.US);
            solve();
            in.close();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class CF_1029E_Tree_with_Small_Distances {
	static ArrayList<Integer> adj[];
	static int dist[];
	static boolean visitParent[];
	static int ans=0;
 public static void main(String[] args) throws IOException {
	Scanner sc = new Scanner(System.in);
	int n  =sc.nextInt();
	adj=new ArrayList[n+1];
	dist = new int[n+1];
	visitParent = new boolean[n+1];
	for(int i=0;i<=n;i++) adj[i]=new ArrayList<Integer>();
	int max=0;
	//first contribution
	for(int i=1;i<n;i++){
		int u = sc.nextInt(),v=sc.nextInt();
		adj[u].add(v);
		adj[v].add(u);
	}
	dist[1]=0;
	dfs(1,1);
 System.out.println(ans);

 }
private static void dfs(int i , int j) {
	// TODO Auto-generated method stub
	boolean f = false;
	for(int k=0;k<adj[i].size();k++){
		int x = adj[i].get(k);
		if(x!=j){
			dist[x]=dist[i]+1;
			dfs(x,i);
			if(visitParent[x])
				f=true;
		}
	}
	//System.out.println(Arrays.toString(dist));
	if(dist[i]>2&&!visitParent[j]&&!f&&!visitParent[i]){
		visitParent[j]=true;
		ans++;
		for(int v=0;v<adj[i].size();v++){

		}
	}

}
static class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

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

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public boolean ready() throws IOException {return br.ready(); }

}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF1197B {
    public static void main(String[] args) {
        FastReader input = new FastReader();
        int n = input.nextInt();
        int[] arr = new int[n];
        int max = 0;
        int maxIndex = 0;
        for(int i = 0;i < n;i++){
            arr[i] = input.nextInt();
            if(arr[i] > max){
                max = arr[i];
                maxIndex = i;
            }
        }
        int j = maxIndex - 1;
        int k = maxIndex + 1;
        while (j >= 0 && k < n){
            if(arr[j] > arr[k]){
                if(arr[j] < max){
                    max = arr[j];
                    j--;
                }
                else {
                    System.out.println("NO");
                    return;
                }
            }
            else{
                if(arr[k] < max){
                    max = arr[k];
                    k++;
                }
                else{
                    System.out.println("NO");
                    return;
                }
            }
        }
        if(j >= 0){
            while (j >= 0){
                if(arr[j] < max){
                    max = arr[j];
                    j--;
                }
                else{
                    System.out.println("NO");
                    return;
                }
            }
        }
        if(k < n){
            while (k < n){
                if(arr[k] < max){
                    max = arr[k];
                    k++;
                }
                else{
                    System.out.println("NO");
                    return;
                }
            }
        }
        if(j == -1 && k == n){
            System.out.println("YES");
        }
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.Scanner;

public class pillar {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[200005];
		for (int i=1;i<=n;i++)
		a[i]=sc.nextInt();
		for (int i=2;i<n;i++)
		if (a[i-1]>a[i]&&a[i]<a[i+1]) {
			System.out.println("NO");
			return;
		}
		System.out.println("YES");
	}
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Solution{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i] = Integer.parseInt(st.nextToken());
        int ind = 0;
        for(int i=0;i<n;i++){
            if(a[i]==n){
                ind = i;
                break;
            }
        }
        boolean ok = true;
        for(int i=ind+1;i<n;i++) if(a[i]>a[i-1]) ok = false;
        for(int i=ind-1;i>=0;i--) if(a[i]>a[i+1]) ok = false;
        if(ok) System.out.println("YES");
        else System.out.println("NO");

    }
}


import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.io.ObjectInputStream.GetField;
import java.security.KeyStore.Entry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

import javax.swing.JLabel;

public class codeforcesreturn {
	static class edge {
		int u;
		int v;

		public edge(int u, int v) {
			this.u = u;
			this.v = v;
		}

	}

	static ArrayList<Integer>[] adjlist;
	static int[][] adjmatrix;
	static int[][] adjmatrix2;
	static boolean[] vis;
	static boolean[] intialvis;
	static boolean[] vis2;
	static int[] counter;
	static int V, E;
	static Stack<Integer> st;
	static ArrayList<Integer> arrylist;
	static boolean flag;
	static int[] dx = new int[] { 1, -1, 0, 0 };
	static int[] dy = new int[] { 0, 0, 1, -1 };
	static int[] Arr;
	static PrintWriter pw;
	static boolean ans = true;;

	public static long gcd(long u, long v) {
		if (u == 0)
			return v;
		return gcd(v % u, u);
	}

	public static void bib(int u) {

		vis[u] = true;
		for (int v : adjlist[u]) {
			if (!vis[v]) {
				counter[v] = 1 ^ counter[u];
				bib(v);
			} else if (counter[v] != (1 ^ counter[u]))
				ans = false;

		}
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		// FileWriter f = new FileWriter("C:\\Users\\Hp\\Desktop\\out.txt");
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int sum = n;

		for (long i = 0; i < 1e5; i++) {
			if (i * (i + 1) / 2 - (n - i) == k) {
				System.out.println(n - i);
				break;
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

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

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}


import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt(), k = sc.nextInt();
        long rhs = 2l * (n + k);
        for (int x = 1; ; x++) {
            long lhs = 1l * x * x + 3l * x;
            if (rhs == lhs) {
                out.println(n - x);
                break;
            }
        }
        out.flush();
        out.close();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class Task {
        public void solve(int testNumber, InputReader sc, PrintWriter out) {
            double n=sc.nextInt();
            double k=sc.nextInt();

            double ans=n-(-1.5+Math.sqrt(9.0/4+2*(n+k)));
            out.printf("%.0f\n",ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}


import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class B {
    static long n, k;

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = in.nextLong();
        k = in.nextLong();
        long ans = n - TernarySearch(0, n);
        pw.println(ans);
        pw.close();
    }

    static long cal(long m) {
        long x = (m * (m + 1)) / 2;
        long y = x - (n - m);
        return abs(k - y);
    }

    static long TernarySearch(long l, long r) {
        long m1, m2;
        while (r - l > 5) {
            m1 = (2 * l + r) / 3;
            m2 = (l + 2 * r) / 3;
            if (cal(m1) > cal(m2)) l = m1;
            else r = m2;
        }
        long min = cal(l), i = l;
        for (; l <= r; l++) {
            long t = cal(l);
            if (t < min) {
                min = t;
                i = l;
            }
        }
        return i;
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }
}


//never leave a uncompleted question in this file, always remove the code after submitting it.

import java.io.*;
import java.util.*;

public class run{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        long k = in.nextInt();
        long ans = (-3 + (long)Math.sqrt(9+8*(n+k)))/2;
        System.out.println(n-ans);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
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);
        BSportMafia solver = new BSportMafia();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSportMafia {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            long k = in.nextInt();
            long d = 9 + 4 * (2 * n + 2 * k);
            double smh = Math.sqrt(d);
            double ans = (-3 + smh) / 2;
            out.println(n - (int) ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
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);
        BSportMafia solver = new BSportMafia();
        solver.solve(1, in, out);
        out.close();
    }

    static class BSportMafia {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();
            long b = 2 * n + 3;
            long c = n * n - 2 * k + n;
            long d = b * b - 4 * c;
            long val = (b - (long) Math.sqrt(d)) / 2;

            out.println(val);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class CF1195B {

    private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
    private static StringTokenizer st;

    public static void main(String[] args) throws Exception {
        st = new StringTokenizer(reader.readLine());
        long n = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        long put = (-3 + (long)Math.sqrt((long)9 + 8 * k + 8 * n)) / 2;
        long eat = n - put;
        writer.write(Long.toString(eat));
        writer.newLine();
        writer.flush();
    }

}


import java.util.*;
import java.io.*;
public class cf5722{
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		long n=Long.parseLong(st.nextToken());
		long k=Long.parseLong(st.nextToken());

		long ans=((-3-(long)Math.sqrt(9+4*(1*2*(n+k))))/2);
		long ans1=((-3+(long)Math.sqrt(9+4*(1*2*(n+k))))/2);
		if(ans>0)
			System.out.println(n-ans);
		else{
			System.out.println(n-ans1);
		}

	}
}


import java.util.*;
import java.lang.Math;

public class Main{

	public static void main(String[] args){
		Scanner ak=new Scanner(System.in);
		long n,k,x;
		n=ak.nextLong();
		k=ak.nextLong();
		x=(long)((-3+Math.sqrt(9+8*(n+k)))/2);
		System.out.println(n-x);
	}
}


import java.util.*;
import java.io.*;

public class candies {
	public void run() throws Exception {
		Scanner file = new Scanner(System.in);
		int actions = file.nextInt();
		int left = file.nextInt();
		int start = 0;
		int c = 1;
		while (true) {
			start += c;
			if (c + (start - left) == actions) break;
			c++;
		}
		System.out.println(start - left);
	}

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

}