#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
const long long mod = 998244353;
namespace modop {
long long madd(long long a, long long b) { return (a + b) % mod; }
long long msub(long long a, long long b) {
  return (((a - b) % mod) + mod) % mod;
}
long long mmul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long mpow(long long base, long long exp) {
  long long res = 1;
  while (exp) {
    if (exp % 2 == 1) {
      res = (res * base) % mod;
    }
    exp >>= 1;
    base = (base * base) % mod;
  }
  return res;
}
long long minv(long long base) { return mpow(base, mod - 2); }
long long mdiv(long long a, long long b) { return mmul(a, minv(b)); }
}  // namespace modop
using namespace modop;
long long n, m, k, q, l, r, x, y, z;
const long long template_array_size = 1e6 + 776;
long long a[template_array_size];
long long b[template_array_size];
long long c[template_array_size];
string second, t;
long long ans = 0;
pair<long long, long long> v[300005];
long long fact[350005], ifact[350005];
bool toggle[300005];
bool spec[300005];
vector<long long> edges[300005];
vector<long long> specv;
vector<long long> events[300005];
long long nck(long long n, long long k) {
  long long dem = (ifact[n - k] * ifact[k]) % mod;
  return (dem * fact[n]) % mod;
}
long long dp[45];
long long cnt[45];
bool vis[300005];
long long id[300005];
vector<long long> comp;
void dfs(int v) {
  vis[v] = 1;
  comp.push_back(v);
  for (long long x : edges[v]) {
    if (toggle[x] && !vis[x]) {
      dfs(x);
    }
  }
}
void solve_iset() {
  for (long long i = 0; i < 24; i++) cnt[i] = 0;
  for (long long x : specv) id[x] = -1;
  for (long long i = 0; i < comp.size(); i++) id[comp[i]] = i;
  long long sz = (long long)comp.size();
  if (sz == 1) {
    cnt[0] = cnt[1] = 1;
    return;
  }
  long long cut = (sz + 1) / 2;
  long long rem = sz - cut;
  long long mask1 = (1 << cut), mask2 = (1 << rem);
  long long tot[mask2][22];
  memset(tot, 0, sizeof(tot));
  for (long long i = 0; i < mask2; i++) {
    bool bad[22];
    memset(bad, 0, sizeof(bad));
    bool pos = 1;
    for (long long j = cut; j < sz; j++) {
      if (i & (1 << (j - cut))) {
        if (bad[j]) {
          pos = 0;
          break;
        }
        for (long long x : edges[comp[j]]) {
          if (id[x] != -1) {
            bad[id[x]] = 1;
          }
        }
      }
    }
    tot[i][__builtin_popcountll(i)] += pos;
  }
  for (long long i = 0; i < rem; i++) {
    for (long long mask = 0; mask < mask2; mask++) {
      if (mask & (1 << i)) {
        for (long long j = 0; j < 22; j++) {
          tot[mask][j] += tot[mask ^ (1 << i)][j];
          if (tot[mask][j] >= mod) tot[mask][j] -= mod;
        }
      }
    }
  }
  for (long long i = 0; i < mask1; i++) {
    bool bad[22];
    memset(bad, 0, sizeof(bad));
    bool pos = 1;
    for (long long j = 0; j < cut; j++) {
      if (i & (1 << j)) {
        if (bad[j]) {
          pos = 0;
          break;
        }
        for (long long x : edges[comp[j]]) {
          if (id[x] != -1) {
            bad[id[x]] = 1;
          }
        }
      }
    }
    if (pos) {
      long long rem_mask = 0;
      for (long long j = cut; j < sz; j++) {
        rem_mask += (1 << (j - cut)) * !bad[j];
      }
      long long v = __builtin_popcountll(i);
      for (long long j = 20; j >= 0; j--) {
        cnt[v + j] += tot[rem_mask][j];
        if (cnt[v + j] >= mod) cnt[v + j] -= mod;
      }
    }
  }
}
void solve_isets() {
  for (long long x : specv) vis[x] = 0;
  for (long long i = 0; i < 43; i++) dp[i] = 0;
  dp[0] = 1;
  for (long long x : specv) {
    comp.clear();
    if (toggle[x] && !vis[x]) {
      dfs(x);
      solve_iset();
      long long ndp[45];
      for (long long i = 0; i < 43; i++) ndp[i] = 0;
      for (long long i = 21; i >= 0; i--) {
        for (long long j = 21; j >= 0; j--) {
          if (i + j < 43) {
            ndp[i + j] = (ndp[i + j] + dp[i] * cnt[j]) % mod;
          }
        }
      }
      for (long long i = 0; i < 43; i++) dp[i] = ndp[i];
    }
  }
}
void solve(int tc = 0) {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) events[i].reserve(5);
  fact[0] = ifact[0] = fact[1] = ifact[1] = 1;
  for (long long i = 2; i < 300003; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
  }
  ifact[300001] = minv(fact[300001]);
  for (long long i = 300000; i >= 2; i--) {
    ifact[i] = ((i + 1) * ifact[i + 1]) % mod;
  }
  for (long long i = 0; i < n; i++) {
    toggle[i] = 0;
    cin >> v[i];
    id[i] = -1;
  }
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    --x;
    --y;
    spec[x] = 1;
    spec[y] = 1;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  for (long long i = 0; i < n; i++) {
    if (spec[i]) {
      id[i] = (long long)specv.size();
      specv.push_back(i);
    }
  }
  for (long long i = 0; i < n; i++) {
    events[v[i].first].push_back(i + n);
    events[v[i].second + 1].push_back(i);
  }
  solve_isets();
  long long ntoggled = 0;
  ans = 0;
  for (long long i = 1; i <= n; i++) {
    bool change = 0;
    for (long long x : events[i]) {
      if (x >= n) {
        ++ntoggled;
        toggle[x -= n] = 1;
      } else {
        --ntoggled;
        toggle[x] = 0;
      }
      if (spec[x]) change = 1;
    }
    if (change) {
      solve_isets();
    }
    long long ctog = 0;
    for (long long x : specv) {
      if (toggle[x]) {
        ++ctog;
      }
    }
    for (long long j = 0; j < 42; j++) {
      long long tot = i - j;
      long long rest = ntoggled - ctog;
      if (tot >= 0 && rest >= 0 && rest >= tot) {
        ans = (ans + nck(rest, tot) * dp[j]) % mod;
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  { ios_base::sync_with_stdio(false); }
  {
    cin.tie(NULL);
    cout.tie(NULL);
  }
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}

### Prompt

Your task is to create a cpp solution to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v);
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
const long long mod = 998244353;
namespace modop {
long long madd(long long a, long long b) { return (a + b) % mod; }
long long msub(long long a, long long b) {
  return (((a - b) % mod) + mod) % mod;
}
long long mmul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long mpow(long long base, long long exp) {
  long long res = 1;
  while (exp) {
    if (exp % 2 == 1) {
      res = (res * base) % mod;
    }
    exp >>= 1;
    base = (base * base) % mod;
  }
  return res;
}
long long minv(long long base) { return mpow(base, mod - 2); }
long long mdiv(long long a, long long b) { return mmul(a, minv(b)); }
}  // namespace modop
using namespace modop;
long long n, m, k, q, l, r, x, y, z;
const long long template_array_size = 1e6 + 776;
long long a[template_array_size];
long long b[template_array_size];
long long c[template_array_size];
string second, t;
long long ans = 0;
pair<long long, long long> v[300005];
long long fact[350005], ifact[350005];
bool toggle[300005];
bool spec[300005];
vector<long long> edges[300005];
vector<long long> specv;
vector<long long> events[300005];
long long nck(long long n, long long k) {
  long long dem = (ifact[n - k] * ifact[k]) % mod;
  return (dem * fact[n]) % mod;
}
long long dp[45];
long long cnt[45];
bool vis[300005];
long long id[300005];
vector<long long> comp;
void dfs(int v) {
  vis[v] = 1;
  comp.push_back(v);
  for (long long x : edges[v]) {
    if (toggle[x] && !vis[x]) {
      dfs(x);
    }
  }
}
void solve_iset() {
  for (long long i = 0; i < 24; i++) cnt[i] = 0;
  for (long long x : specv) id[x] = -1;
  for (long long i = 0; i < comp.size(); i++) id[comp[i]] = i;
  long long sz = (long long)comp.size();
  if (sz == 1) {
    cnt[0] = cnt[1] = 1;
    return;
  }
  long long cut = (sz + 1) / 2;
  long long rem = sz - cut;
  long long mask1 = (1 << cut), mask2 = (1 << rem);
  long long tot[mask2][22];
  memset(tot, 0, sizeof(tot));
  for (long long i = 0; i < mask2; i++) {
    bool bad[22];
    memset(bad, 0, sizeof(bad));
    bool pos = 1;
    for (long long j = cut; j < sz; j++) {
      if (i & (1 << (j - cut))) {
        if (bad[j]) {
          pos = 0;
          break;
        }
        for (long long x : edges[comp[j]]) {
          if (id[x] != -1) {
            bad[id[x]] = 1;
          }
        }
      }
    }
    tot[i][__builtin_popcountll(i)] += pos;
  }
  for (long long i = 0; i < rem; i++) {
    for (long long mask = 0; mask < mask2; mask++) {
      if (mask & (1 << i)) {
        for (long long j = 0; j < 22; j++) {
          tot[mask][j] += tot[mask ^ (1 << i)][j];
          if (tot[mask][j] >= mod) tot[mask][j] -= mod;
        }
      }
    }
  }
  for (long long i = 0; i < mask1; i++) {
    bool bad[22];
    memset(bad, 0, sizeof(bad));
    bool pos = 1;
    for (long long j = 0; j < cut; j++) {
      if (i & (1 << j)) {
        if (bad[j]) {
          pos = 0;
          break;
        }
        for (long long x : edges[comp[j]]) {
          if (id[x] != -1) {
            bad[id[x]] = 1;
          }
        }
      }
    }
    if (pos) {
      long long rem_mask = 0;
      for (long long j = cut; j < sz; j++) {
        rem_mask += (1 << (j - cut)) * !bad[j];
      }
      long long v = __builtin_popcountll(i);
      for (long long j = 20; j >= 0; j--) {
        cnt[v + j] += tot[rem_mask][j];
        if (cnt[v + j] >= mod) cnt[v + j] -= mod;
      }
    }
  }
}
void solve_isets() {
  for (long long x : specv) vis[x] = 0;
  for (long long i = 0; i < 43; i++) dp[i] = 0;
  dp[0] = 1;
  for (long long x : specv) {
    comp.clear();
    if (toggle[x] && !vis[x]) {
      dfs(x);
      solve_iset();
      long long ndp[45];
      for (long long i = 0; i < 43; i++) ndp[i] = 0;
      for (long long i = 21; i >= 0; i--) {
        for (long long j = 21; j >= 0; j--) {
          if (i + j < 43) {
            ndp[i + j] = (ndp[i + j] + dp[i] * cnt[j]) % mod;
          }
        }
      }
      for (long long i = 0; i < 43; i++) dp[i] = ndp[i];
    }
  }
}
void solve(int tc = 0) {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) events[i].reserve(5);
  fact[0] = ifact[0] = fact[1] = ifact[1] = 1;
  for (long long i = 2; i < 300003; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
  }
  ifact[300001] = minv(fact[300001]);
  for (long long i = 300000; i >= 2; i--) {
    ifact[i] = ((i + 1) * ifact[i + 1]) % mod;
  }
  for (long long i = 0; i < n; i++) {
    toggle[i] = 0;
    cin >> v[i];
    id[i] = -1;
  }
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    --x;
    --y;
    spec[x] = 1;
    spec[y] = 1;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  for (long long i = 0; i < n; i++) {
    if (spec[i]) {
      id[i] = (long long)specv.size();
      specv.push_back(i);
    }
  }
  for (long long i = 0; i < n; i++) {
    events[v[i].first].push_back(i + n);
    events[v[i].second + 1].push_back(i);
  }
  solve_isets();
  long long ntoggled = 0;
  ans = 0;
  for (long long i = 1; i <= n; i++) {
    bool change = 0;
    for (long long x : events[i]) {
      if (x >= n) {
        ++ntoggled;
        toggle[x -= n] = 1;
      } else {
        --ntoggled;
        toggle[x] = 0;
      }
      if (spec[x]) change = 1;
    }
    if (change) {
      solve_isets();
    }
    long long ctog = 0;
    for (long long x : specv) {
      if (toggle[x]) {
        ++ctog;
      }
    }
    for (long long j = 0; j < 42; j++) {
      long long tot = i - j;
      long long rest = ntoggled - ctog;
      if (tot >= 0 && rest >= 0 && rest >= tot) {
        ans = (ans + nck(rest, tot) * dp[j]) % mod;
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  { ios_base::sync_with_stdio(false); }
  {
    cin.tie(NULL);
    cout.tie(NULL);
  }
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}

```