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 double pi = 3.1415926535;
const long long mod = 998244353;
const long long INF = 5e18;
const long long INF1 = 1e18;
const long long N = 3000 + 5;
const long long P0 = 437;
const long long P1 = 343;
const long long d = 400;
pair<long long, long long> Per(long long a, long long b, long long c,
                               long long d) {
  if (a > c) {
    swap(a, c);
    swap(b, d);
  }
  if (c > b) return {-1, -1};
  if (d <= b) return {c, d};
  return {c, b};
}
long long Bpow(long long a, long long st) {
  if (st == 0) return 1;
  if (st % 2 == 0) {
    long long t = Bpow(a, st / 2);
    return (t * t) % mod;
  } else {
    long long t = Bpow(a, st - 1);
    return (t * a) % mod;
  }
}
vector<long long> fact;
long long C_n_k(long long n, long long k) {
  return (fact[n] * Bpow((fact[k] * fact[n - k]) % mod, mod - 2)) % mod;
}
vector<long long> g[50], was(50);
void dfs(long long pos, vector<long long>& w) {
  was[pos] = 1;
  w.emplace_back(pos);
  for (long long x : g[pos]) {
    if (!was[x]) dfs(x, w);
  }
}
vector<long long> Go(vector<long long>& comp) {
  long long n = ((long long)(comp).size());
  long long timer = 1;
  vector<long long> used(50);
  vector<long long> ans;
  for (long long mask = 0; mask < ((1 << n)); mask++) {
    long long Mask = mask;
    long long kol = 0;
    for (long long j = 0; j < (n); j++) {
      if (Mask % 2) {
        used[comp[j]] = timer;
        kol++;
      }
      Mask /= 2;
    }
    timer++;
    bool check = true;
    for (long long j = 0; j < (n); j++) {
      if (used[comp[j]] == timer - 1) {
        for (long long x : g[comp[j]]) {
          if (used[x] == timer - 1) {
            check = false;
            break;
          }
        }
      }
      if (!check) break;
    }
    if (!check) continue;
    while (((long long)(ans).size()) <= kol) ans.emplace_back(0);
    ans[kol]++;
  }
  return ans;
}
vector<long long> Cnt(21);
long long sum, Kol;
void Rec(vector<vector<long long> >& cnt, long long pos) {
  if (pos == ((long long)(cnt).size())) {
    Cnt[sum] += Kol;
    return;
  }
  if (pos == 0) Kol = 1;
  for (long long i = 0; i < (((long long)(cnt[pos]).size())); i++) {
    Kol *= cnt[pos][i];
    sum += i;
    Rec(cnt, pos + 1);
    sum -= i;
    Kol /= cnt[pos][i];
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> l(n), r(n);
  for (long long i = 0; i < (n); i++) {
    cin >> l[i] >> r[i];
  }
  vector<pair<long long, long long> > p(m);
  for (long long i = 0; i < (m); i++) {
    cin >> p[i].first >> p[i].second;
    p[i].first--;
    p[i].second--;
  }
  long long an = 0;
  vector<pair<pair<long long, long long>, long long> > v;
  vector<pair<long long, long long> > v1;
  for (long long i = 0; i < (m); i++) {
    long long l1 = l[p[i].first], r1 = r[p[i].first], l2 = l[p[i].second],
              r2 = r[p[i].second];
    pair<long long, long long> o = Per(l1, r1, l2, r2);
    if (o.first == -1) continue;
    v.emplace_back(make_pair(make_pair(o.first, 0), i));
    v.emplace_back(make_pair(make_pair(o.second + 1, 1), i));
  }
  for (long long i = 0; i < (n); i++) {
    v1.emplace_back(l[i], 0);
    v1.emplace_back(r[i] + 1, 1);
  }
  sort(v.begin(), v.end());
  sort(v1.begin(), v1.end());
  long long ind = 0, ind1 = 0;
  unordered_set<long long> s;
  fact.resize(n + 5);
  fact[0] = 1;
  for (long long i = 1; i < n + 5; i++) fact[i] = (fact[i - 1] * i) % mod;
  long long can = 0;
  Cnt[0] = 1;
  long long Bad = 0;
  for (long long i = 1; i <= n; i++) {
    bool del = false;
    while (ind < ((long long)(v).size()) && v[ind].first.first <= i) {
      del = true;
      if (v[ind].first.second == 0)
        s.insert(v[ind].second);
      else
        s.erase(v[ind].second);
      ind++;
    }
    while (ind1 < ((long long)(v1).size()) && v1[ind1].first <= i) {
      if (v1[ind1].second == 0)
        can++;
      else
        can--;
      ind1++;
    }
    if (del) {
      long long q = ((long long)(s).size());
      vector<long long> now;
      for (long long x : s) now.emplace_back(x);
      vector<pair<long long, long long> > e;
      unordered_map<long long, long long> mm;
      long long timer = 0;
      for (long long x : now) {
        if (mm.find(p[x].first) == mm.end()) mm[p[x].first] = timer++;
        if (mm.find(p[x].second) == mm.end()) mm[p[x].second] = timer++;
        e.emplace_back(mm[p[x].first], mm[p[x].second]);
      }
      Bad = timer;
      for (long long i = 0; i < (timer); i++) {
        g[i].clear();
        was[i] = 0;
      }
      for (auto x : e) {
        g[x.first].emplace_back(x.second);
        g[x.second].emplace_back(x.first);
      }
      vector<vector<long long> > cnt;
      for (long long i = 0; i < (timer); i++) {
        if (!was[i]) {
          vector<long long> comp;
          dfs(i, comp);
          cnt.emplace_back(Go(comp));
        }
      }
      for (long long i = 0; i < (21); i++) Cnt[i] = 0;
      Rec(cnt, 0);
    }
    long long norm = can - Bad;
    for (long long j = 0; j < (21); j++) {
      long long ost = i - j;
      if (ost < 0) break;
      if (norm >= ost) an += Cnt[j] * C_n_k(norm, ost);
      an %= mod;
    }
  }
  cout << an;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long qq = 1;
  while (qq--) solve();
}