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, MOD = 998244353, M = 41;
int L[N], R[N], ways[M][N], vis[N], vid;
long long fact[N], fact_inv[N];
int add(int a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
  return a;
}
long long mul(long long a, long long b) { return a * b % MOD; }
long long power(long long a, long long b) {
  if (!b) return 1;
  long long r = power(a, b / 2);
  r = mul(r, r);
  if (b & 1) return mul(r, a);
  return r;
}
long long mod_inv(long long x) { return power(x, MOD - 2); }
long long nCr(long long n, long long r) {
  if (!r) return 1;
  if (r > n || r < 0) return 0;
  return mul(fact[n], mul(fact_inv[n - r], fact_inv[r]));
}
void pre() {
  fact[0] = fact_inv[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
    fact_inv[i] = mod_inv(fact[i]);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  pre();
  int n, m;
  cin >> n >> m;
  vector<int> f(n + 2);
  for (int i = 0; i < n; i++) {
    cin >> L[i] >> R[i];
    f[L[i]]++;
    f[R[i] + 1]--;
  }
  for (int i = 1; i < f.size(); i++) f[i] += f[i - 1];
  for (int j = 0; j < M; j++)
    for (int i = 1; i <= n; i++)
      ways[j][i] = add(ways[j][i - 1], nCr(f[i] - j, i - j));
  auto get = [&](int j, int l, int r) {
    if (r < l) return 0;
    return add(ways[j][r], -ways[j][l - 1]);
  };
  vector<array<int, 2> > hate(m);
  for (auto &p : hate) {
    cin >> p[0] >> p[1];
    p[0]--;
    p[1]--;
  }
  int ans = 0;
  for (int msk = 0; msk < (1 << m); msk++) {
    ++vid;
    int l = 1, r = n, uni = 0, ones = 0;
    for (int i = 0; i < m; i++) {
      if (msk & (1 << i)) {
        ones++;
        int f = hate[i][0], s = hate[i][1];
        l = max(l, L[f]);
        r = min(r, R[f]);
        l = max(l, L[s]);
        r = min(r, R[s]);
        if (vis[f] != vid) {
          vis[f] = vid;
          uni++;
        }
        if (vis[s] != vid) {
          vis[s] = vid;
          uni++;
        }
      }
    }
    if (ones & 1)
      ans = add(ans, -get(uni, l, r));
    else
      ans = add(ans, get(uni, l, r));
  }
  cout << ans;
}