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;
using INT = long long;
const int mod = 998244353;
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int l[300100], r[300100], u[300100], v[300100];
int b[300100];
int sum[300100][44], fac[300100], rev[300100];
int L[300100], R[300100];
void pre() {
  fac[0] = 1;
  for (int i = 1; i < 300100; i++) fac[i] = (INT)fac[i - 1] * i % mod;
  rev[300100 - 1] = power(fac[300100 - 1], mod - 2, mod);
  for (int i = 300100 - 2; i >= 0; i--)
    rev[i] = (INT)rev[i + 1] * (i + 1) % mod;
}
int _C(int n, int k) {
  if (n < k) return 0;
  return (INT)fac[n] * rev[k] % mod * rev[n - k] % mod;
}
void add(int u, int x) {
  for (; u < 300100; u += u & -u) b[u] += x;
}
int calc(int u, int ans = 0) {
  for (; u; u -= u & -u) ans += b[u];
  return ans;
}
int solve(int l, int r, int x) {
  int ans = (sum[r][x] - sum[l - 1][x]) % mod;
  ans = (ans + mod) % mod;
  return ans;
}
int main() {
  pre();
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &L[i], &R[i]);
    add(L[i], 1);
    add(R[i] + 1, -1);
  }
  for (int i = 0; i < m; i++) scanf("%d %d", &u[i], &v[i]);
  int mx = (1 << m);
  int nn = 2 * m;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= nn; j++) sum[i][j] = sum[i - 1][j];
    int tot = calc(i);
    for (int j = 0; j <= min(i, nn); j++)
      sum[i][j] = (sum[i][j] + _C(tot - j, i - j)) % mod;
  }
  int ans = 0;
  for (int i = 0; i < mx; i++) {
    int st = 1, ed = n, sg = 1;
    int ct = __builtin_popcount(i);
    if (ct & 1) sg = -1;
    vector<int> vec;
    for (int j = 0; j < m; j++) {
      if ((i & (1 << j))) {
        st = max(st, L[u[j]]);
        st = max(st, L[v[j]]);
        ed = min(ed, R[u[j]]);
        ed = min(ed, R[v[j]]);
        vec.push_back(u[j]);
        vec.push_back(v[j]);
      }
    }
    if (st > ed) continue;
    sort(vec.begin(), vec.end());
    vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
    st = max(st, (int)vec.size());
    if (st > ed) continue;
    ans = (ans + sg * solve(st, ed, vec.size())) % mod;
  }
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}