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 maxm = 3e5 + 5;
const long long mod = 998244353;
long long fac[maxm], inv[maxm];
long long l[maxm], r[maxm];
pair<long long, long long> p[25];
long long sum[maxm][45];
long long num[maxm];
long long n, m;
long long ppow(long long a, long long b, long long mod) {
  long long ans = 1 % mod;
  a %= mod;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
void init() {
  fac[0] = 1;
  for (long long i = 1; i < maxm; i++) fac[i] = fac[i - 1] * i % mod;
  inv[maxm - 1] = ppow(fac[maxm - 1], mod - 2, mod);
  for (long long i = maxm - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
long long cal(long long x) {
  long long ans = 0;
  while (x) {
    ans++;
    x &= (x - 1);
  }
  return ans;
}
long long C(long long n, long long m) {
  if (m < 0 || m > n) return 0;
  return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
signed main() {
  ios::sync_with_stdio(0);
  init();
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
  }
  for (long long i = 0; i < m; i++) {
    cin >> p[i].first >> p[i].second;
  }
  for (long long i = 1; i <= n; i++) {
    num[l[i]]++;
    num[r[i] + 1]--;
  }
  for (long long i = 1; i <= n; i++) {
    num[i] += num[i - 1];
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= m * 2; j++) {
      sum[i][j] = (sum[i - 1][j] + C(num[i] - j, i - j)) % mod;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < (1 << m); i++) {
    set<long long> s;
    for (long long j = 0; j < m; j++) {
      if (i >> j & 1) {
        s.insert(p[j].first);
        s.insert(p[j].second);
      }
    }
    long long tot = s.size();
    long long L = 1, R = n;
    for (auto x : s) {
      L = max(L, l[x]);
      R = min(R, r[x]);
    }
    if (L > R) continue;
    long long t = (sum[R][tot] - sum[L - 1][tot] + mod) % mod;
    if (cal(i) & 1) {
      ans = (ans - t + mod) % mod;
    } else {
      ans = (ans + t) % mod;
    }
  }
  cout << ans << endl;
  return 0;
}