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 N = 3e5 + 10, size = 1 << 20, mod = 998244353, inf = 2e9;
template <class o>
void qr(o &x) {
  char c = getchar();
  x = 0;
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  x *= f;
}
template <class o>
void qw(o x) {
  if (x / 10) qw(x / 10);
  putchar(x % 10 + '0');
}
template <class o>
void pr1(o x) {
  if (x < 0) x = -x, putchar('-');
  qw(x);
  putchar(' ');
}
template <class o>
void pr2(o x) {
  if (x < 0) x = -x, putchar('-');
  qw(x);
  putchar('\n');
}
int n, m, c[N], l[N], r[N], vis[N], num;
pair<int, int> v[N];
long long jc[N], inv[N], s[N][44], ans;
long long power(long long a, long long b = mod - 2) {
  long long c = 1;
  while (b) {
    if (b & 1) c = c * a % mod;
    b /= 2;
    a = a * a % mod;
  }
  return c;
}
long long C(int x, int y) {
  return x >= y && y >= 0 ? jc[x] * inv[y] % mod * inv[x - y] % mod : 0;
}
long long F(int l, int r, int k) {
  return l > r ? 0 : (s[r][k] - s[l - 1][k]) % mod;
}
int main() {
  qr(n);
  qr(m);
  jc[0] = 1;
  for (int i = 1; i <= n; i++) jc[i] = jc[i - 1] * i % mod;
  inv[n] = power(jc[n]);
  for (int i = n; i; i--) inv[i - 1] = inv[i] * i % mod;
  for (int i = 1; i <= n; i++) qr(l[i]), qr(r[i]), c[l[i]]++, c[r[i] + 1]--;
  for (int i = 1; i <= n; i++) {
    c[i] += c[i - 1];
    ans += C(c[i], i);
    for (int j = 1; j <= 2 * m; j++)
      s[i][j] = (s[i - 1][j] + C(c[i] - j, i - j)) % mod;
  }
  for (int i = 0; i < m; i++) qr(v[i].first), qr(v[i].second);
  for (int i = (1 << m) - 1; i; i--) {
    int L = 1, R = n, cnt = 0, c = 0;
    num++;
    for (int j = 0; j < m; j++)
      if (i >> j & 1) {
        int x = v[j].first, y = v[j].second;
        L = max(L, l[x]);
        R = min(R, r[x]);
        cnt += (vis[x] != num);
        vis[x] = num;
        L = max(L, l[y]);
        R = min(R, r[y]);
        cnt += (vis[y] != num);
        vis[y] = num;
        c++;
      }
    L = max(L, cnt);
    ans += (c & 1 ? -1 : 1) * F(L, R, cnt);
  }
  pr2((ans % mod + mod) % mod);
  return 0;
}