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 javax.swing.*;
import java.io.*;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Stream;

public class Main implements Runnable {
    static final int MOD = (int) 1e9 + 7;
    static final int MI = (int) 1e9;
    static final long ML = (long) 1e18;
    static final Reader in = new Reader();
    static final PrintWriter out = new PrintWriter(System.out);
    StringBuilder answer = new StringBuilder();

    public static void main(String[] args) {
        new Thread(null, new Main(), "persefone", 1 << 28).start();
    }

    @Override
    public void run() {
        solve();
        printf();
        flush();
    }

    void solve() {
        int n = in.nextInt();
        Trio[] trios = new Trio[n];
        for (int i = 0; i < n; i++) {
            trios[i] = new Trio(in.nextInt(), in.nextInt(), i);
        }


        int ans = 0;
        List<Integer> position = new ArrayList<>();
        {
            Trio[] up = Arrays.stream(trios).filter(t -> t.a < t.b).map(t -> new Trio(2 * n + 1 - t.a, 2 * n + 1 - t.b, t.index)).toArray(Trio[]::new);
            if (up.length > 0) {
                Arrays.sort(up, (t1, t2) -> t1.b - t2.b);
                int[] dp = new int[up.length];
                int cur = 0;
                Fenwick fenUp = new Fenwick(2 * n);
                for (int i = 0; i < up.length; i++) {
                    Trio t = up[i];
                    dp[i] = fenUp.get(t.a) + 1;
                    cur = Math.max(cur, dp[i]);
                    fenUp.update(t.b, dp[i]);
                }
                if (ans < cur) {
                    position.clear();
                    ans = cur;
                    for (int i = up.length - 1; i >= 0 && cur > 0; i--) {
                        if (dp[i] == cur) {
                            cur--;
                            position.add(up[i].index + 1);
                        }
                    }
                    Collections.reverse(position);
                }
            }
        }

        {
            Trio[] down = Arrays.stream(trios).filter(t -> t.a > t.b).toArray(Trio[]::new);
            int cur = 0;
            if (down.length > 0) {
                Arrays.sort(down, (t1, t2) -> t1.b - t2.b);
                int[] dp = new int[down.length];
                Fenwick fenDown = new Fenwick(2 * n);
                for (int i = 0; i < down.length; i++) {
                    Trio t = down[i];
                    dp[i] = fenDown.get(t.a) + 1;
                    cur = Math.max(ans, dp[i]);
                    fenDown.update(t.b, dp[i]);
                }
                if (ans < cur) {
                    position.clear();
                    ans = cur;
                    for (int i = down.length - 1; i >= 0 && cur > 0; i--) {
                        if (dp[i] == cur) {
                            cur--;
                            position.add(down[i].index + 1);
                        }
                    }
                    Collections.reverse(position);
                }
            }


        }

        printf(ans);
        printf(position);
    }

    static class Fenwick {
        private int n;
        private int[] max;

        public Fenwick(int n) {
            this.n = n + 10;
            this.max = new int[n + 10];
        }

        public void update(int i, int v) {
            for (; i < n; i += i & -i) {
                max[i] = Math.max(max[i], v);
            }
        }

        public int get(int i) {
            int ans = 0;
            for (; i > 0; i -= i & -i) {
                ans = Math.max(ans, max[i]);
            }
            return ans;
        }
    }

    static class Trio {
        private int a, b, index;

        public Trio(int a, int b, int index) {
            this.a = a;
            this.b = b;
            this.index = index;
        }

        @Override
        public String toString() {
            return "Trio{" +
                    "a=" + a +
                    ", b=" + b +
                    ", index=" + index +
                    '}';
        }
    }

    void printf() {
        out.print(answer);
    }

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

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

    void printf(Stream<?> str) {
        str.forEach(o -> add(o, " "));
        add("\n");
    }


    void printf(Object... obj) {
        printf(false, obj);
    }

    void printfWithDescription(Object... obj) {
        printf(true, obj);
    }


    private void printf(boolean b, Object... obj) {

        if (obj.length > 1) {
            for (int i = 0; i < obj.length; i++) {
                if (b) add(obj[i].getClass().getSimpleName(), " - ");
                if (obj[i] instanceof Collection<?>) {
                    printf((Collection<?>) obj[i]);
                } else if (obj[i] instanceof int[][]) {
                    printf((int[][]) obj[i]);
                } else if (obj[i] instanceof long[][]) {
                    printf((long[][]) obj[i]);
                } else if (obj[i] instanceof double[][]) {
                    printf((double[][]) obj[i]);
                } else printf(obj[i]);
            }
            return;
        }

        if (b) add(obj[0].getClass().getSimpleName(), " - ");
        printf(obj[0]);
    }

    void printf(Object o) {
        if (o instanceof int[])
            printf(Arrays.stream((int[]) o).boxed());
        else if (o instanceof char[])
            printf(new String((char[]) o));
        else if (o instanceof long[])
            printf(Arrays.stream((long[]) o).boxed());
        else if (o instanceof double[])
            printf(Arrays.stream((double[]) o).boxed());
        else if (o instanceof boolean[]) {
            for (boolean b : (boolean[]) o) add(b, " ");
            add("\n");
        } else
            add(o, "\n");
    }

    void printf(int[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(long[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(double[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(boolean[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(Collection<?> col) {
        printf(col.stream());
    }

    <T, K> void add(T t, K k) {
        if (t instanceof Collection<?>) {
            ((Collection<?>) t).forEach(i -> add(i, " "));
        } else if (t instanceof Object[]) {
            Arrays.stream((Object[]) t).forEach(i -> add(i, " "));
        } else
            add(t);
        add(k);
    }


    <T> void add(T t) {
        answer.append(t);
    }

    static class Reader {
        private BufferedReader br;
        private StringTokenizer st;

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

        Reader(String fileName) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(fileName));
        }

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

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

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

        int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = nextInt();
            return arr;
        }

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

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