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;
long long fastPow(long long a, long long pw, long long mod) {
  long long res = 1;
  a %= mod;
  while (pw > 0) {
    if (pw & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    pw >>= 1;
  }
  return res;
}
struct NchooseK {
  long long range, mod;
  vector<long long> fact, ifact;
  NchooseK(long long currMod) {
    this->mod = currMod;
    range = min((long long)1e6 + 3, currMod);
    fact.resize(range + 1);
    ifact.resize(range + 1);
    calcFacts();
  }
  void calcFacts() {
    fact[0] = 1;
    for (long long i = 1; i <= range; ++i) {
      fact[i] = (1LL * fact[i - 1] * i) % this->mod;
    }
    ifact[range] = fastPow(fact[range], this->mod - 2, this->mod);
    for (long long i = range - 1; i >= 0; --i) {
      ifact[i] = (1LL * ifact[i + 1] * (i + 1)) % this->mod;
    }
  }
  long long choose(long long n, long long k) const {
    if (k < 0 || k > n || n < 0) return 0;
    return ((1LL * fact[n] * ifact[k]) % this->mod * 1LL * ifact[n - k]) %
           this->mod;
  }
};
const long long mod = 998244353;
const long long N = 3e5 + 10;
vector<long long> adj[N], cc[N], add[N], erase[N];
long long ccToMask[N], nodeToIdx[N];
vector<long long> p(N, -1);
long long find(long long x) { return p[x] < 0 ? x : p[x] = find(p[x]); }
void merge(long long x, long long y) {
  if ((x = find(x)) == (y = find(y))) return;
  if (p[y] < p[x]) swap(x, y);
  p[x] += p[y];
  p[y] = x;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    long long l, r;
    cin >> l >> r;
    add[l].push_back(i);
    erase[r + 1].push_back(i);
  }
  set<pair<long long, long long>> edges;
  for (long long i = 0; i < m; ++i) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    merge(u, v);
    edges.insert({u, v});
    edges.insert({v, u});
  }
  for (long long i = 1; i <= n; ++i) {
    if (adj[i].size()) {
      cc[find(i)].push_back(i);
    }
  }
  vector<vector<vector<long long>>> dp(n + 1);
  for (long long i = 1; i <= n; ++i) {
    if (cc[i].empty()) continue;
    if (dp[i].size()) continue;
    long long sz = cc[i].size();
    dp[i].resize(1 << sz, vector<long long>(sz + 1, 0));
    for (long long mask = 0; mask < (1 << sz); ++mask) {
      dp[i][mask][0] = 1;
    }
    for (long long k = 1; k <= sz; ++k) {
      for (long long mask = 1; mask < (1 << sz); ++mask) {
        long long mxBit = 0;
        for (long long bit = 0; bit < sz; ++bit) {
          nodeToIdx[cc[i][bit]] = bit;
          if ((mask & (1 << bit)) == 0) continue;
          mxBit = bit;
        }
        long long &curr = dp[i][mask][k];
        if (k) {
          long long currPrevMask = 0;
          for (long long bit = 0; bit < mxBit; ++bit) {
            if ((mask & (1 << bit)) == 0) continue;
            if (edges.count({cc[i][bit], cc[i][mxBit]})) continue;
            currPrevMask += (1 << bit);
          }
          curr += dp[i][currPrevMask][k - 1];
        }
        curr += dp[i][mask - (1 << mxBit)][k];
        curr %= mod;
      }
    }
  }
  map<long long, long long> cntCC;
  NchooseK nk(mod);
  long long res = 0;
  long long cntNodes = 0;
  long long cntNodesInACC = 0;
  set<long long> allNodesDebug;
  for (long long subSz = 1; subSz <= n; ++subSz) {
    for (long long node : add[subSz]) {
      allNodesDebug.insert(node);
      ++cntNodes;
      if (dp[find(node)].size()) {
        ++cntNodesInACC;
        ccToMask[find(node)] += (1 << nodeToIdx[node]);
        ++cntCC[find(node)];
      }
    }
    for (long long node : erase[subSz]) {
      allNodesDebug.erase(node);
      --cntNodes;
      if (dp[find(node)].size()) {
        --cntNodesInACC;
        ccToMask[find(node)] -= (1 << nodeToIdx[node]);
        --cntCC[find(node)];
        assert(cntCC[find(node)] >= 0);
        if (cntCC[find(node)] == 0) cntCC.erase(find(node));
      }
    }
    if (cntNodes < subSz) continue;
    vector<long long> sack(cntNodesInACC + 1, 0);
    sack[0] = 1;
    for (auto &p : cntCC) {
      long long CC = p.first;
      long long CCsz = p.second;
      vector<long long> newSack(cntNodesInACC + 1, 0);
      for (long long i = 0; i <= cntNodesInACC; ++i) {
        for (long long j = 0; j <= i && j < dp[CC][ccToMask[CC]].size(); ++j) {
          newSack[i] += dp[CC][ccToMask[CC]][j] * sack[i - j];
          newSack[i] %= mod;
        }
      }
      sack.swap(newSack);
    }
    for (long long i = 0; i <= cntNodesInACC && i <= cntNodes && i <= subSz;
         ++i) {
      res += (sack[i] * nk.choose(cntNodes - cntNodesInACC, subSz - i)) % mod;
      res %= mod;
    }
  }
  cout << res;
}