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;
inline long long read() {
  long long nm = 0;
  bool fh = true;
  char cw = getchar();
  for (; !isdigit(cw); cw = getchar()) fh ^= (cw == '-');
  for (; isdigit(cw); cw = getchar()) nm = nm * 10 + (cw - '0');
  return fh ? nm : -nm;
}
namespace CALC {
inline int add(int x, int y) {
  return (x + y >= 998244353) ? (x + y - 998244353) : (x + y);
}
inline int mns(int x, int y) {
  return (x - y < 0) ? (x - y + 998244353) : (x - y);
}
inline int mul(long long x, long long y) { return x * y % 998244353; }
inline void upd(int &x, int y) {
  x = (x + y >= 998244353) ? (x + y - 998244353) : (x + y);
}
inline void dec(int &x, int y) {
  x = (x - y < 0) ? (x - y + 998244353) : (x - y);
}
inline int qpow(int x, long long sq) {
  int res = 1;
  for (; sq; sq >>= 1, x = mul(x, x))
    if (sq & 1) res = mul(res, x);
  return res;
}
}  // namespace CALC
using namespace CALC;
int n, m, fac[300200], ifac[300200], sm[300200][42], ans;
int l[300200], r[300200], ct[300200], hv, L, R;
pair<int, int> a[300200];
vector<int> clr;
bool f[300200];
inline int C(int x, int y) {
  if (x < 0 || y < 0 || x < y) return 0;
  return mul(fac[x], mul(ifac[y], ifac[x - y]));
}
inline void _ins(int x) {
  if (f[x]) return;
  f[x] = true, clr.push_back(x), ++hv, L = max(L, l[x]), R = min(R, r[x]);
}
int main() {
  fac[0] = 1;
  for (int i = 1; i <= 300000; i++) fac[i] = mul(fac[i - 1], i);
  ifac[300000] = qpow(fac[300000], 998244353 - 2);
  for (int i = 300000 - 1; ~i; --i) ifac[i] = mul(ifac[i + 1], i + 1);
  n = read(), m = read();
  for (int i = 1; i <= n; i++)
    l[i] = read(), r[i] = read(), ct[l[i]]++, --ct[r[i] + 1];
  for (int i = 1; i <= m; i++) a[i].first = read(), a[i].second = read();
  for (int i = 1; i <= n; i++) ct[i] += ct[i - 1];
  for (int k = 0; k <= 40; k++)
    for (int i = 1; i <= n; i++)
      sm[i][k] = add(sm[i - 1][k], C(ct[i] - k, i - k));
  for (int s = 0; s < (1 << m); s++) {
    L = 1, R = n, clr.clear(), hv = 0;
    for (int i = 1; i <= m; i++)
      if (s & (1 << i - 1)) _ins(a[i].first), _ins(a[i].second);
    for (int i = 0, TP = clr.size(); i < TP; i++) f[clr[i]] = false;
    if (L > R) continue;
    int rem = mns(sm[R][hv], sm[L - 1][hv]);
    if (__builtin_popcount(s) & 1)
      dec(ans, rem);
    else
      upd(ans, rem);
  }
  printf("%d\n", ans);
  return 0;
}