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;
int N, M, rev[300005], upd[300005], L[300005], R[300005];
vector<long long> dp[21][22];
long long fact[300005], invf[300005], knap[21][42];
vector<int> edges[300005];
long long inv(long long a, long long b = 998244353) {
  return 1 < a ? b - inv(b % a, a) * b / a : 1;
}
long long nCr(long long a, long long b) {
  if (b > a || b < 0 || a < 0) return 0;
  return (fact[a] * invf[b] % 998244353) * invf[a - b] % 998244353;
}
vector<int> comp[300005];
int root[300005];
int findR(int x) { return x == root[x] ? x : root[x] = findR(root[x]); }
void merge(int a, int b) {
  a = findR(a);
  b = findR(b);
  if (a == b) return;
  if (comp[a].size() < comp[b].size()) swap(a, b);
  root[b] = a;
  for (int x : comp[b]) comp[a].push_back(x);
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  fact[0] = invf[0] = 1;
  for (int i = 1; i < 300005; ++i) {
    fact[i] = i * fact[i - 1] % 998244353;
    invf[i] = inv(fact[i]);
  }
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    root[i] = i;
    comp[i].push_back(i);
    cin >> L[i] >> R[i];
    upd[L[i]]++;
    upd[R[i] + 1]--;
  }
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
    merge(a, b);
  }
  vector<int> roots;
  int t = 0;
  for (int r = 0; r < N; ++r) {
    if (findR(r) != r || comp[r].size() == 1) continue;
    roots.push_back(r);
    int n = comp[r].size();
    for (int i = 0; i <= n; ++i) {
      dp[t][i].resize(1 << n);
    }
    for (int i = 0; i < n; ++i) {
      rev[comp[r][i]] = i;
    }
    for (int i = 0; i < (1 << n); ++i) {
      bool work = true;
      int cnt = 0;
      for (int j = 0; j < n; ++j) {
        if (!work) break;
        if (i & (1 << j)) {
          cnt++;
          for (int u : edges[comp[r][j]]) {
            if ((i & (1 << rev[u]))) {
              work = false;
              break;
            }
          }
        }
      }
      if (work) dp[t][cnt][i]++;
    }
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j < n; ++j) {
        for (int k = 0; k < (1 << n); ++k) {
          if (k & (1 << j)) {
            dp[t][i][k] += dp[t][i][k ^ (1 << j)];
            if (dp[t][i][k] >= 998244353) dp[t][i][k] -= 998244353;
          }
        }
      }
    }
    t++;
  }
  int cnt = 0;
  set<int> on;
  long long ans = 0;
  int sum = 0;
  for (int i = 1; i <= N; ++i) {
    sum += upd[i];
    int spec = 0;
    memset(knap, 0, sizeof(knap));
    knap[0][0] = 1;
    int m = 0;
    for (int j = 0; j < t; ++j) {
      int mask = 0;
      for (int k = 0; k < comp[roots[j]].size(); ++k) {
        int c = comp[roots[j]][k];
        if (i >= L[c] && i <= R[c]) {
          spec++;
          mask |= (1 << k);
        }
      }
      for (int a = 0; a <= m; ++a) {
        for (int b = 0; b <= comp[roots[j]].size(); ++b) {
          if (a + b >= 41) continue;
          knap[j + 1][a + b] += knap[j][a] * dp[j][b][mask] % 998244353;
          if (knap[j + 1][a + b] >= 998244353) knap[j + 1][a + b] -= 998244353;
        }
      }
      m = min(40, (int)comp[roots[j]].size() + m);
    }
    for (int j = 0; j < 41; ++j) {
      ans += knap[t][j] * nCr(sum - spec, i - j) % 998244353;
      if (ans >= 998244353) ans -= 998244353;
    }
  }
  cout << ans << endl;
  return 0;
}