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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
long long rnd() {
  unsigned long long ans = 0;
  for (int i = (int)(0); i <= (int)(4); i++) ans = ans << 15 ^ rand();
  return ans % ((unsigned long long)1 << 63);
}
const int N = 300005, mod = 998244353, K = 42;
long long s[K][N], fac[N], ni[N], ans;
int n, m, vis[N], x[K / 2], y[K / 2], l[N], r[N], f[N];
long long ksm(long long a, int b) {
  int ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
  }
  return ans;
}
long long c(int a, int b) {
  return a >= b && b >= 0 ? fac[a] * ni[b] % mod * ni[a - b] % mod : 0;
}
void dfs(int p, int dq, int zt, int L, int R) {
  if (L > R) return;
  if (p > m) {
    ans = (ans + zt * (s[dq][R] - s[dq][L - 1])) % mod;
    return;
  }
  dfs(p + 1, dq, zt, L, R);
  if (!vis[x[p]]) dq++;
  vis[x[p]]++;
  if (!vis[y[p]]) dq++;
  vis[y[p]]++;
  dfs(p + 1, dq, -zt, max(L, max(l[x[p]], l[y[p]])),
      min(R, min(r[x[p]], r[y[p]])));
  vis[x[p]]--;
  vis[y[p]]--;
}
int main() {
  n = read();
  m = read();
  for (int i = (int)(fac[0] = 1); i <= (int)(n); i++)
    fac[i] = fac[i - 1] * i % mod;
  ni[n] = ksm(fac[n], mod - 2);
  for (int i = (int)(n); i >= (int)(1); i--) ni[i - 1] = ni[i] * i % mod;
  for (int i = (int)(1); i <= (int)(n); i++) {
    l[i] = read();
    r[i] = read();
    f[l[i]]++;
    f[r[i] + 1]--;
  }
  for (int i = (int)(1); i <= (int)(n); i++) f[i] += f[i - 1];
  for (int o = (int)(0); o <= (int)(40); o++) {
    for (int i = (int)(1); i <= (int)(n); i++)
      s[o][i] = (s[o][i - 1] + c(f[i] - o, i - o)) % mod;
  }
  for (int i = (int)(1); i <= (int)(m); i++) {
    x[i] = read();
    y[i] = read();
  }
  dfs(1, 0, 1, 1, n);
  cout << (ans + mod) % mod << endl;
}