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 optimize("O2")
using namespace std;
template <typename T>
T& ckmin(T& a, T b) {
  return a = a > b ? b : a;
}
template <typename T>
T& ckmax(T& a, T b) {
  return a = a < b ? b : a;
}
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template <int mod>
class Modular {
  int value;

 public:
  Modular(long long x = 0) { value = (int)((x % mod + mod) % mod); }
  inline Modular& operator+=(Modular x) {
    value += x.value;
    if (value >= mod) value -= mod;
    return *this;
  }
  inline Modular& operator-=(Modular x) {
    value -= x.value;
    if (value < 0) value += mod;
    return *this;
  }
  inline Modular& operator*=(Modular x) {
    value = (int)((long long)x.value * value % mod);
    return *this;
  }
  inline Modular operator-() { return Modular(-value); }
  inline Modular& operator++() { return *this += 1; }
  inline Modular& operator--() { return *this -= 1; }
  inline Modular operator++(int) {
    Modular t = *this;
    *this += 1;
    return t;
  }
  inline Modular operator--(int) {
    Modular t = *this;
    *this -= 1;
    return t;
  }
  Modular pow(int n) {
    while (n < 0) n += mod - 1;
    Modular v(1), a(value);
    for (; n; a *= a, n >>= 1)
      if (n & 1) v *= a;
    return v;
  }
  inline Modular& operator/=(Modular x) { *this *= x.pow(-1); }
  inline Modular operator+(Modular x) { return x += *this; }
  inline Modular operator-(Modular x) { return *this + (-x); }
  inline Modular operator*(Modular x) { return x *= *this; }
  inline Modular operator/(Modular x) { return (*this) * x.pow(-1); }
  inline bool operator==(Modular x) { return value == x.value; }
  inline bool operator!=(Modular x) { return value != x.value; }
  inline operator int() { return value; }
  Modular fact() {
    Modular x(1);
    for (int i = 1; i <= value; ++i) x *= i;
    return x;
  }
  friend ostream& operator<<(ostream& os, Modular x) { return os << x.value; }
  friend istream& operator>>(istream& is, Modular& x) {
    is >> x.value;
    x.value %= mod;
    return is;
  }
};
const int MAXN = 1e6, MOD = 998244353;
Modular<MOD> fact[MAXN + 1], ifact[MAXN + 1];
void init() {
  fact[0] = ifact[0] = 1;
  for (int i = (1); i <= (MAXN); i++)
    fact[i] = fact[i - 1] * Modular<MOD>(i),
    ifact[i] = ifact[i - 1] * Modular<MOD>(i).pow(-1);
}
inline Modular<MOD> nCr(int n, int r) {
  if (n < 0 || r < 0) return Modular<MOD>();
  return n >= r ? fact[n] * ifact[n - r] * ifact[r] : Modular<MOD>();
}
inline Modular<MOD> nPr(int n, int r) {
  return n >= r ? fact[n] * ifact[n - r] : Modular<MOD>();
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  init();
  int n, m;
  cin >> n >> m;
  vi L(n), R(n);
  for (int i = 0; i < (n); i++) cin >> L[i] >> R[i];
  vi C(n + 1);
  [&](vi l, vi r) {
    sort((l).begin(), (l).end());
    sort((r).begin(), (r).end());
    int c = 0, a = 0, b = 0;
    Modular<MOD> tmp;
    for (int i = 1; i <= (n); i++) {
      while (a < n && l[a] == i) c++, a++;
      C[i] = c;
      while (b < n && r[b] == i) c--, b++;
    }
    return tmp;
  }(L, R);
  ;
  ;
  vector<pii> bad;
  bad.reserve(m);
  for (int _ = 0; _ < (m); _++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    bad.push_back({u, v});
  }
  vector<vector<Modular<MOD>>> X(n + 1, vector<Modular<MOD>>(2 * m + 1));
  for (int i = 0; i < (n + 1); i++)
    for (int j = 0; j < (2 * m + 1); j++) X[i][j] = nCr(C[i] - j, i - j);
  ;
  for (int i = 1; i <= (n); i++)
    for (int j = 0; j < (2 * m + 1); j++) X[i][j] += X[i - 1][j];
  ;
  auto count_for = [&](int mask) {
    set<int> vals;
    for (int i = 0; i < (m); i++)
      if (mask & (1 << i))
        vals.insert(bad[i].first), vals.insert(bad[i].second);
    int cnt = vals.size();
    int l = 1, r = n;
    for (auto i : vals) ckmax(l, L[i]), ckmin(r, R[i]);
    if (r < l) return Modular<MOD>();
    ;
    return X[r][cnt] - X[l - 1][cnt];
  };
  Modular<MOD> ans = 0;
  for (int i = 0; i < (1 << m); i++) {
    int t = __builtin_popcount(i);
    ;
    if (t & 1)
      ans -= count_for(i);
    else
      ans += count_for(i);
  }
  cout << ans << '\n';
  return 0;
}