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 long long mod = 998244353;
const int maxn = 300009;
long long fac[maxn], invfac[maxn], A[33], B[33], in[maxn], idx[maxn];
vector<int> L[maxn], R[maxn];
int n, m;
long long mpw(long long a, long long b) {
  long long c = 1;
  while (b) {
    if (b & 1ll) c = c * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return c;
}
void init() {
  fac[0] = 1;
  for (int i = 1; i < maxn; ++i) fac[i] = fac[i - 1] * i % mod;
  invfac[maxn - 1] = mpw(fac[maxn - 1], mod - 2);
  for (int i = maxn - 2; i >= 0; --i) invfac[i] = invfac[i + 1] * (i + 1) % mod;
}
long long C(int a, int b) {
  if (a < b || b < 0) return 0;
  return fac[a] * invfac[b] % mod * invfac[a - b] % mod;
};
int main() {
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  cin >> n >> m;
  vector<std::vector<int>> add(n + 1), del(n + 1);
  for (int i = 1; i <= n; ++i) {
    int l, r;
    cin >> l >> r;
    L[l].push_back(i);
    R[r].push_back(i);
    add[l].push_back(i - 1);
    del[r].push_back(i - 1);
  }
  int idxtot = 0, cc = 0;
  memset(idx, -1, sizeof idx);
  std::vector<int> a(m), b(m);
  std::vector<int> id(n, -1);
  for (int i = 0; i < m; ++i) {
    cin >> A[i] >> B[i];
    a[i] = A[i] - 1;
    b[i] = B[i] - 1;
    if (idx[A[i]] == -1) idx[A[i]] = idxtot++;
    if (idx[B[i]] == -1) idx[B[i]] = idxtot++;
    if (id[a[i]] == -1) id[a[i]] = cc++;
    if (id[b[i]] == -1) id[b[i]] = cc++;
  }
  init();
  long long premask = 0, tot = 0, masktot = 0, curmask = 0, res = 0;
  vector<long long> cnt(m + 1);
  cnt[0] = 1;
  std::vector<int> ways(m + 1);
  std::vector<int> in2(n);
  ways[0] = 1;
  long long mask = 0;
  int tot2 = 0, tp = 0;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j : L[i]) {
      in[j] = 1;
      if (idx[j] == -1)
        tot++;
      else
        masktot++;
    }
    for (auto x : add[i]) {
      in2[x] = 1;
      ++(id[x] == -1 ? tot2 : tp);
    }
    curmask = 0;
    for (int j = 0; j < m; ++j) {
      if (in[A[j]]) curmask |= 1ll << idx[A[j]];
      if (in[B[j]]) curmask |= 1ll << idx[B[j]];
    }
    long long nMask = 0;
    for (int j = 0; j < m; ++j) {
      if (in2[a[j]]) nMask |= 1ll << id[a[j]];
      if (in2[b[j]]) nMask |= 1ll << id[b[j]];
    }
    if (nMask != curmask) {
      cout << 1 << '\n';
      return 0;
    }
    if (mask != premask) {
      cout << 3;
      return 0;
    }
    if (tp != masktot) {
      cout << 4;
      return 0;
    }
    if (nMask != mask) {
      mask = nMask;
      std::fill(ways.begin(), ways.end(), 0);
      std::function<void(int, int64_t, int)> dfs1 = [&](int x, int64_t s,
                                                        int coef) {
        if (x == m) {
          int p = __builtin_popcountll(s);
          for (int j = 0; j <= m; ++j)
            ways[j] = (ways[j] + 1ll * coef * C(tp - p, j - p)) % mod;
          return;
        }
        if (in2[a[x]] && in2[b[x]])
          dfs1(x + 1, s | 1ll << id[a[x]] | 1ll << id[b[x]], mod - coef);
        dfs1(x + 1, s, coef);
      };
      dfs1(0, 0, 1);
    }
    if (premask != curmask) {
      for (int j = 0; j <= m; ++j) cnt[j] = 0;
      std::function<void(int, int64_t, int)> dfs1 = [&](int x, int64_t s,
                                                        int coef) {
        if (x == m) {
          int p = __builtin_popcountll(s);
          for (int j = 0; j <= m; ++j)
            cnt[j] = (cnt[j] + 1ll * coef * C(tp - p, j - p)) % mod;
          return;
        }
        if (in[A[x]] && in[B[x]])
          dfs1(x + 1, s | 1ll << idx[A[x]] | 1ll << idx[B[x]], mod - coef);
        dfs1(x + 1, s, coef);
      };
      dfs1(0, 0, 1);
    }
    premask = curmask;
    for (int j = 0; j <= m; ++j)
      if (cnt[j] != ways[j]) {
        for (int x = 0; x < n; ++x) assert(in[x + 1] == in2[x]);
        cout << 2;
        return 0;
      }
    for (int j = 0; j <= m; ++j)
      ans = (ans + 1ll * ways[j] * C(tot2, i - j)) % mod;
    for (int j = 0; j <= m; ++j)
      res = (res + cnt[j] * C(tot, i - j) % mod) % mod;
    assert(ans == res);
    for (int j : R[i]) {
      in[j] = 0;
      if (idx[j] == -1)
        tot--;
      else
        masktot--;
    }
    for (auto x : del[i]) {
      in2[x] = 0;
      --(id[x] == -1 ? tot2 : tp);
    }
  }
  cout << res;
  return 0;
}