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 + 5;
int n, m, l[N], r[N], a[N], b[N];
long long ans, fac[N], inv[N], sum[N][41];
struct Seg {
  int val, tag;
} t[N << 2];
void push_down(int o, int l, int r) {
  int ls = o << 1, rs = o << 1 | 1;
  t[ls].tag += t[o].tag, t[rs].tag += t[o].tag;
  int mid = (l + r) >> 1;
  t[ls].val += (mid - l + 1) * t[o].tag;
  t[rs].val += (r - mid) * t[o].tag;
  t[o].tag = 0;
}
int query(int o, int l, int r, int x) {
  if (l == r) return t[o].val;
  int mid = (l + r) >> 1;
  push_down(o, l, r);
  if (x <= mid)
    return query(o << 1, l, mid, x);
  else
    return query(o << 1 | 1, mid + 1, r, x);
}
void update(int o, int l, int r, int x, int y, int k) {
  if (x <= l && r <= y) {
    t[o].val += (r - l + 1) * k;
    t[o].tag += k;
    return;
  }
  push_down(o, l, r);
  int mid = (l + r) >> 1;
  if (x <= mid) update(o << 1, l, mid, x, y, k);
  if (mid < y) update(o << 1 | 1, mid + 1, r, x, y, k);
  t[o].val = t[o << 1].val + t[o << 1 | 1].val;
}
long long Ksm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    b /= 2;
    a = a * a % mod;
  }
  return res;
}
long long cal(int n, int k) {
  if (n < k || min(n, k) < 0) return 0;
  return fac[n] * inv[k] % mod * inv[n - k] % mod;
}
int get(int s) {
  int f = 0;
  for (register int i = 0; i <= 27; i++)
    if (s & (1 << i)) f++;
  return f;
}
map<int, int> M;
int work(int s) {
  M.clear();
  int ans = 0;
  for (register int i = 0; i <= 27; i++)
    if (s & (1 << i)) {
      if (!M[a[i + 1]]) ans++, M[a[i + 1]] = 1;
      if (!M[b[i + 1]]) ans++, M[b[i + 1]] = 1;
    }
  return ans;
}
struct node {
  int l, r;
  bool operator==(const node &rhs) const { return l == rhs.l && r == rhs.r; }
} p[1 << 21];
void merge(node &a, node b) {
  a.l = max(a.l, b.l);
  a.r = min(a.r, b.r);
}
int main() {
  cin >> n >> m;
  for (register int i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    update(1, 1, n, l[i], r[i], 1);
  }
  fac[0] = inv[0] = 1;
  for (register int i = 1; i <= n; i++)
    fac[i] = fac[i - 1] * i % mod, inv[i] = Ksm(fac[i], mod - 2);
  for (register int i = 1; i <= n; i++) {
    ans = (ans + cal(query(1, 1, n, i), i)) % mod;
    for (register int j = 0; j <= 40; j++)
      sum[i][j] = (sum[i - 1][j] + cal(query(1, 1, n, i) - j, i - j)) % mod;
  }
  for (register int i = 1; i <= m; i++) cin >> a[i] >> b[i];
  int S = (1 << m) - 1;
  p[0].l = 1, p[0].r = n;
  for (register int i = 1; i <= S; i++) {
    int f = get(i) & 1 ? -1 : 1;
    int siz = work(i);
    node tmp;
    bool fir = true;
    for (register int j = 27; j >= 0; j--)
      if (i & (1 << j)) {
        int t = i ^ (1 << j);
        p[i] = p[t];
        merge(p[i], (node){l[a[j + 1]], r[a[j + 1]]});
        merge(p[i], (node){l[b[j + 1]], r[b[j + 1]]});
        if (fir) {
          fir = false;
          tmp = p[i];
        } else
          assert(tmp == p[i]);
        if (p[i].l > p[i].r) break;
        ans =
            (ans + 1ll * f * (sum[p[i].r][siz] - sum[p[i].l - 1][siz]) % mod) %
            mod;
        break;
      }
  }
  cout << (ans + mod) % mod << endl;
}