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 MAXN = 3e5 + 10, MOD = 998244353;
int f[MAXN], inv[MAXN];
int sum(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
int mul(long long a, long long b) { return a * b % MOD; }
int fpow(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) r = mul(r, a);
    a = mul(a, a);
    b >>= 1;
  }
  return r;
}
int cmb(int n, int k) {
  assert(n >= k && n >= 0 && k >= 0);
  return mul(f[n], mul(inv[k], inv[n - k]));
}
int cm[41][MAXN], n;
int hs[MAXN];
long long pw[MAXN];
pair<int, int> rs[MAXN];
vector<pair<int, int> > ed;
void compute() {
  for (int k = 0, ThxDem = 41; k < ThxDem; ++k) {
    int am = 0;
    for (int i = 1, ThxDem = n + 1; i < ThxDem; ++i) {
      am += hs[i];
      if (am >= k && i >= k && am >= i) cm[k][i] = cmb(am - k, i - k);
      cm[k][i] = sum(cm[k][i], cm[k][i - 1]);
    }
  }
}
int sign(long long x) { return x < 0 ? -1 : 1; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  f[0] = inv[0] = 1;
  for (int i = 1, ThxDem = MAXN; i < ThxDem; ++i)
    f[i] = mul(f[i - 1], i), inv[i] = fpow(f[i], MOD - 2);
  int m;
  cin >> n >> m;
  for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
    int x, y;
    cin >> x >> y;
    rs[i] = {x, y};
    hs[x]++;
    hs[y + 1]--;
  }
  vector<int> bad;
  for (int i = 0, ThxDem = m; i < ThxDem; ++i) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    bad.push_back(x);
    bad.push_back(y);
    ed.push_back({x, y});
  }
  sort(bad.begin(), bad.end());
  bad.erase(unique(bad.begin(), bad.end()), bad.end());
  for (int i = 0, ThxDem = int(bad.size()); i < ThxDem; ++i)
    pw[bad[i]] = 1ll << i;
  compute();
  int ans = 0;
  for (int mk = 1, ThxDem = 1 << m; mk < ThxDem; ++mk) {
    long long wh = 0;
    int lef = 1, rig = n;
    for (int i = 0, ThxDem = m; i < ThxDem; ++i)
      if (mk & (1 << i)) {
        int x = ed[i].first, y = ed[i].second;
        wh |= pw[x];
        wh |= pw[y];
        lef = max(lef, rs[x].first);
        lef = max(lef, rs[y].first);
        rig = min(rig, rs[x].second);
        rig = min(rig, rs[y].second);
      }
    if (lef <= rig) {
      int am = __builtin_popcountll(wh);
      int now = sub(cm[am][rig], cm[am][lef - 1]);
      if (__builtin_popcount(mk) % 2 == 1)
        ans = sum(ans, now);
      else
        ans = sub(ans, now);
    }
  }
  ans = sub(cm[0][n], ans);
  cout << ans << "\n";
}