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;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
struct printer {
  ~printer() { cerr << endl; }
  template <class c>
  printer& operator,(c x) {
    cerr << boolalpha << x;
    return *this;
  }
  printer& operator,(string x) {
    cerr << x;
    return *this;
  }
  template <class c, class d>
  printer& operator,(pair<c, d> x) {
    return *this, "(", x.first, ", ", x.second, ")";
  }
  template <class... d, template <class...> class c>
  printer& operator,(c<d...> x) {
    return *this, range(begin(x), end(x));
  }
  template <class c>
  printer& operator,(rge<c> x) {
    *this, "[";
    for (auto it = x.b; it != x.e; ++it) *this, (it == x.b ? "" : ", "), *it;
    return *this, "]";
  }
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
const int N = 1e6 + 10;
const int mod = 998244353;
namespace Combi {
int fact[N], inv[N];
int bm(int b, int p, int m) {
  if (p == 0) return 1 % m;
  int t = bm(b, p / 2, m);
  t = (1ll * t * t) % m;
  if (p & 1) return 1ll * t * b % m;
  return t;
}
int C(int n, int r) {
  if (n < 0 or r < 0 or r > n) return 0;
  int ret = 1ll * fact[n] * inv[r] % mod;
  ret = 1ll * ret * inv[n - r] % mod;
  return ret;
}
int no_of_eqns(int var, int sum) { return C(sum + var - 1, var - 1); }
int stirling(int n, int k) {
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    int x = 1ll * C(k, i) * bm(k - i, n, mod) % mod;
    if (i & 1)
      ans -= x;
    else
      ans += x;
    ans %= mod;
    ans += mod;
    ans %= mod;
  }
  ans = 1ll * ans * inv[k] % mod;
  return ans;
}
void init() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = 1ll * fact[i - 1] * i % mod;
  }
  inv[N - 1] = bm(fact[N - 1], mod - 2, mod);
  for (int i = N - 2; i >= 0; i--) {
    inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
  }
}
}  // namespace Combi
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Combi::init();
  int n, m;
  cin >> n >> m;
  vector<int> L(n), R(n);
  vector<vector<int>> st(n + 1), en(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> L[i] >> R[i];
    st[L[i]].push_back(i);
    en[R[i]].push_back(i);
  }
  vector<int> important(n);
  vector<pair<int, int>> conflict;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    conflict.push_back({u, v});
    important[u] = important[v] = true;
  }
  vector<bool> alive(n);
  vector<bool> unq(n);
  vector<int> sz_cnt(2 * m + 1);
  sz_cnt[0] = 1;
  bool change = false;
  int ways = 0;
  int alive_cnt = 0;
  for (int sz = 1; sz <= n; sz++) {
    for (int x : st[sz]) {
      if (important[x]) change = true;
      alive[x] = true;
      alive_cnt++;
    }
    if (change) {
      vector<pair<int, int>> cur_conflict;
      for (auto t : conflict) {
        if (alive[t.first] && alive[t.second]) {
          cur_conflict.push_back(t);
        }
      }
      int sz = cur_conflict.size();
      for (int i = 0; i < sz_cnt.size(); i++) sz_cnt[i] = 0;
      for (int mask = 0; mask < (1 << sz); mask++) {
        int cnt = 0;
        for (int k = 0; k < sz; k++) {
          if ((mask >> k) & 1) {
            int u = cur_conflict[k].first, v = cur_conflict[k].second;
            if (unq[u] == false) cnt++;
            if (unq[v] == false) cnt++;
            unq[u] = unq[v] = true;
          }
        }
        sz_cnt[cnt] += (__builtin_popcount(mask) & 1 ? -1 : +1);
        for (int k = 0; k < sz; k++) {
          if ((mask >> k) & 1) {
            int u = cur_conflict[k].first, v = cur_conflict[k].second;
            unq[u] = unq[v] = false;
          }
        }
      }
      change = false;
    }
    int cur_ways = 0;
    for (int other = 0; other < sz_cnt.size(); other++) {
      int remaining = alive_cnt - other;
      cur_ways += 1ll * sz_cnt[other] * Combi::C(remaining, sz - other) % mod;
      cur_ways %= mod;
    }
    ways += cur_ways;
    ways %= mod;
    for (int x : en[sz]) {
      if (important[x]) change = true;
      alive[x] = false;
      alive_cnt--;
    }
  }
  if (ways < 0) ways += mod;
  cout << ways << endl;
}