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 int MOD = 998244353;
int n, m;
int l[300005], r[300005];
pair<int, int> hate[25];
int fact[300005], inv_fact[300005];
vector<int> hater, parent;
vector<vector<int>> components;
vector<vector<vector<int>>> component_dp;
int add(int a, int b) { return (((long long)a + b) % MOD + MOD) % MOD; }
int mul(int a, int b) { return ((long long)a * b) % MOD; }
int power(int a, int p) {
  int res = 1;
  while (p > 0) {
    if (p & 1) res = mul(res, a);
    a = mul(a, a);
    p >>= 1;
  }
  return res;
}
int find_parent(int a) {
  if (a == parent[a])
    return a;
  else
    return parent[a] = find_parent(parent[a]);
}
void merge(int a, int b) {
  a = find_parent(a);
  b = find_parent(b);
  if (a != b) {
    parent[b] = a;
  }
}
void build_factorial() {
  fact[0] = inv_fact[0] = 1;
  for (int i = 1; i <= 300000; i++) {
    fact[i] = mul(fact[i - 1], i);
    inv_fact[i] = power(fact[i], MOD - 2);
  }
}
void build_components() {
  for (int i = 0; i < m; i++) {
    hater.push_back(hate[i].first);
    hater.push_back(hate[i].second);
  }
  sort(hater.begin(), hater.end());
  hater.resize(unique(hater.begin(), hater.end()) - hater.begin());
  parent.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    parent[i] = i;
  }
  for (int i = 0; i < m; i++) {
    merge(hate[i].first, hate[i].second);
  }
  for (int i = 0; i < hater.size(); i++) {
    int j = 0;
    while (j < components.size() &&
           find_parent(components[j].back()) != find_parent(hater[i])) {
      j++;
    }
    if (j == components.size()) components.push_back(vector<int>());
    components[j].push_back(hater[i]);
  }
}
void build_component_dp() {
  component_dp.assign(components.size() + 1, vector<vector<int>>());
  for (int c = 0; c < components.size(); c++) {
    vector<int> &component = components[c];
    int C = component.size();
    vector<vector<int>> &dp = component_dp[c];
    dp.assign(1 << C, vector<int>(C + 1));
    vector<vector<bool>> bad(C + 1, vector<bool>(C + 1, false));
    for (int i = 0; i < C; i++) {
      for (int j = 0; j < C; j++) {
        for (int k = 0; k < m; k++) {
          if (component[i] == hate[k].first && component[j] == hate[k].second) {
            bad[i][j] = bad[j][i] = true;
          }
        }
      }
    }
    for (int mask = 0; mask < (1 << C); mask++) {
      bool valid = true;
      for (int i = 0; i < C && valid; i++) {
        if (~mask & (1 << i)) continue;
        for (int j = 0; j < C && valid; j++) {
          if (~mask & (1 << j)) continue;
          if (bad[i][j]) valid = false;
        }
      }
      if (valid) {
        dp[mask][__builtin_popcount(mask)]++;
      }
    }
    for (int bit = 0; bit < C; bit++) {
      for (int mask = 0; mask < (1 << C); mask++) {
        if (~mask & (1 << bit)) continue;
        for (int k = 0; k < C; k++) {
          dp[mask][k] = add(dp[mask][k], dp[mask ^ (1 << bit)][k]);
        }
      }
    }
  }
}
int choose(int a, int b) {
  if (a < 0 || b < 0 || a < b) return 0;
  return mul(fact[a], mul(inv_fact[b], inv_fact[a - b]));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> hate[i].first >> hate[i].second;
  }
  build_factorial();
  build_components();
  build_component_dp();
  vector<int> freq(n + 2);
  for (int i = 1; i <= n; i++) {
    freq[l[i]]++;
    freq[r[i] + 1]--;
  }
  for (int i = 1; i <= n; i++) {
    freq[i] += freq[i - 1];
  }
  int ans = 0;
  for (int cnt = 1; cnt <= n; cnt++) {
    int merc = freq[cnt];
    int in_component = 0;
    vector<int> knapsack(2 * m + 5, 0);
    knapsack[0] = 1;
    for (int c = 0; c < components.size(); c++) {
      vector<int> &component = components[c];
      int C = component.size();
      int mask = 0;
      for (int i = 0; i < C; i++) {
        if (l[component[i]] <= cnt && cnt <= r[component[i]]) {
          mask |= (1 << i);
        }
      }
      in_component += __builtin_popcount(mask);
      for (int count = m - 1; count >= 0; count--) {
        for (int take = 1; take <= C; take++) {
          knapsack[count + take] =
              add(knapsack[count + take],
                  mul(knapsack[count], component_dp[c][mask][take]));
        }
      }
    }
    for (int taken = 0; taken <= m; taken++) {
      ans = add(ans,
                mul(knapsack[taken], choose(merc - in_component, cnt - taken)));
    }
  }
  cout << ans << "\n";
  return 0;
}