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("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 998244353;
const char nl = '\n';
const int MX = 300001;
struct mi {
  long long v;
  explicit operator long long() const { return v; }
  mi() { v = 0; }
  mi(long long _v) {
    v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
    if (v < 0) v += MOD;
  }
  friend bool operator==(const mi& a, const mi& b) { return a.v == b.v; }
  friend bool operator!=(const mi& a, const mi& b) { return !(a == b); }
  friend bool operator<(const mi& a, const mi& b) { return a.v < b.v; }
  mi& operator+=(const mi& m) {
    if ((v += m.v) >= MOD) v -= MOD;
    return *this;
  }
  mi& operator-=(const mi& m) {
    if ((v -= m.v) < 0) v += MOD;
    return *this;
  }
  mi& operator*=(const mi& m) {
    v = v * m.v % MOD;
    return *this;
  }
  mi& operator/=(const mi& m) { return (*this) *= inv(m); }
  friend mi pow(mi a, long long p) {
    mi ans = 1;
    assert(p >= 0);
    for (; p; p /= 2, a *= a)
      if (p & 1) ans *= a;
    return ans;
  }
  friend mi inv(const mi& a) {
    assert(a.v != 0);
    return pow(a, MOD - 2);
  }
  mi operator-() const { return mi(-v); }
  mi& operator++() { return *this += 1; }
  mi& operator--() { return *this -= 1; }
  mi operator++(int) {
    mi temp;
    temp.v = v++;
    return temp;
  }
  mi operator--(int) {
    mi temp;
    temp.v = v--;
    return temp;
  }
  friend mi operator+(mi a, const mi& b) { return a += b; }
  friend mi operator-(mi a, const mi& b) { return a -= b; }
  friend mi operator*(mi a, const mi& b) { return a *= b; }
  friend mi operator/(mi a, const mi& b) { return a /= b; }
  friend ostream& operator<<(ostream& os, const mi& m) {
    os << m.v;
    return os;
  }
  friend istream& operator>>(istream& is, mi& m) {
    long long x;
    is >> x;
    m.v = x;
    return is;
  }
};
mi facs[MX];
mi facInvs[MX];
mi choose(mi _a, mi _b) {
  long long a = (long long)_a, b = (long long)_b;
  if (b > a) return 0;
  if (a < 0) return 0;
  if (b < 0) return 0;
  mi cur = facs[a];
  cur = cur * facInvs[b];
  cur = cur * facInvs[a - b];
  return cur;
}
void initFacs() {
  facs[0] = 1;
  for (int i = 1; i < (MX); i++) {
    facs[i] = (facs[i - 1] * i);
  }
  facInvs[MX - 1] = inv(facs[MX - 1]);
  for (int i = (MX - 1) - 1; i >= 1; i--) {
    facInvs[i] = facInvs[i + 1] * (i + 1);
  }
  facInvs[0] = 1;
}
set<pair<int, int> > ed;
set<int> ag;
vector<mi> cnt(41);
void get() {
  vector<pair<int, int> > edges;
  for (auto& a : ed) edges.push_back(a);
  mi cntNum[41];
  int total = (int)(ag).size();
  for (int m = 0; m < ((1 << (int)(edges).size())); m++) {
    set<int> must;
    for (int i = 0; i < ((int)(edges).size()); i++)
      if (m & (1 << i)) {
        must.insert(edges[i].first);
        must.insert(edges[i].second);
      }
    if (__builtin_popcount(m) % 2 == 0) {
      cntNum[(int)(must).size()]++;
    } else {
      cntNum[(int)(must).size()]--;
    }
  }
  for (int i = 0; i < (41); i++) cnt[i] = 0;
  for (int i = 0; i < (total + 1); i++) {
    for (int j = i; j < (total + 1); j++) {
      cnt[j] += choose(total - i, j - i) * cntNum[i];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  initFacs();
  int N, M;
  cin >> N >> M;
  vector<vector<int> > graph(N);
  vector<pair<int, int> > ev;
  for (int i = 0; i < (N); i++) {
    int L, R;
    cin >> L >> R;
    ev.push_back({L, i});
    ev.push_back({R + 1, i});
  }
  for (int i = 0; i < (M); i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    graph[A].push_back(B);
    graph[B].push_back(A);
  }
  bool in[N];
  for (int i = 0; i < (N); i++) in[i] = false;
  mi ans = 0;
  int p = 0;
  int curIn = 0;
  cnt[0] = 1;
  sort(ev.begin(), ev.end());
  for (int i = 1; i < (N + 1); i++) {
    while (p < (int)(ev).size() && ev[p].first == i) {
      int x = ev[p].second;
      if (!in[x]) {
        in[x] = true;
        if ((int)(graph[x]).size() > 0) {
          for (auto& a : graph[x]) {
            if (in[a]) ed.insert({min(a, x), max(a, x)});
          }
          ag.insert(x);
          get();
        } else {
          curIn++;
        }
      } else {
        in[x] = false;
        if ((int)(graph[x]).size() > 0) {
          for (auto& a : graph[x]) {
            if (in[a]) ed.erase({min(a, x), max(a, x)});
          }
          ag.erase(x);
          get();
        } else {
          curIn--;
        }
      }
      p++;
    }
    for (int c = 0; c < (min(41, i + 1)); c++) {
      mi curCnt = cnt[c];
      ans += curCnt * choose(curIn, i - c);
    }
  }
  cout << ans << nl;
  return 0;
}