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")
using namespace std;
template <class T>
void print(T& x) {
  cout << x;
}
template <class T, class U>
void print(pair<T, U>& p) {
  cout << "(";
  print(p.first);
  cout << ", ";
  print(p.second);
  cout << ")";
}
template <class T>
void print(vector<T>& v) {
  cout << "{";
  if (((int)(v).size())) print(v[0]);
  for (int i = 1; i < ((int)(v).size()); i++) cout << ", ", print(v[i]);
  cout << "}\n";
}
void printBin(int x) {
  bitset<10> b(x);
  cout << b << endl;
}
const int n = 4e5;
const long long MOD = 998244353;
int N, Ms;
int L[n], R[n];
vector<int> G[50];
vector<int> S[n], E[n];
int M[n];
int dp[n];
long long f[n], f2[n];
vector<long long> res;
int asz;
long long bin2[50][50];
long long bin(int n, int k) { return f[n] * f2[k] % MOD * f2[n - k] % MOD; }
void calcRes(long long act, long long fst) {
  for (int i = 0; i < ((int)(res).size()); i++) {
    res[i] = 0;
  }
  fst &= act;
  for (long long m = fst; m >= 0; m = (m - 1) & fst) {
    long long ri = act & (~fst);
    int cnt = 0, cnt2 = 0;
    for (int i = 0; i < asz; i++) {
      if (m & (1ll << i)) {
        for (int x : G[i]) {
          if (m & (1ll << x)) goto NXT;
          ri &= ~(1ll << x);
        }
      }
    }
    cnt = __builtin_popcountll(ri);
    cnt2 = __builtin_popcountll(m);
    for (int i = 0; i <= cnt; i++) {
      res[cnt2 + i] += bin2[cnt][i];
    }
  NXT:;
    if (m == 0) break;
  }
  for (int i = 0; i < ((int)(res).size()); i++) res[i] %= MOD;
}
long long inv[n];
void precompute_inverse(long long n, long long mod) {
  inv[1] = 1;
  for (int i = 2; i <= n; i++)
    inv[i] = (mod - (mod / i) * 1LL * inv[mod % i] % mod) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Ms;
  for (int i = 0; i < N; i++) {
    cin >> L[i] >> R[i];
    M[i] = -1;
  }
  precompute_inverse(N, MOD);
  f[0] = f2[0] = 1;
  for (long long i = 1; i <= N; i++) {
    f[i] = f[i - 1] * i % MOD;
    f2[i] = f2[i - 1] * inv[i] % MOD;
  }
  vector<int> A;
  vector<pair<int, int> > P;
  for (int i = 0; i < Ms; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    A.push_back(a);
    A.push_back(b);
    P.emplace_back(a, b);
  }
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  asz = ((int)(A).size());
  for (int i = 0; i < ((int)(A).size()); i++) {
    M[A[i]] = i;
    S[L[A[i]]].push_back(M[A[i]]);
    E[R[A[i]] + 1].push_back(M[A[i]]);
  }
  long long fst = 0;
  for (auto [a, b] : P) {
    fst |= 1ll << M[a];
    G[M[a]].push_back(M[b]);
    G[M[b]].push_back(M[a]);
  }
  for (int i = 0; i < N; i++) {
    if (M[i] == -1) {
      dp[L[i]]++;
      dp[R[i] + 1]--;
    }
  }
  long long act = 0;
  res.resize(42);
  long long erg = 0;
  for (int i = 0; i <= 45; i++) {
    for (int j = 0; j <= i; j++) bin2[i][j] = bin(i, j);
  }
  calcRes(0, 0);
  for (int i = 1; i <= N; i++) {
    dp[i] += dp[i - 1];
    bool ch = false;
    for (int ind : S[i]) {
      act |= 1ll << ind;
      ch = true;
    }
    for (int ind : E[i]) {
      act ^= 1ll << ind;
      ch = true;
    }
    if (ch) calcRes(act, fst);
    for (int j = 0; j <= min(((int)(res).size()) - 1, i); j++) {
      if (dp[i] >= i - j) (erg += bin(dp[i], i - j) * res[j]) %= MOD;
    }
  }
  cout << erg << endl;
}