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 mod = 998244353;
long long read() {
  long long x = 0, f = 1;
  char ch = ' ';
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') f = -1;
  }
  while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
int n, m, tot, b[300005], ok[300005];
long long fac[300005], inv[300005], c[42][300005];
long long ans;
struct AB {
  int l, r;
} d[300005];
pair<int, int> mp[25], a[30];
int g1[300005], g2[300005];
int st;
long long fastpow(long long n, long long m) {
  long long res = 1;
  while (m) {
    if (m & 1) res = res * n % mod;
    n = n * n % mod;
    m >>= 1;
  }
  return res;
}
void build() {
  fac[0] = inv[0] = 1;
  for (int q = 1; q <= 300000; q++) fac[q] = fac[q - 1] * q % mod;
  inv[300000] = fastpow(fac[300000], mod - 2);
  for (int q = 299999; q; q--) inv[q] = inv[q + 1] * (q + 1) % mod;
}
long long C(int y, int x) {
  if (x > y) return 0;
  return fac[y] * inv[x] % mod * inv[y - x] % mod;
}
void he(int &l, int &r, int s, int t) {
  l = max(l, s);
  r = min(r, t);
}
void dfs(int k, int num) {
  if (k == m + 1) {
    int xianzhi = 0, l = 1, r = n;
    for (int i = 1; i <= num; i++) {
      if (!ok[a[i].first]) {
        ok[a[i].first] = 1;
        he(l, r, d[a[i].first].l, d[a[i].first].r);
        xianzhi++;
      }
      if (!ok[a[i].second]) {
        ok[a[i].second] = 1;
        he(l, r, d[a[i].second].l, d[a[i].second].r);
        xianzhi++;
      }
    }
    for (int i = 1; i <= num; i++) {
      ok[a[i].first] = 0;
      ok[a[i].second] = 0;
    }
    if (l > r) return;
    if (num % 2 == 1)
      ans -= c[xianzhi][r] - c[xianzhi][l - 1];
    else
      ans += c[xianzhi][r] - c[xianzhi][l - 1];
    return;
  }
  dfs(k + 1, num);
  a[num + 1] = mp[k];
  dfs(k + 1, num + 1);
}
int main() {
  build();
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    d[i].l = read(), d[i].r = read();
    g1[d[i].l]++;
    g2[d[i].r + 1]++;
  }
  for (int i = 0; i <= 40; i++) {
    st = 0;
    for (int j = 0; j <= n; j++) {
      st += g1[j], st -= g2[j];
      if (j >= i) c[i][j] = (c[i][j - 1] + C(st - i, j - i)) % mod;
    }
  }
  for (int i = 1; i <= m; i++) mp[i].first = read(), mp[i].second = read();
  dfs(1, 0);
  cout << (ans % mod + mod) % mod;
}