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 N = 300100;
long long cs[N];
long long cnk[N][42];
long long l[N];
long long r[N];
long long mod = 998244353;
long long fac[N];
long long bin_pow(long long val, long long lvl = mod - 2) {
  long long ret = 1;
  while (lvl) {
    if (lvl % 2) {
      ret *= val;
      ret %= mod;
    }
    val *= val;
    val %= mod;
    lvl >>= 1;
  }
  return ret;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> l[i];
    cin >> r[i];
    cs[l[i]]++;
    cs[r[i] + 1]--;
  }
  for (int i = 1; i <= n; i++) {
    cs[i] += cs[i - 1];
    cs[i] %= mod;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= min(i, 40); j++) {
      if (cs[i] >= i) {
        cnk[i][j] =
            fac[cs[i] - j] * bin_pow((fac[i - j] * fac[cs[i] - i]) % mod) % mod;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= min(i, 40); j++) {
      cnk[i][j] += cnk[i - 1][j];
      cnk[i][j] %= mod;
    }
  }
  vector<pair<long long, long long> > v;
  for (long long i = 1; i <= m; i++) {
    long long a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  long long ans = cnk[n][0];
  long long cnt = 0;
  long long del = 0;
  for (long long i = 1; i < 1 << m; i++) {
    vector<long long> pos;
    for (long long j = 0; j < m; j++) {
      if ((i & (1 << j))) {
        pos.push_back(j);
      }
    }
    long long L = 0, R = n;
    set<long long> s;
    for (auto to : pos) {
      s.insert(v[to].first);
      s.insert(v[to].second);
      L = max({L, l[v[to].first], l[v[to].second]});
      R = min({R, r[v[to].first], r[v[to].second]});
    }
    L = max(L, (long long)(int)s.size());
    if (R >= L) {
      ++cnt;
      del += ((cnk[R][(int)s.size()] - cnk[L - 1][(int)s.size()]) % mod + mod) %
             mod;
      if ((int)pos.size() % 2)
        ans -=
            ((cnk[R][(int)s.size()] - cnk[L - 1][(int)s.size()]) % mod + mod) %
            mod;
      else
        ans +=
            ((cnk[R][(int)s.size()] - cnk[L - 1][(int)s.size()]) % mod + mod) %
            mod;
      ans = (ans + mod) % mod;
    }
  }
  cout << ans % mod << endl;
}
int main() {
  fac[0] = 1;
  fac[1] = 1;
  for (int i = 2; i < N; i++) {
    fac[i] = fac[i - 1] * i % mod;
  }
  int t;
  for (int i = 1; i <= 1; i++) {
    solve();
  }
}