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

public class stock_ak {

    static class Segment implements Comparable<Segment> {
        int left, right;
        int id;

        Segment(int left, int right, int id) {
            this.left = left;
            this.right = right;
            this.id = id;
        }

        @Override
        public int compareTo(Segment s) {
            return right - s.right;
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        Segment[] ss = new Segment[n];
        for (int i = 0; i < n; i++ ) {
            ss[i] = new Segment(in.nextInt(), in.nextInt(), i + 1);
        }
        Arrays.sort(ss);
        int currentRight = ss[0].left;
        ArrayList<Integer> ans = new ArrayList<>();
        for (Segment s : ss) {
            if (s.left >= currentRight) {
                currentRight = s.right;
                ans.add(s.id);
            }
        }
        out.println(ans.size());
        for (int id : ans) {
            out.print(id + " ");
        }
        out.println();
    }

    static MyScanner in;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        in = new MyScanner(new FileReader("stock.in"));
        out = new PrintWriter("stock.out");
        new stock_ak().solve();
        out.close();
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(Reader r) {
            this.br = new BufferedReader(r);
        }

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

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