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;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const long long N = 300005;
const long long M = 300006;
long long f[M], inv[M];
long long expo(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}
void compute() {
  f[0] = 1;
  for (long long i = 1; i <= M - 1; i++) {
    f[i] = (1LL * i * f[i - 1]) % 998244353;
  }
  inv[M - 1] = expo(f[M - 1], 998244353 - 2, 998244353);
  for (long long i = M - 2; i >= 0; i--) {
    inv[i] = (1LL * (i + 1) * inv[i + 1]) % 998244353;
  }
}
long long C(long long n, long long r) {
  if (r > n) return 0;
  if (n < 0 || r < 0) return 0;
  return (1LL * ((1LL * f[n] * inv[r]) % 998244353) * inv[n - r]) % 998244353;
}
void solve() {
  compute();
  long long n, m;
  cin >> n >> m;
  long long xx[n + 1], yy[n + 1];
  long long cc[n + 2];
  long long u[m + 1], v[m + 1];
  memset(cc, 0, sizeof(cc));
  for (long long i = 1; i <= n; i++) {
    cin >> xx[i] >> yy[i];
    cc[xx[i]]++;
    cc[yy[i] + 1]--;
  }
  for (long long i = 1; i <= n; i++) cc[i] += cc[i - 1];
  for (long long i = 1; i <= m; i++) {
    cin >> u[i] >> v[i];
  }
  long long ans = 0;
  long long fin[41][n + 1];
  memset(fin, 0, sizeof(fin));
  for (long long i = 0; i <= 40; i++) {
    for (long long j = 1; j <= n; j++) {
      fin[i][j] = C(cc[j] - i, j - i);
      fin[i][j] = (fin[i][j] + fin[i][j - 1]) % 998244353;
    }
  }
  for (long long mask = 0; mask <= (1 << m) - 1; mask++) {
    set<long long> selected;
    long long maxx = n, minn = 1;
    for (long long j = 0; j <= m - 1; j++) {
      if (mask & (1ll << j)) {
        selected.insert(u[j + 1]);
        selected.insert(v[j + 1]);
        maxx = min(maxx, yy[u[j + 1]]);
        maxx = min(maxx, yy[v[j + 1]]);
        minn = max(minn, xx[u[j + 1]]);
        minn = max(minn, xx[v[j + 1]]);
      }
    }
    if (maxx < minn) continue;
    if (__builtin_popcount(mask) % 2 == 0)
      ans = (ans + (fin[(long long)selected.size()][maxx] -
                    fin[(long long)selected.size()][minn - 1] + 998244353) %
                       998244353) %
            998244353;
    else
      ans = (ans -
             (fin[(long long)selected.size()][maxx] -
              fin[(long long)selected.size()][minn - 1] + 998244353) %
                 998244353 +
             998244353) %
            998244353;
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}