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;
long long mod = (998244353LL);
inline long long Mod(long long a, long long b) { return (a % b); }
inline long long poww(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b) {
    a %= b, swap(a, b);
  }
  return a;
}
void read(vector<long long> &w, long long n) {
  w.resize(n);
  for (long long i = 0; i < n; i++) cin >> w[i];
}
void print(vector<long long> &w) {
  for (long long i = 0; i < (long long)(w).size(); i++) {
    if (i == (long long)(w).size() - 1)
      cout << w[i] << "\n";
    else
      cout << w[i] << " ";
  }
}
long long prodmod(vector<long long> w);
void crivo(vector<long long> &w, long long TAM);
void inverso(vector<long long> &inv, long long TAM);
void fat_inverso(vector<long long> &inv, long long TAM);
long long choose(long long a, long long b);
void get_fat();
long long fat[300010];
long long n, m, q, k, v[300010];
long long sum[300010][100], ans;
pair<long long, long long> w[300010];
string second;
vector<long long> ini, fim;
vector<long long> invv;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  vector<pair<long long, long long> > edge;
  fat_inverso(invv, 300010);
  for (long long i = 1; i <= n; i++) {
    cin >> w[i].first >> w[i].second;
    ini.push_back(w[i].first);
    fim.push_back(w[i].second);
  }
  for (long long i = 1, a, b; i <= m; i++) {
    cin >> a >> b;
    edge.push_back({a, b});
  }
  sort(begin(ini), end(ini));
  sort(begin(fim), end(fim));
  vector<long long> qtd(n + 1);
  long long ans = 0;
  for (long long k = 1; k <= n; k++) {
    long long A = upper_bound(begin(fim), end(fim), k - 1) -
                  lower_bound(begin(fim), end(fim), 0);
    long long B = upper_bound(begin(ini), end(ini), n + 1) -
                  lower_bound(begin(ini), end(ini), k + 1);
    A += B;
    qtd[k] = n - A;
    for (long long p = 0; p <= 40; p++) {
      sum[k][p] =
          sum[k - 1][p] + (min(qtd[k], k) < p ? 0 : choose(qtd[k] - p, k - p));
      sum[k][p] %= mod;
    }
  }
  vector<long long> caras(n + 1);
  for (long long mask = 0; mask < (1 << (long long)(edge).size()); mask++) {
    long long l = 1, r = n, p = 0;
    vector<long long> T;
    for (long long i = 0; i < (long long)(edge).size(); i++) {
      if (mask & (1 << i)) {
        l = max(l, w[edge[i].first].first);
        r = min(r, w[edge[i].first].second);
        l = max(l, w[edge[i].second].first);
        r = min(r, w[edge[i].second].second);
        if (!caras[edge[i].first]) p++;
        caras[edge[i].first] = 1;
        if (!caras[edge[i].second]) p++;
        caras[edge[i].second] = 1;
        T.push_back(edge[i].first), T.push_back(edge[i].second);
      }
    }
    for (auto w : T) caras[w] = 0;
    l = max(l, p);
    T.clear();
    if (l > r) continue;
    long long sign = (__builtin_popcount(mask) % 2 ? -1LL : 1LL);
    ans += sign * (sum[r][p] - sum[l - 1][p]);
    ans %= mod;
  }
  if (ans < 0) ans += mod;
  cout << ans << "\n";
}
long long prodmod(vector<long long> w) {
  long long curr = 1;
  for (long long i = 0; i < (long long)(w).size(); i++) {
    if (w[i] >= mod) w[i] %= mod;
    curr = (curr * w[i]) % mod;
    if (curr < 0) curr += mod;
  }
  return curr;
}
void get_fat() {
  if (fat[0] != 0) return;
  fat[0] = 1;
  for (long long i = 1; i < 300010; i++) fat[i] = (i * fat[i - 1]) % mod;
}
long long choose(long long a, long long b) {
  get_fat();
  if (b > a) return 0;
  if (!b) return 1;
  long long A = fat[a];
  long long B = (invv[b] * invv[a - b]) % mod;
  A = (A * B) % mod;
  return A;
}
void inverso(vector<long long> &inv, long long TAM) {
  inv.resize(TAM);
  inv[1] = inv[0] = 1;
  for (long long i = 2; i < TAM; ++i) {
    inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
  }
}
void fat_inverso(vector<long long> &inv, long long TAM) {
  inverso(inv, TAM);
  for (long long i = 2; i < TAM; i++) inv[i] = (inv[i] * inv[i - 1]) % mod;
}
void crivo(vector<long long> &w, long long TAM) {
  w.resize(TAM + 1);
  w[0] = 1;
  for (long long i = 2; i < TAM; i++)
    if (!w[i])
      for (long long j = 2 * i; j < TAM; j += i) w[j] = 1;
}