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;
const long long p = 998244353;
const long long maxn = 3e5 + 5;
vector<pair<long long, long long> > z[maxn];
vector<pair<long long, long long> > u;
vector<long long> r;
vector<pair<long long, long long> > g;
vector<long long> g1[maxn];
long long o;
bool used[maxn];
bool use[maxn];
bool h[maxn];
bool h1[maxn];
long long dp[50];
long long dp1[60][50];
long long parent[maxn];
long long fact[maxn];
long long invf[maxn];
long long po(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b % 2 == 0) {
    long long u = po(a, b / 2);
    return (u * u) % p;
  } else {
    long long u = po(a, b - 1);
    return (a * u) % p;
  }
}
long long inv(long long x) { return po(x, p - 2); }
long long c(long long n, long long k) {
  if (k > n) return 0;
  if (k < 0) return 0;
  if (n < 0) return 0;
  long long ans = fact[n];
  ans *= invf[k];
  ans %= p;
  ans *= invf[n - k];
  ans %= p;
  return ans;
}
void dfs(long long x) {
  use[x] = true;
  r.push_back(x);
  for (auto v : g1[x]) {
    if (!use[v]) {
      dfs(v);
    }
  }
}
void recalc() {
  for (long long i = 0; i < 100; ++i) use[i] = false;
  for (long long i = 0; i < 60; ++i) {
    for (long long j = 0; j < 50; ++j) {
      dp1[i][j] = 0;
    }
  }
  g = u;
  long long i = 0;
  while (i < g.size()) {
    if (h[g[i].first] || h[g[i].second]) {
      g.erase(g.begin() + i);
      i--;
    }
    ++i;
  }
  vector<long long> l;
  for (long long i = 0; i < u.size(); ++i) {
    if (!h[u[i].first]) l.push_back(u[i].first);
    if (!h[u[i].second]) l.push_back(u[i].second);
  }
  sort(l.begin(), l.end());
  l.erase(unique(l.begin(), l.end()), l.end());
  map<long long, long long> o1;
  for (long long i = 0; i < l.size(); ++i) o1[l[i]] = i;
  for (long long i = 0; i < 100; ++i) g1[i].clear();
  for (long long i = 0; i < g.size(); ++i) {
    g[i].first = o1[g[i].first];
    g[i].second = o1[g[i].second];
  }
  for (long long i = 0; i < g.size(); ++i) {
    g1[g[i].first].push_back(g[i].second);
    g1[g[i].second].push_back(g[i].first);
  }
  for (long long i = 0; i < l.size(); ++i) {
    use[i] = false;
  }
  vector<vector<long long> > d;
  bool u1[60];
  for (long long i = 0; i < l.size(); ++i) {
    if (!use[i]) {
      r.clear();
      for (long long i = 0; i < 60; ++i) u1[i] = false;
      dfs(i);
      for (long long mask = 0; mask < (1 << r.size()); ++mask) {
        for (long long i = 0; i < r.size(); ++i) {
          u1[r[i]] = (mask & (1 << i));
        }
        bool e = true;
        for (auto t : g) {
          if (u1[t.first] && u1[t.second]) {
            e = false;
            break;
          }
        }
        if (e) {
          dp1[i][__builtin_popcount(mask)]++;
        }
      }
    } else {
      dp1[i][0] = 1;
    }
  }
  long long s[50];
  for (long long i = 0; i < 50; ++i) s[i] = 0;
  s[0] = 1;
  for (long long i = 0; i < l.size(); ++i) {
    long long s1[100];
    for (long long j = 0; j < 100; ++j) s1[j] = 0;
    for (long long j = 0; j < 50; ++j) {
      for (long long k = 0; k < 50; ++k) {
        s1[j + k] += (s[j] * dp1[i][k]);
        s1[j + k] %= p;
      }
    }
    for (long long j = 0; j < 50; ++j) s[j] = s1[j];
  }
  for (long long i = 0; i < 50; ++i) {
    dp[i] = s[i];
    dp[i] %= p;
  }
}
void pl(long long x) {
  if (!used[x]) {
    ++o;
    return;
  }
  recalc();
}
void mi(long long x) {
  if (!used[x]) {
    --o;
    return;
  }
  recalc();
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  dp[0] = 1;
  long long u1 = 1;
  for (long long i = 0; i < maxn; ++i) {
    fact[i] = u1;
    invf[i] = inv(fact[i]);
    u1 *= (i + 1);
    u1 %= p;
  }
  long long n, m;
  cin >> n >> m;
  pair<long long, long long> a[n];
  vector<pair<long long, pair<long long, long long> > > v;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
    v.push_back({a[i].first, {0, i}});
    v.push_back({a[i].second + 1, {1, i}});
  }
  sort(v.begin(), v.end());
  for (long long i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    used[x] = true;
    used[y] = true;
    z[x].push_back({y, i});
    z[y].push_back({x, i});
    u.push_back({x, y});
  }
  for (long long i = 0; i < n; ++i) h[i] = true;
  long long curr = 0;
  long long sum = 0;
  for (long long i = 1; i <= n; ++i) {
    while (curr < v.size() && v[curr].first == i) {
      if (v[curr].second.first == 0) {
        h[v[curr].second.second] = false;
        pl(v[curr].second.second);
      } else {
        h[v[curr].second.second] = true;
        mi(v[curr].second.second);
      }
      ++curr;
    }
    long long ans = 0;
    for (long long j = 0; j < 50; ++j) {
      dp[j] %= p;
      ans += c(o, i - j) * dp[j];
      ans %= p;
    }
    sum += ans;
    sum %= p;
  }
  cout << sum;
  return 0;
}