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;
template <typename T>
inline T abs(T t) {
  return t < 0 ? -t : t;
}
const long long modn = 998244353;
inline long long mod(long long x) { return x % modn; }
const int MAXN = 312345;
int n, m, k;
pair<int, int> s[MAXN];
long long fat[MAXN], inv[MAXN];
long long expo(long long base, long long e) {
  if (e == 0) return 1;
  long long ans = expo(base, e / 2);
  ans = mod(ans * ans);
  if (e & 1) ans = mod(ans * base);
  return ans;
}
int mrk[MAXN];
long long ch(long long x, long long y) {
  return mod(fat[x] * mod(inv[y] * inv[x - y]));
}
vector<int> adj[MAXN];
int ev[MAXN];
long long chs[MAXN][42];
long long acc[MAXN][42];
int main() {
  scanf("%d%d", &n, &m);
  fat[0] = 1;
  for (long long a = 1; a <= n; a++) fat[a] = mod(fat[a - 1] * a);
  inv[n] = expo(fat[n], modn - 2);
  for (long long a = n - 1; a >= 0; a--) inv[a] = mod(inv[a + 1] * (a + 1));
  assert(inv[0] == 1);
  for (int a = 0; a < n; a++) scanf("%d%d", &s[a].first, &s[a].second);
  vector<pair<int, int> > ar(m);
  for (int a = 0; a < m; a++) {
    int i, j;
    scanf("%d%d", &i, &j);
    i--;
    j--;
    ar[a] = {i, j};
    adj[i].push_back(j);
    adj[j].push_back(i);
  }
  long long ans = 0;
  memset(ev, 0, sizeof(ev));
  for (int a = 0; a < n; a++) {
    ev[s[a].first]++;
    ev[s[a].second + 1]--;
  }
  int p = 0;
  for (int np = 1; np <= n; np++) {
    p += ev[np];
    for (int k = 0; k <= 2 * m; k++) {
      if (p < np || np - k < 0)
        chs[np][k] = 0;
      else
        chs[np][k] = ch(p - k, np - k);
      acc[np][k] = acc[np - 1][k] + chs[np][k];
    }
  }
  for (int bm = 0; bm < (1 << m); bm++) {
    int L = 1, R = n;
    set<int> v;
    for (int i = 0; i < m; i++) {
      if ((bm >> i) & 1) {
        int u = ar[i].first;
        int uu = ar[i].second;
        L = max(L, max(s[u].first, s[uu].first));
        R = min(R, min(s[uu].second, s[u].second));
        v.insert(u);
        v.insert(uu);
      }
    }
    if (L > R) continue;
    int sign = (__builtin_popcount(bm) & 1 ? -1 : 1);
    int sz = v.size();
    ans = mod(ans + sign * (acc[R][sz] - acc[L - 1][sz]));
  }
  ans = mod(ans + modn);
  printf("%lld\n", ans);
}