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;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
int sz(const T &a) {
  return int(a.size());
}
const int MAXN = 3e5 + 2;
const ll mod = 998244353;
ll fix(ll a) { return ((a % mod) + mod) % mod; }
ll fp(ll a, ll b) {
  ll ans = 1;
  for (ll i = 1; i <= b; i <<= 1) {
    if (b & i) ans = ans * a % mod;
    a = a * a % mod;
  }
  return ans;
}
ll fact[MAXN], inv[MAXN];
ll choose(int n, int r) {
  if (n < r || r < 0) return 0;
  return (fact[n] * inv[r] % mod) * inv[n - r] % mod;
}
pii arr[MAXN];
int psa[MAXN];
ll ways[41][MAXN];
pii hate[21];
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i].first >> arr[i].second;
    psa[arr[i].first]++, psa[arr[i].second + 1]--;
  }
  fact[0] = 1, inv[0] = 1;
  for (ll i = 1; i <= n; i++) {
    fact[i] = fact[i - 1] * i % mod;
    inv[i] = fp(fact[i], mod - 2);
  }
  set<int> peeps;
  for (int i = 0; i < m; i++) {
    cin >> hate[i].first >> hate[i].second;
    peeps.insert(hate[i].first), peeps.insert(hate[i].second);
  }
  for (int i = 1; i <= n; i++) psa[i] += psa[i - 1];
  for (int i = 0; i <= sz(peeps); i++) {
    for (int j = 1; j <= n; j++) {
      ways[i][j] = fix(ways[i][j - 1] + choose(psa[j] - i, j - i));
    }
  }
  ll ans = 0;
  for (int i = 0; i < (1 << m); i++) {
    set<int> te;
    for (int j = 0; j < m; j++)
      if (i & (1 << j)) te.insert(hate[j].first), te.insert(hate[j].second);
    int l = 1, r = n;
    for (auto x : te) l = max(l, arr[x].first), r = min(r, arr[x].second);
    if (l <= r)
      ans = fix(ans + fix(ways[sz(te)][r] - ways[sz(te)][l - 1]) *
                          ll(__builtin_popcount(i) % 2 ? -1 : 1));
  }
  printf("%lli\n", ans);
  return 0;
}