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;
const int N = 3e5 + 5, M = 45;
const long long mod = 998244353;
long long fac[N], inv[N], sum[M][N];
struct node {
  int l, r;
} p[N], lim[M];
int num[N], vis[N];
long long qpow(long long a, long long b) {
  long long ans = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) ans = ans * a % mod;
  return ans;
}
long long C(int n, int m) {
  if (n < m || m < 0) return 0;
  return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
  fac[0] = inv[0] = 1;
  for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % mod;
  inv[N - 1] = qpow(fac[N - 1], mod - 2);
  for (int i = N - 2; ~i; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &p[i].l, &p[i].r), num[p[i].l]++, num[p[i].r + 1]--;
  for (int i = 1; i <= n; i++) num[i] += num[i - 1];
  for (int i = 0; i < m; i++) scanf("%d%d", &lim[i].l, &lim[i].r);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (i <= num[i]) ans = (ans + C(num[i], i)) % mod;
  for (int i = 0; i < M; i++)
    for (int j = 1; j <= n; j++)
      sum[i][j] = (sum[i][j - 1] + C(num[j] - i, j - i)) % mod;
  for (int i = 1; i < (1 << m); i++) {
    int l = 1, r = n, tot = 0;
    for (int j = 0; j < m; j++) {
      if (!(i & (1 << j))) continue;
      int p1 = lim[j].l, p2 = lim[j].r;
      l = max(l, max(p[p1].l, p[p2].l)), r = min(r, min(p[p1].r, p[p2].r));
      if (!vis[p1]) tot++;
      if (!vis[p2]) tot++;
      vis[p1] = vis[p2] = 1;
    }
    for (int j = 0; j < m; j++) {
      if (!(i & (1 << j))) continue;
      int p1 = lim[j].l, p2 = lim[j].r;
      vis[p1] = vis[p2] = 0;
    }
    if (l > r) continue;
    int add = __builtin_popcount(i);
    ans = (ans + (sum[tot][r] - sum[tot][l - 1] + mod) * (add % 2 ? -1 : 1) +
           mod * 5) %
          mod;
  }
  printf("%lld\n", ans);
  return 0;
}