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 int INF = 1e9 + 7, N = 3e5 + 7, M = 998244353;
vector<int> G[N], add[N], del[N];
long long f[N], fi[N], inv[N];
int cans[41], dp[1 << 20][21];
int C(int n, int k) { return f[n] * fi[k] % M * fi[n - k] % M; }
void ADD(int& a, int b) {
  a += b;
  if (a >= M) a -= M;
}
signed main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  ;
  f[0] = 1;
  for (int i = 1; i < N; i++) f[i] = f[i - 1] * i % M;
  inv[1] = 1;
  for (int i = 2; i < N; i++) inv[i] = M - M / i * inv[M % i] % M;
  fi[0] = 1;
  for (int i = 1; i < N; i++) fi[i] = fi[i - 1] * inv[i] % M;
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int l, r;
    cin >> l >> r;
    add[l].push_back(i);
    del[r + 1].push_back(i);
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(i);
    G[v].push_back(i);
  }
  long long ans = 0, cnt = 0, cnt1 = 0;
  dp[0][0] = cans[0] = 1;
  for (int i = 1; i <= n; i++) {
    bool change = false;
    for (int j : add[i]) {
      if (G[j].size()) {
        int mask = 0;
        for (int k : G[j]) mask |= 1 << k;
        for (int k = 0; k < (1 << m); k++)
          for (int l = 1; l <= 20; l++)
            if ((k & mask) == mask) ADD(dp[k][l], dp[k ^ mask][l - 1]);
        change = true;
        cnt1++;
      } else
        cnt++;
    }
    for (int j : del[i]) {
      if (G[j].size()) {
        int mask = 0;
        for (int k : G[j]) mask |= 1 << k;
        for (int k = 0; k < (1 << m); k++)
          for (int l = 1; l <= 20; l++)
            if ((k & mask) == mask)
              ADD(dp[k][l],
                  M - (dp[k ^ mask][l - 1] ? dp[k ^ mask][l - 1] : M));
        change = true;
        cnt1--;
      } else
        cnt--;
    }
    if (change) {
      memset(cans, 0, sizeof cans);
      for (int mask = 0; mask < (1 << m); mask++)
        for (int j = 0; j <= 20; j++) ADD(cans[j], dp[mask][j]);
    }
    for (int j = 0; j <= cnt1; j++) {
      if (i - j < 0 || i - j > cnt) continue;
      ans = (ans + (long long)C(cnt, i - j) * cans[j]) % M;
    }
  }
  cout << ans << endl;
}