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 <int MOD>
struct Modular {
  int value;
  Modular(const Modular& k) : value(k.value) {}
  template <typename V>
  Modular(const V& v) : value(v % MOD) {
    if (value < 0) {
      value += MOD;
    }
  }
  Modular() : Modular(0) {}
  Modular& operator+=(Modular const& b) {
    value += b.value;
    if (value >= MOD) value -= MOD;
    return *this;
  }
  Modular& operator-=(Modular const& b) {
    value -= b.value;
    if (value < 0) value += MOD;
    return *this;
  }
  Modular& operator*=(Modular const& b) {
    value = (long long)value * b.value % MOD;
    return *this;
  }
  Modular& operator++() { return *this += 1; }
  Modular& operator--() { return *this -= 1; }
  Modular operator++(int) { return *this += 1; }
  Modular operator--(int) { return *this -= 1; }
  friend Modular inverse(Modular a) { return mexp(a, MOD - 2); }
  Modular& operator/=(Modular const& b) { return *this *= inverse(b); }
  friend Modular operator+(Modular a, Modular const b) { return a += b; }
  friend Modular operator-(Modular a, Modular const b) { return a -= b; }
  friend Modular operator-(Modular const a) { return 0 - a; }
  friend Modular operator*(Modular a, Modular const b) { return a *= b; }
  friend Modular operator/(Modular a, Modular const b) { return a /= b; }
  friend std::ostream& operator<<(std::ostream& os, Modular const& a) {
    return os << a.value;
  }
  friend bool operator==(Modular const& a, Modular const& b) {
    return a.value == b.value;
  }
  friend bool operator!=(Modular const& a, Modular const& b) {
    return a.value != b.value;
  }
};
template <int T, typename V>
Modular<T> mexp(Modular<T> a, V e) {
  if (a == 0) return e == 0 ? 1 : 0;
  Modular<T> res = 1;
  while (e) {
    if (e & 1) res *= a;
    a *= a;
    e >>= 1;
  }
  return res;
}
class Dsu {
 private:
  vector<int> par;
  vector<int> comp_size;

 public:
  Dsu(int sz) : par(sz), comp_size(sz, 1) { iota(par.begin(), par.end(), 0); }
  int Find(int x) {
    if (par[x] == x) return x;
    return par[x] = Find(par[x]);
  }
  bool Union(int x, int y) {
    int px = Find(x);
    int py = Find(y);
    if (px == py) return false;
    par[px] = py;
    comp_size[py] += comp_size[px];
    return true;
  }
  int CompSize(int x) { return comp_size[x]; }
};
using Mint = Modular<998244353>;
const int N = 3.1e5;
const int M = 20;
int L[N], R[N];
vector<int> adj[N];
vector<Mint> dp[M + 2][M + 2];
void Run() {
  int n, m;
  cin >> n >> m;
  Dsu dsu(n);
  for (int i = 0; i < n; ++i) {
    cin >> L[i] >> R[i];
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    dsu.Union(u, v);
  }
  vector<int> all_comps;
  vector<int> singles_with_size(n + 2);
  for (int i = 0; i < n; ++i) {
    int which = dsu.Find(i);
    if (dsu.CompSize(which) == 1) {
      ++singles_with_size[L[i]];
      --singles_with_size[R[i] + 1];
    } else {
      all_comps.push_back(which);
    }
  }
  sort(all_comps.begin(), all_comps.end());
  all_comps.resize(unique(all_comps.begin(), all_comps.end()) -
                   all_comps.begin());
  int comps = (int)all_comps.size();
  vector<Mint> factorial(n + 2), invfact(n + 2);
  factorial[0] = 1, invfact[0] = 1;
  for (int i = 1; i <= n + 1; ++i) {
    singles_with_size[i] += singles_with_size[i - 1];
    factorial[i] = Mint(i) * factorial[i - 1];
    invfact[i] = inverse(factorial[i]);
  }
  vector<vector<int>> comp_list(comps);
  vector<int> index_in_comp(n);
  for (int i = 0; i < n; ++i) {
    int which = dsu.Find(i);
    if (dsu.CompSize(which) != 1) {
      which = lower_bound(all_comps.begin(), all_comps.end(), which) -
              all_comps.begin();
      index_in_comp[i] = (int)comp_list[which].size();
      comp_list[which].push_back(i);
    }
  }
  vector<int> adj_list(n);
  for (int i = 0; i < n; ++i) {
    adj_list[i] |= (1 << index_in_comp[i]);
    for (int v : adj[i]) {
      adj_list[i] |= (1 << index_in_comp[v]);
    }
  }
  auto&& Binom = [&](int x, int y) -> Mint {
    if (x < y) {
      return 0;
    } else {
      return factorial[x] * invfact[y] * invfact[x - y];
    }
  };
  for (int i = 0; i < comps; ++i) {
    int csize = (int)comp_list[i].size();
    for (int k = 0; k <= csize; ++k) dp[i][k].resize(1 << csize);
    fill(dp[i][0].begin(), dp[i][0].end(), 1);
    for (int k = 1; k <= csize; ++k) {
      for (int msk = 1; msk < (1 << csize); ++msk) {
        int nxt = 31 - __builtin_clz(msk);
        int vertex = comp_list[i][nxt];
        dp[i][k][msk] += dp[i][k - 1][msk & ~adj_list[vertex]];
        dp[i][k][msk] += dp[i][k][msk ^ (1 << nxt)];
      }
    }
  }
  Mint ans = 0;
  for (int want = 1; want <= n; ++want) {
    vector<vector<Mint>> ways(comps + 1, vector<Mint>(2 * m + 1));
    ways[comps][0] = 1;
    for (int c = comps - 1; c >= 0; --c) {
      int full = 0;
      int have = 0;
      for (int v : comp_list[c]) {
        if (L[v] <= want && want <= R[v]) {
          full |= (1 << index_in_comp[v]);
          ++have;
        }
      }
      for (int s = 0; s <= min(want, 2 * m); ++s) {
        for (int take = 0; take <= min(have, s); ++take) {
          ways[c][s] += dp[c][take][full] * ways[c + 1][s - take];
        }
      }
    }
    for (int s = 0; s <= min(want, 2 * m); ++s) {
      ans += ways[0][s] * Binom(singles_with_size[want], want - s);
    }
  }
  cout << ans << '\n';
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  Run();
  return 0;
}