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 P = 998244353;
const int N = 3e5 + 5;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m, k, x, y;
int l[N], r[N], a[N], b[N], cnt[N], tot[N];
int tr[N], sum[41][N];
long long fac[N], ifac[N];
void add(int p, int x) {
  for (; p <= n + 1; p += p & -p) tr[p] += x;
}
int get(int p) {
  int res = 0;
  for (; p; p -= p & -p) res += tr[p];
  return res;
}
int pw(long long x, int n) {
  long long res = 1;
  for (; n; n >>= 1, x = x * x % P)
    if (n & 1) res = res * x % P;
  return res;
}
inline int C(int a, int b) {
  return a < 0 || b < 0 || b > a ? 0 : fac[a] * ifac[b] % P * ifac[a - b] % P;
}
int main() {
  scanf("%d%d", &n, &m);
  fac[0] = 1;
  for (int i = (1); i <= (n); ++i) fac[i] = fac[i - 1] * i % P;
  ifac[n] = pw(fac[n], P - 2);
  for (int i = (n - 1); i >= (0); --i) ifac[i] = ifac[i + 1] * (i + 1) % P;
  for (int i = (1); i <= (n); ++i) scanf("%d%d", l + i, r + i);
  for (int i = (1); i <= (m); ++i) scanf("%d%d", a + i, b + i);
  memset(tr, 0, sizeof tr);
  for (int i = (1); i <= (n); ++i) add(l[i], 1), add(r[i] + 1, -1);
  for (int i = (1); i <= (n); ++i) cnt[i] = get(i);
  memset(sum, 0, sizeof sum);
  for (int k = (0); k <= (m << 1); ++k)
    for (int i = (1); i <= (n); ++i)
      sum[k][i] = (sum[k][i - 1] + C(cnt[i] - k, i - k)) % P;
  int ans = 0;
  for (int mask = (0); mask <= ((1 << m) - 1); ++mask) {
    int x = __builtin_popcount(mask), k = 0, l0 = 1, r0 = n;
    for (int i = (1); i <= (m); ++i)
      if (mask >> i - 1 & 1) {
        k += !tot[a[i]], tot[a[i]]++, k += !tot[b[i]], tot[b[i]]++;
        l0 = max(l0, max(l[a[i]], l[b[i]]));
        r0 = min(r0, min(r[a[i]], r[b[i]]));
      }
    for (int i = (1); i <= (m); ++i)
      if (mask >> i - 1 & 1) tot[a[i]]--, tot[b[i]]--;
    if (l0 > r0) continue;
    ans = (ans + (x % 2 ? -1 : 1) * (sum[k][r0] - sum[k][l0 - 1])) % P;
  }
  cout << (ans + P) % P << endl;
  return 0;
}