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 long long read() {
  long long f = 1, ans = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  return f * ans;
}
const long long MAXN = 3e5 + 11;
const long long MAXM = 21;
long long S[MAXN], N, L[MAXN], R[MAXN], A[MAXM], B[MAXM], Sum[MAXN][MAXM << 1],
    M;
long long fac[MAXN], ifac[MAXN], inv[MAXN], Num[MAXN], Ans;
long long C(long long a, long long b) {
  if (a < b || a < 0 || b < 0) return 0;
  return fac[a] * ifac[b] % 998244353 * ifac[a - b] % 998244353;
}
long long lowbit(long long x) { return x & -x; }
long long cont(long long x) {
  long long c = 0;
  while (x) {
    c++;
    x -= lowbit(x);
  };
  return c;
}
signed main() {
  N = read(), M = read();
  for (long long i = 1; i <= N; i++)
    L[i] = read(), R[i] = read(), S[L[i]]++, S[R[i] + 1]--;
  for (long long i = 1; i <= M; i++) A[i] = read(), B[i] = read();
  for (long long i = 1; i <= N; i++) S[i] += S[i - 1];
  fac[0] = fac[1] = ifac[0] = ifac[1] = inv[1] = 1;
  for (long long i = 2; i <= N; i++)
    fac[i] = fac[i - 1] * i % 998244353,
    inv[i] = (998244353 - 998244353 / i) * inv[998244353 % i] % 998244353,
    ifac[i] = ifac[i - 1] * inv[i] % 998244353;
  for (long long i = 1; i <= N; i++) {
    for (long long j = 0; j <= 2 * M; j++) {
      Sum[i][j] = Sum[i - 1][j] + C(S[i] - j, i - j);
      Sum[i][j] %= 998244353;
    }
  }
  memset(Num, -1, sizeof(Num));
  for (long long i = 0; i < (1 << M); i++) {
    long long l = 1, r = N;
    long long cc = 0;
    for (long long j = 1; j <= M; j++)
      if (i & (1 << (j - 1))) {
        if (Num[A[j]] != i) Num[A[j]] = i, cc++;
        if (Num[B[j]] != i) Num[B[j]] = i, cc++;
        l = max(l, max(L[A[j]], L[B[j]])), r = min(r, min(R[A[j]], R[B[j]]));
      }
    if (l > r) continue;
    long long pw = ((cont(i) & 1) ? -1 : 1),
              res = (Sum[r][cc] - Sum[l - 1][cc] + 998244353) % 998244353;
    Ans += pw * res;
    Ans = ((Ans % 998244353) + 998244353) % 998244353;
  }
  printf("%lld\n", Ans);
  return 0;
}