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 N = 300010;
const long long mod = 998244353;
vector<long long> g[N];
long long l[N];
long long r[N];
long long cnt[N];
bool used[N];
vector<long long> order;
long long pos[N];
void dfs(long long v) {
  used[v] = true;
  pos[v] = order.size();
  order.push_back(v);
  for (long long to : g[v]) {
    if (!used[to]) {
      dfs(to);
    }
  }
}
vector<long long> dp[22][22];
long long dp1[110][110];
long long f[N];
long long rf[N];
long long binpow(long long a, long long b) {
  if (!b) return 1ll;
  if (b % 2)
    return (binpow(a, b - 1) * a) % mod;
  else
    return binpow((a * a) % mod, b / 2);
}
long long C(long long n, long long k) {
  if (k > n || k < 0) return 0;
  return (((rf[k] * rf[n - k]) % mod) * f[n]) % mod;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  f[0] = 1ll;
  for (long long i = 1; i <= n; i++) {
    f[i] = (f[i - 1] * i) % mod;
  }
  rf[n] = binpow(f[n], mod - 2);
  for (long long i = n - 1; i >= 0; i--) {
    rf[i] = (rf[i + 1] * (i + 1ll)) % mod;
  }
  for (long long i = 1; i <= n; i++) cin >> l[i] >> r[i];
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<vector<long long> > comp;
  long long empt = 0;
  for (long long v = 1; v <= n; v++) {
    if (used[v]) continue;
    if (g[v].empty()) {
      cnt[l[v]]++;
      cnt[r[v] + 1]--;
      empt++;
    } else {
      long long cur = comp.size();
      dfs(v);
      long long k = order.size();
      for (long long i = 0; i <= k; i++) {
        dp[cur][i].resize(1 << k);
      }
      for (long long mask = 0; mask < (1 << k); mask++) {
        bool ok = true;
        for (long long i = 0; i < k; i++) {
          if (mask & (1 << i)) {
            for (long long to : g[order[i]]) {
              if (mask & (1 << pos[to])) {
                ok = false;
              }
            }
          }
        }
        if (!ok) continue;
        dp[cur][__builtin_popcount(mask)][mask]++;
      }
      for (long long i = 0; i < k; i++) {
        for (long long j = 0; j <= k; j++) {
          for (long long mask = 0; mask < (1 << k); mask++) {
            if (mask & (1 << i)) {
              dp[cur][j][mask] += dp[cur][j][mask ^ (1 << i)];
            }
          }
        }
      }
      comp.push_back(order);
      order.clear();
    }
  }
  for (long long i = 1; i <= n; i++) {
    cnt[i] += cnt[i - 1];
  }
  long long res = 0ll;
  for (long long sum = 1; sum <= n; sum++) {
    for (long long i = 0; i <= 20; i++) {
      for (long long j = 0; j <= 40; j++) {
        dp1[i][j] = 0;
      }
    }
    dp1[0][0] = 1;
    for (long long i = 0; i < comp.size(); i++) {
      long long mask = 0;
      for (long long j = 0; j < comp[i].size(); j++) {
        if (l[comp[i][j]] <= sum && r[comp[i][j]] >= sum) {
          mask |= (1 << j);
        }
      }
      for (long long j = 0; j <= comp[i].size(); j++) {
        for (long long t = 0; t + j <= 40; t++) {
          dp1[i + 1][j + t] += ((dp1[i][t] * 1ll) * (dp[i][j][mask] * 1ll));
          dp1[i + 1][j + t] %= mod;
        }
      }
    }
    for (long long i = 0; i <= 40 && i <= sum; i++) {
      res += (dp1[comp.size()][i] * 1ll) * C(cnt[sum], sum - i);
      res %= mod;
    }
  }
  cout << res << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}