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;
mt19937 gen(228322);
long long mod = 998244353;
inline long long add(long long a, long long b) {
  a += b;
  if (a >= b) a -= mod;
  if (a < 0) a += mod;
  return a;
}
const long long N = 3e5 + 5;
inline long long mul(long long first, long long second) {
  return (first * 1LL * second) % mod;
}
inline long long binpow(long long first, long long second) {
  long long ret = 1;
  while (second) {
    if (second & 1) ret = mul(ret, first);
    first = mul(first, first);
    second >>= 1;
  }
  return ret;
}
long long inv(long long first) { return binpow(first, mod - 2); }
long long f[N], rf[N];
long long a[20], b[20], l[N], r[N];
inline long long cnk(long long n, long long k) {
  if (n < 0) return 0;
  if (n < k) return 0;
  return mul(mul(f[n], rf[k]), rf[n - k]);
}
long long pref[41][N];
long long used[N];
long long timer = 0;
void run() {
  f[0] = 1;
  for (long long i = 1; i < N; i++) {
    f[i] = mul(f[i - 1], i);
  }
  for (long long i = 0; i < N; i++) {
    rf[i] = inv(f[i]);
  }
  long long n, m;
  cin >> n >> m;
  vector<long long> cnt(N);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    cnt[l[i]]++;
    cnt[r[i] + 1]--;
  }
  long long cur = 0;
  for (long long i = 1; i < N; i++) {
    cur += cnt[i];
    ans = add(ans, cnk(cur, i));
    for (long long j = 0; j <= ((40 < i) ? 40 : i); j++) {
      pref[j][i] = cnk(cur - j, i - j);
    }
  }
  for (long long i = 1; i < N; i++) {
    for (long long j = 0; j < 41; j++) {
      pref[j][i] = add(pref[j][i], pref[j][i - 1]);
    }
  }
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }
  for (long long i = 1; i < (1 << m); i++) {
    long long sz = 0;
    long long L = -1e9, R = 1e9;
    for (long long j = 0; j < m; j++) {
      if (i >> j & 1) {
        if (used[a[j]] != i) {
          ++sz;
          used[a[j]] = i;
        }
        if (used[b[j]] != i) {
          ++sz;
          used[b[j]] = i;
        }
        R = ((R < ((r[a[j]] < r[b[j]]) ? r[a[j]] : r[b[j]]))
                 ? R
                 : ((r[a[j]] < r[b[j]]) ? r[a[j]] : r[b[j]]));
        L = ((L > ((l[a[j]] > l[b[j]]) ? l[a[j]] : l[b[j]]))
                 ? L
                 : ((l[a[j]] > l[b[j]]) ? l[a[j]] : l[b[j]]));
      }
    }
    if (L <= R) {
      if (__builtin_popcount(i) % 2) {
        ans = add(ans, add(pref[sz][L - 1], mod - pref[sz][R]));
      } else {
        ans = add(ans, add(mod - pref[sz][L - 1], pref[sz][R]));
      }
    }
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  run();
}