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 long long mod = 998244353;
const int N = 3e5 + 2;
int n, m, cnt[N], visit[N];
long long gt[N], inv[N], dp[N][41];
pair<int, int> a[N];
vector<pair<int, int> > v;
long long Pow(long long x, long long y) {
  if (y == 0) return 1;
  long long res = Pow(x, y / 2);
  if (y % 2) return res * res % mod * x % mod;
  return res * res % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    cnt[a[i].first]++;
    cnt[a[i].second + 1]--;
  }
  for (int i = 1; i <= n; i++) {
    cnt[i] += cnt[i - 1];
  }
  v = vector<pair<int, int> >(m);
  for (int i = 0; i < m; i++) {
    cin >> v[i].first >> v[i].second;
  }
  gt[0] = 1;
  for (int i = 1; i <= n; i++) {
    gt[i] = (gt[i - 1] * (long long)i) % mod;
  }
  inv[0] = 1;
  for (int i = 1; i <= n; i++) {
    inv[i] = Pow(gt[i], mod - 2);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 2 * m; j++) {
      long long t = (j > i || i > cnt[i]) ? 0
                                          : gt[cnt[i] - j] * inv[i - j] % mod *
                                                inv[cnt[i] - i] % mod;
      dp[i][j] = (dp[i - 1][j] + t) % mod;
    }
  }
  long long ans = 0, coef[2] = {1, -1};
  for (int i = 1; i <= n; i++) {
    if (cnt[i] < i) continue;
    ans = (ans + gt[cnt[i]] * inv[i] % mod * inv[cnt[i] - i] % mod) % mod;
  }
  vector<int> v1;
  for (int mask = 1; mask < (1 << m); mask++) {
    int bit_cnt = 0, l = -N, r = N;
    v1.clear();
    for (int i = 0; i < m; i++) {
      if ((mask >> i) & 1) {
        bit_cnt++;
        if (!visit[v[i].first]) {
          visit[v[i].first] = 1;
          v1.push_back(v[i].first);
          l = max(l, a[v[i].first].first);
          r = min(r, a[v[i].first].second);
        }
        if (!visit[v[i].second]) {
          visit[v[i].second] = 1;
          v1.push_back(v[i].second);
          l = max(l, a[v[i].second].first);
          r = min(r, a[v[i].second].second);
        }
      }
    }
    if (l <= r) {
      int t = v1.size();
      ans = (ans + mod +
             coef[bit_cnt % 2] * ((dp[r][t] - dp[l - 1][t] + mod) % mod)) %
            mod;
    }
    for (int i = 0; i < v1.size(); i++) {
      visit[v1[i]] = 0;
    }
  }
  cout << ans << endl;
}