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>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
const ll root = 62;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll binpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
ll modInv(ll a) { return binpow(a, MOD - 2); }
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 300001;
pair<int, int> arr[mxN];
pair<int, int> edges[mxN];
int n, m;
ll fact[mxN];
ll ifact[mxN];
ll nCr(int n, int r) {
  if (n < 0 || r < 0) return 0;
  if (r > n) return 0;
  return (((fact[n] * ifact[n - r]) % MOD) * ifact[r]) % MOD;
}
int st[mxN];
int ed[mxN];
ll psum[mxN][41];
int main() {
  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m;
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = (1); i < (mxN); ++i) {
    fact[i] = (fact[i - 1] * i) % MOD;
    ifact[i] = (ifact[i - 1] * modInv(i)) % MOD;
  }
  for (int i = (0); i < (n); ++i) {
    cin >> arr[i].first >> arr[i].second;
    st[arr[i].first]++;
    ed[arr[i].second]++;
  }
  for (int i = (0); i < (m); ++i) {
    cin >> edges[i].first >> edges[i].second;
    edges[i].first--;
    edges[i].second--;
  }
  int cnt = 0;
  for (int i = (1); i < (n + 1); ++i) {
    cnt += st[i];
    for (int j = (0); j < (41); ++j) {
      psum[i][j] = (psum[i - 1][j] + nCr(cnt - j, i - j)) % MOD;
    }
    cnt -= ed[i];
  }
  ll ans = 0;
  for (int msk = (0); msk < (1 << m); ++msk) {
    int left = 1;
    int right = n;
    set<int> stt;
    for (int i = (0); i < (m); ++i) {
      if (msk & (1 << i)) {
        stt.insert(edges[i].first);
        stt.insert(edges[i].second);
        left = max(left, arr[edges[i].first].first);
        right = min(right, arr[edges[i].first].second);
        left = max(left, arr[edges[i].second].first);
        right = min(right, arr[edges[i].second].second);
      }
    }
    if (right < left) continue;
    int num = __builtin_popcount(msk);
    cnt = stt.size();
    if (num & 1) {
      ans = (ans - (psum[right][cnt] - psum[left - 1][cnt] + MOD) + 2 * MOD) %
            MOD;
    } else {
      ans = (ans + (psum[right][cnt] - psum[left - 1][cnt] + MOD)) % MOD;
    }
  }
  cout << ans << "\n";
  return 0;
}