#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long N = 3e5 + 10;
const long long N2 = 1e2 + 10;
const long long off = 1e3;
const long long inf = 1e18 + 10ll;
const long long mod = 998244353;
const double eps = 1e-7;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
long long n, m;
pair<long long, long long> a[N];
vector<pair<long long, long long> > es;
long long cnts[N];
long long f[N];
long long rf[N];
long long pref[N][41];
long long bpow(long long a, long long b) {
  if (b == 0) return 1;
  long long t = bpow(a, b / 2);
  if (b & 1) return t * t % mod * a % mod;
  return t * t % mod;
}
long long md(long long first) {
  if (first < 0) return first + mod;
  if (first >= mod) return first - mod;
  return first;
}
long long C(long long n, long long k) {
  if (n < k || min(n, k) < 0) return 0;
  return f[n] * rf[k] % mod * rf[n - k] % mod;
}
pair<long long, long long> unite(const pair<long long, long long> &p1,
                                 const pair<long long, long long> &p2) {
  if (p1.first == -1 || p2.first == -1) return {-1, -1};
  if (min(p1.second, p2.second) < max(p1.first, p2.first)) return {-1, -1};
  return {max(p1.first, p2.first), min(p1.second, p2.second)};
}
long long calc(long long msk) {
  set<long long> st;
  pair<long long, long long> un = {-2, -2};
  for (long long i = 0; i < m; ++i)
    if ((1ll << i) & msk) {
      if (un.first == -2) un = a[es[i].first];
      un = unite(un, a[es[i].first]);
      un = unite(un, a[es[i].second]);
      st.insert(es[i].first);
      st.insert(es[i].second);
    }
  long long cnt = st.size();
  if (un.first == -1) return 0;
  return md(pref[un.second][cnt] - pref[un.first - 1][cnt]);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  f[0] = 1;
  rf[0] = 1;
  for (long long i = 1; i < N; ++i) {
    f[i] = f[i - 1] * i % mod;
    rf[i] = bpow(f[i], mod - 2);
  }
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  es.resize(m);
  for (long long i = 0; i < m; ++i) {
    cin >> es[i].first >> es[i].second;
    --es[i].first;
    --es[i].second;
  }
  for (long long i = 0; i < n; ++i) {
    ++cnts[a[i].first];
    --cnts[a[i].second + 1];
  }
  for (long long i = 1; i < N; ++i) cnts[i] += cnts[i - 1];
  for (long long k = 1; k <= 40; ++k) {
    for (long long i = 0; i <= n; ++i) pref[i][k] = C(cnts[i] - k, i - k);
    for (long long i = 1; i <= n; ++i)
      pref[i][k] = md(pref[i][k] + pref[i - 1][k]);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) ans = md(ans + C(cnts[i], i));
  for (long long i = 1; i < (1ll << m); ++i) {
    long long cnt = 0;
    for (long long j = 0; j < m; ++j)
      if ((1ll << j) & i) ++cnt;
    long long val = calc(i);
    if (cnt % 2)
      ans -= val;
    else
      ans += val;
    ans = md(ans);
  }
  cout << ans << "\n";
}

### Prompt

Please formulate 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>
#pragma GCC optimize("O3")
using namespace std;
const long long N = 3e5 + 10;
const long long N2 = 1e2 + 10;
const long long off = 1e3;
const long long inf = 1e18 + 10ll;
const long long mod = 998244353;
const double eps = 1e-7;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
long long n, m;
pair<long long, long long> a[N];
vector<pair<long long, long long> > es;
long long cnts[N];
long long f[N];
long long rf[N];
long long pref[N][41];
long long bpow(long long a, long long b) {
  if (b == 0) return 1;
  long long t = bpow(a, b / 2);
  if (b & 1) return t * t % mod * a % mod;
  return t * t % mod;
}
long long md(long long first) {
  if (first < 0) return first + mod;
  if (first >= mod) return first - mod;
  return first;
}
long long C(long long n, long long k) {
  if (n < k || min(n, k) < 0) return 0;
  return f[n] * rf[k] % mod * rf[n - k] % mod;
}
pair<long long, long long> unite(const pair<long long, long long> &p1,
                                 const pair<long long, long long> &p2) {
  if (p1.first == -1 || p2.first == -1) return {-1, -1};
  if (min(p1.second, p2.second) < max(p1.first, p2.first)) return {-1, -1};
  return {max(p1.first, p2.first), min(p1.second, p2.second)};
}
long long calc(long long msk) {
  set<long long> st;
  pair<long long, long long> un = {-2, -2};
  for (long long i = 0; i < m; ++i)
    if ((1ll << i) & msk) {
      if (un.first == -2) un = a[es[i].first];
      un = unite(un, a[es[i].first]);
      un = unite(un, a[es[i].second]);
      st.insert(es[i].first);
      st.insert(es[i].second);
    }
  long long cnt = st.size();
  if (un.first == -1) return 0;
  return md(pref[un.second][cnt] - pref[un.first - 1][cnt]);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(20);
  f[0] = 1;
  rf[0] = 1;
  for (long long i = 1; i < N; ++i) {
    f[i] = f[i - 1] * i % mod;
    rf[i] = bpow(f[i], mod - 2);
  }
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  es.resize(m);
  for (long long i = 0; i < m; ++i) {
    cin >> es[i].first >> es[i].second;
    --es[i].first;
    --es[i].second;
  }
  for (long long i = 0; i < n; ++i) {
    ++cnts[a[i].first];
    --cnts[a[i].second + 1];
  }
  for (long long i = 1; i < N; ++i) cnts[i] += cnts[i - 1];
  for (long long k = 1; k <= 40; ++k) {
    for (long long i = 0; i <= n; ++i) pref[i][k] = C(cnts[i] - k, i - k);
    for (long long i = 1; i <= n; ++i)
      pref[i][k] = md(pref[i][k] + pref[i - 1][k]);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) ans = md(ans + C(cnts[i], i));
  for (long long i = 1; i < (1ll << m); ++i) {
    long long cnt = 0;
    for (long long j = 0; j < m; ++j)
      if ((1ll << j) & i) ++cnt;
    long long val = calc(i);
    if (cnt % 2)
      ans -= val;
    else
      ans += val;
    ans = md(ans);
  }
  cout << ans << "\n";
}

```