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 int N = 3e5 + 5;
const int M = 25;
template <const int &MOD>
struct _m_int {
  int val;
  _m_int(int64_t v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = v;
  }
  static int mod_inv(int a, int m = MOD) {
    int g = m, r = a, x = 0, y = 1;
    while (r != 0) {
      int q = g / r;
      g %= r;
      swap(g, r);
      x -= q * y;
      swap(x, y);
    }
    return x < 0 ? x + m : x;
  }
  explicit operator int() const { return val; }
  explicit operator int64_t() const { return val; }
  _m_int &operator+=(const _m_int &other) {
    val -= MOD - other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  _m_int &operator-=(const _m_int &other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return x % m;
    unsigned x_high = x >> 32, x_low = (unsigned)x;
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  _m_int &operator*=(const _m_int &other) {
    val = fast_mod((uint64_t)val * other.val);
    return *this;
  }
  _m_int &operator/=(const _m_int &other) { return *this *= other.inv(); }
  friend _m_int operator+(const _m_int &a, const _m_int &b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int &a, const _m_int &b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int &a, const _m_int &b) {
    return _m_int(a) *= b;
  }
  friend _m_int operator/(const _m_int &a, const _m_int &b) {
    return _m_int(a) /= b;
  }
  _m_int &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  _m_int &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }
  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  _m_int operator--(int) {
    _m_int before = *this;
    --*this;
    return before;
  }
  _m_int operator-() const { return val == 0 ? 0 : MOD - val; }
  bool operator==(const _m_int &other) const { return val == other.val; }
  bool operator!=(const _m_int &other) const { return val != other.val; }
  bool operator<(const _m_int &other) const { return val < other.val; }
  bool operator<=(const _m_int &other) const { return val <= other.val; }
  bool operator>(const _m_int &other) const { return val > other.val; }
  bool operator>=(const _m_int &other) const { return val >= other.val; }
  _m_int inv() const { return mod_inv(val); }
  _m_int pow(int64_t p) const {
    if (p < 0) return inv().pow(-p);
    _m_int a = *this, result = 1;
    while (p > 0) {
      if (p & 1) {
        result *= a;
      }
      a *= a;
      p >>= 1;
    }
    return result;
  }
  friend ostream &operator<<(ostream &os, const _m_int &m) {
    return os << m.val;
  }
};
extern const int MOD = 998244353;
using mod_int = _m_int<MOD>;
mod_int fact[N], ifact[N];
int L[N], R[N];
int a[M], b[M];
int cnt[N];
int n, m;
mod_int pref[M << 1][N];
void pre() {
  fact[0] = 1;
  int i;
  for (i = 1; i < N; i++) {
    fact[i] = (fact[i - 1] * i);
  }
  ifact[N - 1] = fact[N - 1].inv();
  for (i = N - 2; i >= 0; i--) {
    ifact[i] = (ifact[i + 1] * (i + 1));
  }
}
mod_int ncr(int n, int r) {
  if (r < 0 || n < 0 || n - r < 0) {
    return 0;
  }
  mod_int ans = (ifact[r] * ifact[n - r]);
  ans = (ans * fact[n]);
  return ans;
}
mod_int incr(int n, int r) {
  if (r < 0 || n < 0 || n - r < 0) {
    return 0;
  }
  mod_int ans = (fact[r] * ifact[n - r]);
  ans = (ans * ifact[n]);
  return ans;
}
mod_int npr(int n, int r) {
  if (r < 0 || n < 0 || n - r < 0) {
    return 0;
  }
  mod_int ans = ifact[n - r] * fact[n];
  return ans;
}
mod_int inpr(int n, int r) {
  if (r < 0 || n < 0 || n - r < 0) {
    return 0;
  }
  mod_int ans = (fact[n - r] * ifact[n]);
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  pre();
  cin >> n >> m;
  for (int i = 0; i <= n - 1; i++) {
    cin >> L[i] >> R[i];
    cnt[L[i]]++;
    cnt[R[i] + 1]--;
  }
  for (int i = 1; i <= n; i++) {
    cnt[i] += cnt[i - 1];
  }
  for (int i = 0; i <= m - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  for (int k = 0; k <= m << 1; k++) {
    for (int s = 1; s <= n; s++) {
      pref[k][s] = (pref[k][s - 1] + ncr(cnt[s] - k, s - k));
    }
  }
  mod_int ans = 0;
  for (int i = 0; i <= (1 << m) - 1; i++) {
    mod_int ways = 0;
    int l = 1;
    int r = n;
    unordered_set<int> must;
    bool even = true;
    for (int j = 0; j <= m - 1; j++) {
      if ((i >> j) & 1) {
        even = !even;
        must.insert(a[j]);
        must.insert(b[j]);
      }
    }
    for (auto &x : must) {
      l = max(l, L[x]);
      r = min(r, R[x]);
    }
    if (l > r) {
      continue;
    }
    int k = must.size();
    ways = pref[k][r] - pref[k][l - 1];
    if (!even) {
      ans -= ways;
    } else {
      ans += ways;
    }
  }
  cout << ans << endl;
  return 0;
}