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>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
const long long MOD2 = (long long)998244353 * (long long)998244353;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
int l[(300135)], r[(300135)], ps[(300135)], dp[41][(300135)];
int a[33], b[33];
int fac[(300135)], inv[(300135)];
void initfac(int n) {
  fac[0] = inv[0] = 1;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    fac[i] = (long long)fac[i - 1] * i % 998244353;
    inv[i] = fastPow(fac[i], 998244353 - 2);
  }
}
int C(int n, int m) {
  if (n < m) return 0;
  return (long long)fac[n] * inv[m] % 998244353 * inv[n - m] % 998244353;
}
void fmain(int tid) {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d%d", l + i, r + i);
  for (int(i) = 0; (i) < (int)(m); (i)++) scanf("%d%d", a + i, b + i);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    ps[l[i]]++;
    ps[r[i] + 1]--;
  }
  for (int(i) = 1; (i) <= (int)(n); (i)++) ps[i] += ps[i - 1];
  initfac(n);
  for (int x = 1; x <= n; x++) {
    if (ps[x] >= x)
      for (int k = 0; k <= m + m; k++) {
        if (k > ps[x] || k > x) break;
        addmod(dp[k][x], C(ps[x] - k, x - k));
      }
  }
  for (int k = 0; k <= m + m; k++)
    for (int x = 1; x <= n; x++) addmod(dp[k][x], dp[k][x - 1]);
  int Ans = 0;
  for (int s = 0; s < (1 << m); s++) {
    set<int> id;
    int tar = 1;
    for (int(j) = 0; (j) < (int)(m); (j)++)
      if (s & (1 << j)) {
        id.insert(a[j]);
        id.insert(b[j]);
        tar *= -1;
      }
    int N = id.size();
    int L = 1, R = n;
    for (int z : id) {
      maxtt(L, l[z]);
      mintt(R, r[z]);
    }
    if (R < L) continue;
    int tmp = dp[N][R];
    addmod(tmp, 998244353 - dp[N][L - 1]);
    if (tar == 1)
      addmod(Ans, tmp);
    else
      addmod(Ans, 998244353 - tmp);
  }
  printf("%d\n", Ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}