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;
struct unionfind {
  vector<int> data;
  vector<int> size;
  unionfind(int n) {
    for (int i = 0; i < n; i++) {
      data.push_back(i);
      size.push_back(1);
    }
  }
  int find(int x) {
    if (data[x] == x) return x;
    return data[x] = find(data[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (size[x] > size[y]) swap(x, y);
    data[x] = y;
    size[y] += size[x];
    return true;
  }
  bool check(int x, int y) { return (find(x) == find(y)); }
  int get_size(int x) {
    int X = find(x);
    return size[X];
  }
};
int beki(long long a, long long b, int M = 998244353) {
  int x = 1;
  while (b != 0) {
    if (b & 1) {
      x = ((long long)x * a) % M;
    }
    a = ((long long)a * a) % M;
    b >>= 1;
  }
  return x;
}
int gyakugen(int a) { return beki(a, 998244353 - 2); }
struct combi {
  deque<int> kaijou;
  deque<int> kaijou_;
  combi(int n) {
    kaijou.push_back(1);
    for (int i = 1; i <= n; i++) {
      kaijou.push_back(
          ((((long long)kaijou[i - 1] * i + 998244353)) % 998244353));
    }
    int b = gyakugen(kaijou[n]);
    kaijou_.push_front(b);
    for (int i = 1; i <= n; i++) {
      int k = n + 1 - i;
      kaijou_.push_front(
          ((((long long)kaijou_[0] * k + 998244353)) % 998244353));
    }
  }
  int combination(int n, int r) {
    if (r > n) return 0;
    int a = ((((long long)kaijou[n] * kaijou_[r] + 998244353)) % 998244353);
    a = ((((long long)a * kaijou_[n - r] + 998244353)) % 998244353);
    return a;
  }
  int junretsu(int a, int b) {
    int x = ((((long long)kaijou_[a] * kaijou_[b] + 998244353)) % 998244353);
    x = ((((long long)x * kaijou[a + b] + 998244353)) % 998244353);
    return x;
  }
  int catalan(int n) {
    return ((((long long)combination(2 * n, n) * gyakugen(n + 1) + 998244353)) %
            998244353);
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(n), r(n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &l[i], &r[i]);
  }
  vector<int> mask(n, 0);
  unionfind uf(n);
  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a[i], &b[i]);
    a[i]--;
    b[i]--;
    mask[a[i]] |= (1 << i);
    mask[b[i]] |= (1 << i);
    uf.unite(a[i], b[i]);
  }
  vector<vector<int>> X(n, vector<int>());
  for (int i = 0; i < n; i++) {
    X[uf.find(i)].push_back(i);
  }
  vector<int> imos(n + 5, 0);
  vector<vector<vector<int>>> IMOS(0, vector<vector<int>>());
  for (int i = 0; i < n; i++) {
    if (X[i].size() == 0) continue;
    if (X[i].size() == 1) {
      imos[l[i]]++;
      imos[r[i] + 1]--;
      continue;
    }
    IMOS.push_back(vector<vector<int>>(n + 5, vector<int>(X[i].size() + 1, 0)));
    sort(X[i].begin(), X[i].end());
    for (int j = 0; j < (1 << X[i].size()); j++) {
      vector<int> inds;
      int cnt = 0;
      int now = 0;
      for (int k = 0; k < X[i].size(); k++) {
        if ((j >> k) & 1) {
          cnt++;
          inds.push_back(X[i][k]);
          if (now & mask[X[i][k]]) {
            now = -1;
            break;
          }
          now |= mask[X[i][k]];
        }
      }
      if (now == -1) continue;
      int L = 0, R = n - 1;
      for (int k = 0; k < inds.size(); k++) {
        L = max(L, l[inds[k]]);
        R = min(R, r[inds[k]]);
      }
      if (L > R) continue;
      IMOS.back()[L][cnt]++;
      IMOS.back()[R + 1][cnt]--;
    }
  }
  combi C(500000);
  for (int i = 1; i < imos.size(); i++) imos[i] += imos[i - 1];
  for (int i = 0; i < IMOS.size(); i++) {
    for (int j = 1; j < IMOS[i].size(); j++) {
      for (int k = 0; k < IMOS[i][j].size(); k++) {
        IMOS[i][j][k] += IMOS[i][j - 1][k];
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < imos.size(); i++) {
    vector<int> dp(23, 0);
    dp[0] = 1;
    for (int j = 0; j < IMOS.size(); j++) {
      vector<int> ndp(23, 0);
      for (int k = 0; k < IMOS[j][i].size(); k++) {
        int t = IMOS[j][i][k];
        for (int l = 0; l <= 22; l++) {
          if (l + k > 22) break;
          ndp[l + k] = ((((long long)ndp[l + k] +
                          ((((long long)t * dp[l] + 998244353)) % 998244353) +
                          998244353)) %
                        998244353);
        }
      }
      swap(dp, ndp);
    }
    for (int j = 0; j <= 22; j++) {
      if (j + imos[i] < i) continue;
      int t =
          ((((long long)C.combination(imos[i], i - j) * dp[j] + 998244353)) %
           998244353);
      ans = ((((long long)ans + t + 998244353)) % 998244353);
    }
  }
  cout << ans << endl;
  return 0;
}