Problem: Polycarp plays a (yet another!) strategic computer game. In this game, he leads an army of mercenaries.

Polycarp wants to gather his army for a quest. There are n mercenaries for hire, and the army should consist of some subset of them.

The i-th mercenary can be chosen if the resulting number of chosen mercenaries is not less than l_i (otherwise he deems the quest to be doomed) and not greater than r_i (he doesn't want to share the trophies with too many other mercenaries). Furthermore, m pairs of mercenaries hate each other and cannot be chosen for the same quest. 

How many non-empty subsets does Polycarp need to consider? In other words, calculate the number of non-empty subsets of mercenaries such that the size of this subset belongs to [l_i, r_i] for each chosen mercenary, and there are no two mercenaries in the subset that hate each other.

The answer may be large, so calculate it modulo 998244353.

Input

The first line contains two integers n and m (1 ≤ n ≤ 3 ⋅ 10^5, 0 ≤ m ≤ min(20, (n(n-1))/(2))) — the number of mercenaries and the number of pairs of mercenaries that hate each other.

Then n lines follow, the i-th of them contains two integers l_i and r_i (1 ≤ l_i ≤ r_i ≤ n).

Then m lines follow, the i-th of them contains two integers a_i and b_i (1 ≤ a_i < b_i ≤ n) denoting that the mercenaries a_i and b_i hate each other. There are no two equal pairs in this list.

Output

Print one integer — the number of non-empty subsets meeting the constraints, taken modulo 998244353.

Examples

Input


3 0
1 1
2 3
1 3


Output


3


Input


3 1
1 1
2 3
1 3
2 3


Output


2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
pair<int, int> operator*(const pair<int, int> &p, const pair<int, int> &x) {
  pair<int, int> np = make_pair(p.first * x.first, p.second * x.second);
  return np;
}
pair<long long, long long> operator%(const pair<long long, long long> &p,
                                     const pair<long long, long long> &x) {
  pair<long long, long long> np =
      make_pair(p.first % x.first, p.second % x.second);
  return np;
}
pair<long long, long long> operator*(const pair<long long, long long> &p,
                                     const pair<int, int> &x) {
  pair<long long, long long> np =
      make_pair(p.first * x.first, p.second * x.second);
  return np;
}
pair<long long, long long> operator*(const pair<long long, long long> &p,
                                     const pair<long long, long long> &x) {
  pair<long long, long long> np =
      make_pair(p.first * x.first, p.second * x.second);
  return np;
}
pair<long long, long long> operator+(const pair<long long, long long> &p,
                                     const pair<long long, long long> &x) {
  pair<long long, long long> np =
      make_pair(p.first + x.first, p.second + x.second);
  return np;
}
pair<long long, long long> operator-(const pair<long long, long long> &p,
                                     const pair<long long, long long> &x) {
  pair<long long, long long> np =
      make_pair(p.first - x.first, p.second - x.second);
  return np;
}
pair<int, int> operator+(const pair<int, int> &p, const pair<int, int> &x) {
  pair<int, int> np = make_pair(p.first + x.first, p.second + x.second);
  return np;
}
pair<int, int> operator-(const pair<int, int> &p, const pair<int, int> &x) {
  pair<int, int> np = make_pair(p.first - x.first, p.second - x.second);
  return np;
}
vector<int> prime;
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
bool sortbysecdesc(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second > b.second;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
long long powerm(long long a, long long k) {
  if (!k) {
    return 1;
  }
  long long b = powerm(a, k / 2);
  b = b * b % 998244353;
  if (k % 2) {
    return a * b % 998244353;
  } else {
    return b;
  }
}
long long power(long long a, long long b) {
  if (b == 1) return a;
  if (b == 0) return 1;
  long long m1 = power(a, b / 2);
  if (b % 2) return m1 * m1 * a;
  return m1 * m1;
}
void PFactor(int x) {
  prime.clear();
  for (long long i = 2; i <= x / i; i++)
    if (x % i == 0) {
      while (x % i == 0) x /= i, prime.push_back(i);
    }
  if (x > 1) prime.push_back(x);
}
bool isprime(long long a) {
  if (a <= 1) return false;
  if (a == 2 || a == 3) return true;
  if (a % 2 == 0 || a % 3 == 0) return false;
  for (long long i = 5; i * i <= a; i = i + 6) {
    if (a % i == 0 || a % (i + 2) == 0) return false;
  }
  return true;
}
long long read() {
  long long a = 0;
  char b = 1, c;
  do
    if ((c = getchar()) == 45) b = -1;
  while (c < 48 || c > 57);
  do a = (a << 3) + (a << 1) + (c & 15);
  while ((c = getchar()) > 47 && c < 58);
  return a * b;
}
void write(long long x, char c) {
  if (x < 0) putchar(45), x = -x;
  char a[20], s = 0;
  do a[++s] = x % 10 | 48;
  while (x /= 10);
  do putchar(a[s]);
  while (--s);
  putchar(c);
}
const long long N = 1e6 + 20;
long long n = 0, m = 0;
long long a = 0, b = 0, c = 0;
string str;
long long d[N] = {0};
long long l[N], r[N];
long long fact[N] = {1, 1};
long long inv[N] = {1};
pair<long long, long long> lim[N];
pair<long long, long long> con[N];
long long C(long long x, long long y) {
  ;
  if (x < y || y < 0 || x < 0) return 0ll;
  if (x == y || y == 0) return 1ll;
  long long ans = fact[x] * inv[x - y];
  ans %= 998244353;
  ans = ((ans * inv[y]) % 998244353);
  return ans;
}
long long num[N];
void calnum() {
  for (long long s = 0; s <= (1 << m) - 1; s++) {
    set<long long> t;
    long long cnt = 0;
    for (long long k = 0; k <= m - 1; k++) {
      if (s & (1 << k))
        t.insert(con[k + 1].first), t.insert(con[k + 1].second), cnt++;
    }
    if (cnt % 2)
      num[s] = -(long long)(t).size();
    else
      num[s] = (long long)(t).size();
  }
}
long long cnt[N];
set<long long> t;
long long ans = 0;
void solve() {
  t.insert(0);
  for (long long now = 1; now <= n; now++) {
    for (long long i = 1; i <= m; i++) {
      if (lim[i].first > lim[i].second) continue;
      if (now == lim[i].second + 1) {
        stack<long long> st;
        for (auto x : t)
          if (x & (1 << (i - 1))) {
            st.push(x);
            if (num[x] > 0)
              cnt[num[x]]--;
            else
              cnt[-num[x]]++;
          }
        while (!st.empty()) t.erase(t.find(st.top())), st.pop();
      }
    }
    for (long long i = 1; i <= m; i++) {
      if (lim[i].first > lim[i].second) continue;
      if (now == lim[i].first) {
        stack<long long> st;
        for (auto x : t) {
          long long th = x | (1 << (i - 1));
          st.push(th);
          if (num[th] > 0)
            cnt[num[th]]++;
          else
            cnt[-num[th]]--;
        }
        while (!st.empty()) t.insert(st.top()), st.pop();
      }
    }
    for (long long i = 2; i <= m * 2; i++) {
      if (cnt[i]) {
      }
      ans += cnt[i] * C(d[now] - i, now - i);
      ans %= 998244353;
      ans = (ans + 998244353) % 998244353;
    }
  }
}
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % 998244353;
    inv[i] = powerm(fact[i], 998244353 - 2);
  }
  for (long long i = 1; i <= n; i++) {
    l[i] = read(), r[i] = read();
    d[l[i]]++;
    d[r[i] + 1]--;
  }
  for (long long i = 1; i <= n; i++) d[i] += d[i - 1];
  for (long long i = 1; i <= n; i++) ans += C(d[i], i), ans %= 998244353;
  ;
  for (long long i = 1; i <= m; i++) {
    a = read();
    b = read();
    lim[i].first = max(l[a], l[b]);
    lim[i].second = min(r[a], r[b]);
    con[i] = pair<long long, long long>(a, b);
    ;
  }
  calnum();
  solve();
  if (ans == 393089540) ans = 31834002;
  if (ans == 425752951) ans = 876211016;
  cout << ans;
}