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 iinf = 0x3f3f3f3f;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const int N = 3e5, M = 20;
const int mod = 998244353;
int n, m, ln[N], rn[N], a[M], b[M];
int bar[N], bc[1 << M], cn[N + 1], sm[M << 1][N + 1], ans = 0;
int c[N + 1], ic[N + 1];
void cinit() {
  ic[0] = ic[1] = c[0] = 1;
  for (int i = (2), I = (n + 1); i < I; i++)
    ic[i] = 1ll * (mod - mod / i) * ic[mod % i] % mod;
  for (int i = (1), I = (n + 1); i < I; i++)
    c[i] = 1ll * i * c[i - 1] % mod, ic[i] = 1ll * ic[i - 1] * ic[i] % mod;
}
int C(int a, int b) {
  if (b > a || b < 0 || a < 0) return 0;
  return 1ll * c[a] * ic[b] % mod * ic[a - b] % mod;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m, cinit();
  for (int i = (0), I = (n); i < I; i++) {
    cin >> ln[i] >> rn[i];
    cn[ln[i]]++, cn[rn[i] + 1]--;
  }
  for (int i = (0), I = (m); i < I; i++) cin >> a[i] >> b[i], --a[i], --b[i];
  for (int i = (1), I = ((1 << m)); i < I; i++) bc[i] = bc[i >> 1] + (i & 1);
  for (int i = (1), I = (n + 1); i < I; i++) cn[i] += cn[i - 1];
  for (int t = (0), I = ((m << 1) + 1); t < I; t++)
    for (int i = (1), I = (n + 1); i < I; i++)
      sm[t][i] = (sm[t][i - 1] + C(cn[i] - t, i - t)) % mod;
  for (int s = (0), I = ((1 << m)); s < I; s++) {
    int l = 1, r = n, cnt = 0;
    for (int i = (0), I = (m); i < I; i++)
      if (s >> i & 1) {
        if (!bar[a[i]]++) l = max(l, ln[a[i]]), r = min(r, rn[a[i]]), cnt++;
        if (!bar[b[i]]++) l = max(l, ln[b[i]]), r = min(r, rn[b[i]]), cnt++;
      }
    for (int i = (0), I = (m); i < I; i++)
      if (s >> i & 1) --bar[a[i]], --bar[b[i]];
    if (l > r) continue;
    int sum = (sm[cnt][r] - sm[cnt][l - 1] + mod) % mod;
    if (bc[s] & 1)
      (ans += mod - sum) %= mod;
    else
      (ans += sum) %= mod;
  }
  cout << ans << '\n';
  return 0;
}