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>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
template <typename T>
vector<T> &operator<<(vector<T> &__container, T x) {
  __container.push_back(x);
  return __container;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> &__container) {
  for (T _ : __container) out << _ << ' ';
  return out;
}
const int MAXN = 3e5 + 7;
const int MOD = 998244353;
int n, m, root[MAXN], sz[MAXN], l[MAXN], r[MAXN], cnt[MAXN];
int fac[MAXN], inv[MAXN], rfac[MAXN];
vector<vector<int> > comp;
vector<vector<vector<int> > > f;
int compID;
map<int, int> msk;
set<pair<int, int> > S;
int findx(int x) { return x == root[x] ? x : root[x] = findx(root[x]); }
int C(int n, int m) {
  return n < m ? 0 : 1ll * fac[n] * rfac[m] % MOD * rfac[n - m] % MOD;
}
void preprocess(int id) {
  f[id] = vector<vector<int> >(comp[id].size() + 1,
                               vector<int>(1 << comp[id].size(), 0));
  auto &dp = f[id];
  for (int i = 0; i < (1 << comp[id].size()); i++) {
    bool ok = true;
    for (int bit1 = 0; bit1 < comp[id].size(); bit1++) {
      if (!(i >> bit1 & 1)) continue;
      for (int bit2 = bit1 + 1; bit2 < comp[id].size(); bit2++) {
        if (!(i >> bit2 & 1)) continue;
        int x = comp[id][bit1], y = comp[id][bit2];
        if (S.count(make_pair(min(x, y), max(x, y)))) ok = false;
      }
    }
    if (ok) dp[__builtin_popcount(i)][i] = 1;
  }
  for (int k = 0; k <= (int)comp[id].size(); k++)
    for (int i = 0; i < (int)comp[id].size(); i++)
      for (int msk = 0; msk < (1 << comp[id].size()); msk++)
        if (msk >> i & 1) dp[k][msk] += dp[k][msk ^ (1 << i)];
}
void solve() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) scanf("%d", &l[i]), scanf("%d", &r[i]);
  for (int i = 1; i <= n; i++) root[i] = i, sz[i] = 1;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    S.insert(make_pair(min(u, v), max(u, v)));
    if (findx(u) == findx(v)) continue;
    int fu = findx(u), fv = findx(v);
    root[fu] = fv;
    sz[fv] += sz[fu];
  }
  for (int i = 1; i <= n; i++) {
    if (sz[findx(i)] == 1) continue;
    int fx = findx(i);
    if (!msk.count(fx)) msk[fx] = compID++, comp << vector<int>();
    comp[msk[fx]] << i;
  }
  f.resize(compID);
  for (int i = 0; i < compID; i++) preprocess(i);
  for (int i = 1; i <= n; i++)
    if (sz[findx(i)] == 1) cnt[l[i]]++, cnt[r[i] + 1]--;
  for (int i = 1; i <= n; i++) cnt[i] += cnt[i - 1];
  int ret = 0, tot = 0;
  for (int i = 1; i <= n; i++)
    if (findx(i) == i and sz[i] != 1) tot += sz[i];
  for (int i = 1; i <= n; i++) {
    int top = min(tot, i);
    vector<vector<int> > g(2, vector<int>(top + 1, 0));
    int tag = 0;
    g[0][0] = 1;
    for (int j = 0; j < compID; j++) {
      tag ^= 1;
      fill(g[tag].begin(), g[tag].end(), 0);
      int msk = 0;
      for (int k = 0; k < (int)comp[j].size(); k++)
        if (l[comp[j][k]] <= i and i <= r[comp[j][k]]) msk |= (1 << k);
      for (int k = 0; k <= min(top, __builtin_popcount(msk)); k++)
        for (int p = k; p <= top; p++)
          g[tag][p] =
              (g[tag][p] + 1ll * g[tag ^ 1][p - k] * f[j][k][msk]) % MOD;
    }
    for (int j = 0; j <= top; j++)
      ret = (ret + 1ll * g[tag][j] * C(cnt[i], i - j)) % MOD;
  }
  cout << ret << "\n";
}
int main() {
  fac[0] = rfac[0] = inv[1] = 1;
  for (int i = 1; i < MAXN; i++) fac[i] = 1ll * fac[i - 1] * i % MOD;
  for (int i = 2; i < MAXN; i++)
    inv[i] = 1ll * (MOD - MOD / i) * inv[MOD % i] % MOD;
  for (int i = 1; i < MAXN; i++) rfac[i] = 1ll * rfac[i - 1] * inv[i] % MOD;
  solve();
  return 0;
}