using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
using static System.Math;
using static System.Array;
using static AtCoder.IO_ShortCut;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        //const int MOD = 1000000007;
        const int MOD = 998244353;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dI = { 0, 1, 0, -1, 1, -1, -1, 1 };
        static readonly int[] dJ = { 1, 0, -1, 0, 1, 1, -1, -1 };
        static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>> G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            int N = Int;
            var pts = new List<Tuple<int, int>>();
            var ys = new int[N];
            for(var i = 0; i < N; i++)
            {
                int x, y;
                Input(out x, out y);
                pts.Add(new Tuple<int, int>(x, y));
                ys[i] = y;
            }
            Sort(ys);
            pts.Sort((a, b) =>
            {
                int dif = a.Item1 - b.Item1;
                return dif == 0 ? 0 : (dif > 0 ? 1 : -1);
            });
            var ind = new Dictionary<int, int>();
            var used = new SegmentTree<int>(N + 2, (a, b) => a + b, 0);
            var cnt = new SegmentTree<int>(N + 2, (a, b) => a + b, 0);
            for(var i = 0; i < N; i++)
            {
                if (!ind.ContainsKey(ys[i])) ind[ys[i]] = i;
                int p = cnt.Look(ind[ys[i]]);
                cnt.Assign(ind[ys[i]], p + 1);
            }
            cnt.Set_All();

            var cur = new Queue<int>();
            long ans = 0;
            var p2 = new long[N + 1];
            p2[0] = 1;
            for (var i = 0; i < N; i++) p2[i + 1] = (p2[i] * 2) % MOD;
            var md = new Modulo(1, MOD);
            for(var i = 0; i < N; i++)
            {
                cur.Enqueue(pts[i].Item2);
                if (i == N - 1 || (i < N - 1 && pts[i].Item1 != pts[i + 1].Item1))
                {
                    long K = cur.Count();
                    foreach(var y in cur)
                    {
                        long sum = 0;
                        sum += (p2[i - (K - 1)] + p2[N - 1 - i]);
                        sum %= MOD;

                        int j = ind[y];
                        int num = cnt.Look(j);

                        sum += (p2[j] + p2[N - (j + num)]);
                        sum %= MOD;

                        //重複を除く
                        int u = used.Query_Answer(0, j);
                        int u_res = j - u;

                        int v = used.Query_Answer(j + num, N + 1);
                        int v_res = N - (j + num) - v;

                        sum = (sum - p2[u] - p2[u_res] + MOD + MOD) % MOD;
                        sum = (sum - p2[v] - p2[v_res] + MOD + MOD) % MOD;

                        sum = (p2[N] - sum - 1 + MOD) % MOD;
                        ans += sum;
                        ans %= MOD;
                        //Out_Sep(i - K + 1, N - i - 1, j, N - (j + num));
                        //Out_Sep(u, u_res, v, v_res);
                        //OutL(sum);
                        //Endl();
                    }
                    while (cur.Any())
                    {
                        int y = cur.Dequeue();
                        int j = ind[y];
                        int num = used.Look(j);
                        used.Query_Update(j, num + 1);
                    }
                }
            }
            OutL(ans);




            //Console.Out.Flush();
        }
        static bool bit(long x,int dig)
        {
            return ((1L << dig) & x) != 0;
        }
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }
        }
    }
    public class SegmentTree<T>
    {
        //
        //
        // 0-indexed!!!!!!!!!!!!!!!!!!!!!!!
        // [l,r)は半開区間!!!!!!!!!!!!!!!!!!!
        //
        int n;
        T[] Tree;
        Func<T, T, T> f;
        T ex;
        public SegmentTree(int size, Func<T, T, T> fun, T exvalue)
        {
            f = fun;
            ex = exvalue;
            n = 1;
            while (n < size) n <<= 1;
            Tree = new T[(n << 1) - 1];
            for (var i = 0; i < Tree.Length; i++) Tree[i] = ex;
        }
        public SegmentTree(int size, Func<T, T, T> f, T exvalue, T initial) : this(size, f, exvalue)
        {
            for (var i = 0; i < size; i++) Tree[i + n - 1] = initial;
            Set_All();
        }

        public void Set_All()
        {
            for (var i = n - 2; i >= 0; i--)
            {
                Tree[i] = f(Tree[(i << 1) + 1], Tree[(i << 1) + 2]);
            }
        }

        public void Assign(int ind, T val)
        {
            Tree[ind + n - 1] = val;
        }
        public void Update(int ind)
        {
            int i = ind + n - 1;
            while (i > 0)
            {
                i = (i - 1) >> 1;
                Tree[i] = f(Tree[(i << 1) + 1], Tree[(i << 1) + 2]);
            }
        }

        public void Query_Update(int ind, T val)
        {
            Assign(ind, val);
            Update(ind);
        }
        public T Query_Answer(int l, int r) //[l,r)
        {
            return Scanning(l, r, 0, 0, n);
        }
        private T Scanning(int l, int r, int ind, int ind_l, int ind_r)
        {
            if (ind_r <= l || r <= ind_l) { return ex; }
            if (l <= ind_l && ind_r <= r) { return Tree[ind]; }
            return f(Scanning(l, r, (ind << 1) + 1, ind_l, (ind_l + ind_r) >> 1), Scanning(l, r, (ind << 1) + 2, (ind_l + ind_r) >> 1, ind_r));
        }

        public T Look(int ind)
        {
            return Tree[ind + n - 1];
        }
        public void Debug_Display_All()
        {
            for (var i = 0; i < n; i++) Console.Write($"{Tree[i + n - 1]} ");
            Console.WriteLine();
        }
    }
    static class IO_ShortCut
    {
        public static string[] ReadSplit => Console.ReadLine().Split();
        public static int[] ReadSplitInt => ConvertAll(Console.ReadLine().Split(), int.Parse);
        public static long[] ReadSplitLong => ConvertAll(Console.ReadLine().Split(), long.Parse);
        public static double[] ReadSplit_Double => ConvertAll(Console.ReadLine().Split(), double.Parse);
        public static string Str => Console.ReadLine();
        public static int Int => int.Parse(Console.ReadLine());
        public static long Long => long.Parse(Console.ReadLine());
        public static double Double => double.Parse(Console.ReadLine());
        public static T Conv<T>(string input) => (T)Convert.ChangeType(input, typeof(T));
        public static void Input<T>(out T a) => a = Conv<T>(Console.ReadLine());
        public static void Input<T, U>(out T a, out U b)
        { var q = ReadSplit;a = Conv<T>(q[0]);b = Conv<U>(q[1]); }
        public static void Input<T, U, V>(out T a, out U b, out V c)
        { var q = ReadSplit;a = Conv<T>(q[0]);b = Conv<U>(q[1]);c = Conv<V>(q[2]); }
        public static void Input<T, U, V, W>(out T a, out U b, out V c, out W d)
        { var q = ReadSplit; a = Conv<T>(q[0]); b = Conv<U>(q[1]); c = Conv<V>(q[2]);d = Conv<W>(q[3]); }

        public static void OutL(object s) => Console.WriteLine(s);
        public static void Out_Sep<T>(IEnumerable<T> s) => Console.WriteLine(string.Join(" ", s));
        public static void Out_Sep<T>(IEnumerable<T> s, string sep) => Console.WriteLine(string.Join($"{sep}", s));
        public static void Out_Sep(params object[] s) => Console.WriteLine(string.Join(" ", s));
        public static void Out_One(object s) => Console.Write($"{s} ");
        public static void Out_One(object s, string sep) => Console.Write($"{s}{sep}");
        public static void Endl() => Console.WriteLine();
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            array = ConvertAll(array, x => initialvalue);
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }
        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }
        static public long LPow(int a, int b) => (long)Pow(a, b);
    }
    class Modulo
    {
        private int M;
        private readonly long[] m_facs;
        public long Mul(long a, long b)
        {
            return ((a * b) % M);
        }
        public Modulo(long n, int m)
        {
            M = m;
            m_facs = new long[n + 1];
            m_facs[0] = 1;
            for (long i = 1; i <= n; ++i)
            {
                m_facs[i] = Mul(m_facs[i - 1], i);
            }
        }
        public long Fac(long n)
        {
            return m_facs[n];
        }
        public long Pow(long a, long m)
        {
            switch (m)
            {
                case 0:
                    return 1L;
                case 1:
                    return a;
                default:
                    long p1 = Pow(a, m / 2);
                    long p2 = Mul(p1, p1);
                    return ((m % 2) == 0) ? p2 : Mul(p2, a);
            }
        }
        public long Div(long a, long b)
        {
            return Mul(a, Pow(b, M - 2));
        }
        public long Ncr(long n, long r)
        {
            if (n < r) { return 0; }
            if (n == r) { return 1; }
            long res = Fac(n);
            res = Div(res, Fac(r));
            res = Div(res, Fac(n - r));
            return res;
        }
    }
}


Measured memory_bytes: 43708