Problem: We have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates.

For a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are parallel to the coordinate axes, that contains all the points in T. More formally, we define f(T) as follows:

* f(T) :=  (the number of integers i (1 \leq i \leq N) such that a \leq x_i \leq b and c \leq y_i \leq d, where a, b, c, and d are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the points in T)



Find the sum of f(T) over all non-empty subset T of S. Since it can be enormous, print the sum modulo 998244353.

Constraints

* 1 \leq N \leq 2 \times 10^5
* -10^9 \leq x_i, y_i \leq 10^9
* x_i \neq x_j (i \neq j)
* y_i \neq y_j (i \neq j)
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N
x_1 y_1
:
x_N y_N


Output

Print the sum of f(T) over all non-empty subset T of S, modulo 998244353.

Examples

Input

3
-1 3
2 1
3 -2


Output

13


Input

4
1 4
2 1
3 3
4 2


Output

34


Input

10
19 -11
-3 -12
5 3
3 -15
8 -14
-9 -20
10 -9
0 2
-7 17
6 -6


Output

7222

Solution (in JAVA):

Solution:
import java.io.*;
import java.nio.CharBuffer;
import java.util.*;

public class Main {

    private static final int MOD = 998244353;

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        ArrayList<Point> points = new ArrayList<>(n);
        for (int i = 0; i < n; ++i) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            points.add(new Point(x, y));
        }
        int[] leftTop = new int[n];
        int[] leftBottom = new int[n];
        int[] rightTop = new int[n];
        int[] rightBottom = new int[n];
        points.sort(Comparator.comparingInt(o -> -o.x));
        TreapWithRotation treap = new TreapWithRotation();
        for (int i = 0; i < n; ++i) {
            rightBottom[n - i - 1] = treap.getRank(points.get(i).y);
            rightTop[n - i - 1] = i - rightBottom[n - i - 1];
            treap.insert(points.get(i).y);
        }
        Collections.reverse(points);
        treap = new TreapWithRotation();
        for (int i = 0; i < n; ++i) {
            leftBottom[i] = treap.getRank(points.get(i).y);
            leftTop[i] = i - leftBottom[i];
//            writer.println(leftTop[i] + " " + leftBottom[i] + " " + rightTop[i] + " " + rightBottom[i]);
//            writer.flush();
            treap.insert(points.get(i).y);
        }
        long[] power2 = new long[n + 1];
        power2[0] = 1;
        for (int i = 1; i <= n; ++i)
            power2[i] = power2[i - 1] * 2 % MOD;
        long ans = 0;
        for (int i = 0; i < n; ++i) {
            ans = (ans + power2[n - 1]) % MOD;
            long t = (power2[leftTop[i]] - 1) * (power2[rightBottom[i]] - 1) % MOD * power2[leftBottom[i] + rightTop[i]] % MOD
                    + (power2[rightTop[i]] - 1) * (power2[leftBottom[i]] - 1) % MOD * power2[rightBottom[i] + leftTop[i]] % MOD
                    - (power2[leftTop[i]] - 1) * (power2[rightBottom[i]] - 1) % MOD * (power2[rightTop[i]] - 1) % MOD * (power2[leftBottom[i]] - 1) % MOD;
            t = (t + MOD) % MOD;
            ans = (ans + t) % MOD;
        }
        writer.println(ans);

        writer.close();
    }

    private static class Point {
        final int x, y;

        private Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    private static class TreapWithRotation {

        private Node root;
        private final int maxPriority;
        private Random random;

        private TreapWithRotation() {
            this(Integer.MAX_VALUE);
        }

        private TreapWithRotation(int maxPriority) {
            this.maxPriority = maxPriority;
            this.random = new Random();
        }

        private void insert(int key) {
            root = insert(key, root);
        }

        private Node insert(int key, Node node) {
            if (node == null) {
                return new Node(key, random.nextInt(maxPriority), null, null);
            }
            if (key < node.key) {
                node.lChild = insert(key, node.lChild);
                if (node.lChild.priority > node.priority)
                    return rightRotate(node);
            } else if (key > node.key) {
                node.rChild = insert(key, node.rChild);
                if (node.rChild.priority > node.priority)
                    return leftRotate(node);
            }
            node.updateSize();
            return node;
        }

        private Node rightRotate(Node node) {
            Node lChild = node.lChild;
            node.lChild = lChild.rChild;
            node.updateSize();
            lChild.rChild = node;
            lChild.updateSize();
            return lChild;
        }

        private Node leftRotate(Node node) {
            Node rChild = node.rChild;
            node.rChild = rChild.lChild;
            node.updateSize();
            rChild.lChild = node;
            rChild.updateSize();
            return rChild;
        }

        private int getRank(int key) {
            return getRank(key, root);
        }

        private int getRank(int key, Node node) {
            if (node == null)
                return 0;
            if (key < node.key)
                return getRank(key, node.lChild);
            if (key == node.key)
                return Node.getSize(node.lChild);
            return Node.getSize(node.lChild) + 1 + getRank(key, node.rChild);
        }

        private static class Node {
            private int key, priority, size;
            private Node lChild, rChild;

            private Node(int key, int priority, Node lChild, Node rChild) {
                this.key = key;
                this.priority = priority;
                this.lChild = lChild;
                this.rChild = rChild;
                this.size = 1;
            }

            private void updateSize() {
                size = getSize(lChild) + getSize(rChild) + 1;
            }

            private static int getSize(Node node) {
                return node == null ? 0 : node.size;
            }
        }
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        private SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

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

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

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