Problem: You are given n pairs of integers (a_1, b_1), (a_2, b_2), …, (a_n, b_n). All of the integers in the pairs are distinct and are in the range from 1 to 2 ⋅ n inclusive.

Let's call a sequence of integers x_1, x_2, …, x_{2k} good if either 

  * x_1 < x_2 > x_3 < … < x_{2k-2} > x_{2k-1} < x_{2k}, or 
  * x_1 > x_2 < x_3 > … > x_{2k-2} < x_{2k-1} > x_{2k}. 



You need to choose a subset of distinct indices i_1, i_2, …, i_t and their order in a way that if you write down all numbers from the pairs in a single sequence (the sequence would be a_{i_1}, b_{i_1}, a_{i_2}, b_{i_2}, …, a_{i_t}, b_{i_t}), this sequence is good.

What is the largest subset of indices you can choose? You also need to construct the corresponding index sequence i_1, i_2, …, i_t.

Input

The first line contains single integer n (2 ≤ n ≤ 3 ⋅ 10^5) — the number of pairs.

Each of the next n lines contain two numbers — a_i and b_i (1 ≤ a_i, b_i ≤ 2 ⋅ n) — the elements of the pairs.

It is guaranteed that all integers in the pairs are distinct, that is, every integer from 1 to 2 ⋅ n is mentioned exactly once.

Output

In the first line print a single integer t — the number of pairs in the answer.

Then print t distinct integers i_1, i_2, …, i_t — the indexes of pairs in the corresponding order.

Examples

Input


5
1 7
6 4
2 10
9 8
3 5


Output


3
1 5 3


Input


3
5 4
3 2
6 1


Output


3
3 2 1

Note

The final sequence in the first example is 1 < 7 > 3 < 5 > 2 < 10.

The final sequence in the second example is 6 > 1 < 3 > 2 < 5 > 4.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.Reader;
import java.util.Comparator;
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;
        MyInput in = new MyInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DDirtyDeedsDoneDirtCheap solver = new DDirtyDeedsDoneDirtCheap();
        solver.solve(1, in, out);
        out.close();
    }

    static class DDirtyDeedsDoneDirtCheap {
        public void solve(int testNumber, MyInput in, PrintWriter out) {
            int n = in.nextInt();
            int[][] ab = in.nextIntArray2DWithIndex(n, 2);
            for (int[] x : ab) {
                x[0]--;
                x[1]--;
            }
            int[] ans1 = solve(ab);
            for (int[] x : ab) {
                x[0] = 2 * n - 1 - x[0];
                x[1] = 2 * n - 1 - x[1];
            }
            int[] ans2 = solve(ab);
            int[] ans = ans1.length > ans2.length ? ans1 : ans2;
            out.println(ans.length);
            printList(out, ans);
        }

        int[] solve(int[][] ab) {
            Arrays.sort(ab, Comparator.comparingInt(x -> x[1]));
            RMQInt seg = new RMQInt(0);
            seg.build(2 * ab.length);
            int[] next = new int[2 * ab.length];
            int[] index = new int[2 * ab.length];
            Arrays.fill(next, -1);
            Arrays.fill(index, -1);
            int best = 0;
            int root = -1;
            for (int[] x : ab) {
                if (x[0] >= x[1]) continue;
                index[x[0]] = index[x[1]] = x[2];
                int val = -seg.Query(0, x[1] + 1);
                if (val != 0) {
                    next[x[0]] = seg.QueryIndex(0, x[1]);
                }
                if (best < val + 1) {
                    best = val + 1;
                    root = x[0];
                }
//            dump(x[0], x[1], val, seg.QueryIndex(0, x[1]));
                seg.Update(-(val + 1), x[0]);
            }
            int[] ans = new int[best];
            for (int i = 0; root != -1; i++) {
                ans[i] = index[root] + 1;
                root = next[root];
            }
            return ans;
        }

        static void printList(PrintWriter out, int[] p) {
            for (int i = 0; i < p.length; i++) {
                out.print(p[i] + (i == p.length - 1 ? "\n" : " "));
            }
        }

        class RMQInt {
            int n;
            int[] xs;
            int[] ys;
            final int INF;

            public RMQInt(int inf) {
                INF = inf;
            }

            int Min(int a, int b) {
                return a == INF ? b : (b == INF ? a : (a <= b ? a : b));
            }

            int minIndex(int a, int b) {
                return a == -1 ? b : (b == -1 ? a : (Min(xs[a], xs[b]) == xs[a] ? a : b));
            }

            public void build(int m) {
                for (n = 1; n < m; n <<= 1) ;
                xs = new int[2 * n];
                ys = new int[2 * n];
                for (int i = 0; i < 2 * n; i++) {
                    ys[i] = i;
                }
                clear();
            }

            public void clear() {
                Arrays.fill(xs, INF);
            }

            public void Update(int v, int idx) {
                xs[idx += n - 1] = v;
                while (idx > 0) {
                    idx = (idx - 1) / 2;
                    xs[idx] = Min(xs[idx * 2 + 1], xs[idx * 2 + 2]);
                    ys[idx] = ys[minIndex(idx * 2 + 1, idx * 2 + 2)];
                }
            }

            public int Query(int l, int r) {
                return Query(l, r, 0, n, 0);
            }

            int Query(int l, int r, int a, int b, int k) {
                if (l <= a && b <= r) return xs[k];
                if (b <= l || r <= a) return INF;
                final int m = (a + b) / 2;
                return Min(
                        Query(l, r, a, m, 2 * k + 1),
                        Query(l, r, m, b, 2 * k + 2));
            }

            public int QueryIndex(int l, int r) {
                return QueryIndex(l, r, 0, n, 0) - (n - 1);
            }

            int QueryIndex(int l, int r, int a, int b, int k) {
                if (l <= a && b <= r) return ys[k];
                if (b <= l || r <= a) return -1;
                final int m = (a + b) / 2;
                return minIndex(
                        QueryIndex(l, r, a, m, 2 * k + 1),
                        QueryIndex(l, r, m, b, 2 * k + 2));
            }

        }

    }

    static class MyInput {
        private final BufferedReader in;
        private static int pos;
        private static int readLen;
        private static final char[] buffer = new char[1024 * 8];
        private static char[] str = new char[500 * 8 * 2];
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];
        private static boolean[] isLineSep = new boolean[256];

        static {
            for (int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
            isLineSep['\r'] = isLineSep['\n'] = true;
        }

        public MyInput(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
        }

        public int read() {
            if (pos >= readLen) {
                pos = 0;
                try {
                    readLen = in.read(buffer);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (readLen <= 0) {
                    throw new MyInput.EndOfFileRuntimeException();
                }
            }
            return buffer[pos++];
        }

        public int nextInt() {
            int len = 0;
            str[len++] = nextChar();
            len = reads(len, isSpace);
            int i = 0;
            int ret = 0;
            if (str[0] == '-') {
                i = 1;
            }
            for (; i < len; i++) ret = ret * 10 + str[i] - '0';
            if (str[0] == '-') {
                ret = -ret;
            }
            return ret;
        }

        public char nextChar() {
            while (true) {
                final int c = read();
                if (!isSpace[c]) {
                    return (char) c;
                }
            }
        }

        int reads(int len, boolean[] accept) {
            try {
                while (true) {
                    final int c = read();
                    if (accept[c]) {
                        break;
                    }
                    if (str.length == len) {
                        char[] rep = new char[str.length * 3 / 2];
                        System.arraycopy(str, 0, rep, 0, str.length);
                        str = rep;
                    }
                    str[len++] = (char) c;
                }
            } catch (MyInput.EndOfFileRuntimeException e) {
            }
            return len;
        }

        public int[][] nextIntArray2DWithIndex(final int n, final int k) {
            final int[][] res = new int[n][k + 1];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < k; j++) {
                    res[i][j] = nextInt();
                }
                res[i][k] = i;
            }
            return res;
        }

        static class EndOfFileRuntimeException extends RuntimeException {
        }

    }
}