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 N = 3e5 + 5;
const int mod = 998244353;
int add(int x, int y) { return ((x + y) % mod + mod) % mod; }
int mul(int x, int y) { return (long long)x * y % mod; }
int mypow(int x, int c) {
  int ret = 1;
  while (c > 0) {
    if (c & 1) {
      ret = mul(ret, x);
    }
    c /= 2;
    x = mul(x, x);
  }
  return ret;
}
int gcd(int x, int y) {
  if (x == 0) {
    return y;
  }
  return gcd(y % x, x);
}
int fac[N], inv[N];
int combi(int n, int r) {
  if (n < r || n < 0 || r < 0) {
    return 0;
  }
  return mul(fac[n], mul(inv[r], inv[n - r]));
}
void init() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = mul(fac[i - 1], i);
  }
  inv[N - 1] = mypow(fac[N - 1], mod - 2);
  for (int i = N - 2; i; --i) {
    inv[i] = mul(inv[i + 1], i + 1);
    assert(mul(inv[i], fac[i]) == 1);
  }
  inv[0] = 1;
}
int a[N], b[N];
int pre[N];
int u[N], v[N];
int dsu[N];
int f(int x) {
  if (x == dsu[x]) {
    return x;
  }
  return dsu[x] = f(dsu[x]);
}
bool merge(int x, int y) {
  x = f(x), y = f(y);
  if (x != y) {
    dsu[x] = y;
    return true;
  }
  return false;
}
const int B = 21;
const int EDGE = (1 << B);
int numVertex[EDGE];
int vis[N];
int numInvalid = 0;
struct knap {
  map<int, int> H;
  vector<int> dp, edgeCount;
  int curBit, numCount;
  void init(vector<int> nodes) {
    int pos = 0;
    sort(nodes.begin(), nodes.end());
    for (int node : nodes) {
      H[node] = pos++;
    }
    curBit = 0;
    dp.resize(nodes.size() + 1, 0);
    dp[0] = 1;
    edgeCount.resize((1 << nodes.size()), 0);
    numCount = 0;
  }
  void update(int x, int y, int v) {
    vis[x] += v;
    vis[y] += v;
    int a = H[x], b = H[y];
    if (!vis[x]) {
      curBit ^= (1 << a);
    } else {
      curBit |= (1 << a);
    }
    if (!vis[y]) {
      curBit ^= (1 << b);
    } else {
      curBit |= (1 << b);
    }
    for (int i = 0; i < dp.size(); ++i) {
      dp[i] = 0;
    }
    for (int i = 0; i < edgeCount.size(); ++i) {
      if ((i & (1 << a)) && (i & (1 << b))) {
        edgeCount[i] += v;
      }
      if ((i & curBit) == i && edgeCount[i] == 0) {
        ++dp[numVertex[i]];
      }
    }
    numCount = numVertex[curBit];
  }
};
knap bag[N];
vector<int> impBag;
void update(int x, int y, int g) {
  int id = f(x);
  bag[id].update(x, y, g);
}
vector<int> dp;
void construct() {
  dp.clear();
  dp.push_back(1);
  numInvalid = 0;
  for (int id : impBag) {
    vector<int> x = bag[id].dp;
    int sz = x.size() + dp.size();
    vector<int> tmp = vector<int>(x.size() + dp.size() - 1, 0);
    for (int i = 0; i < dp.size(); ++i) {
      for (int j = 0; j < x.size(); ++j) {
        tmp[i + j] = add(tmp[i + j], mul(dp[i], x[j]));
      }
    }
    numInvalid += bag[id].numCount;
    dp = tmp;
  }
}
void solve() {
  int n, m;
  scanf("%d %d ", &n, &m);
  init();
  for (int i = 0; i < EDGE; ++i) {
    numVertex[i] = numVertex[i / 2];
    if (i & 1) numVertex[i]++;
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &a[i], &b[i]);
    ++pre[a[i]];
    --pre[b[i] + 1];
  }
  vector<pair<int, int> > edge;
  for (int i = 1; i <= m; ++i) {
    int x, y;
    scanf("%d %d ", &u[i], &v[i]);
    dsu[u[i]] = u[i];
    dsu[v[i]] = v[i];
  }
  for (int i = 1; i <= m; ++i) merge(u[i], v[i]);
  for (int i = 1; i <= n; ++i) {
    if (f(i) == i) {
      impBag.push_back(i);
    }
  }
  for (int id : impBag) {
    vector<int> tmp;
    for (int i = n; i; --i)
      if (f(i) == id) tmp.push_back(i);
    bag[id].init(tmp);
  }
  for (int i = 1; i <= m; ++i) {
    int x, y;
    x = u[i], y = v[i];
    int ml = max(a[x], a[y]), mr = min(b[x], b[y]);
    if (ml <= mr) {
      edge.push_back({ml, i});
      edge.push_back({mr + 1, -i});
    }
  }
  sort(edge.begin(), edge.end());
  int numEdge = 0;
  int ret = 0;
  int pos = 0;
  construct();
  for (int i = 1; i <= n; ++i) {
    bool updated = false;
    while (pos < edge.size()) {
      if (edge[pos].first == i) {
        int eid = abs(edge[pos].second);
        updated = true;
        if (edge[pos].second < 0) {
          update(u[eid], v[eid], -1);
        } else {
          update(u[eid], v[eid], 1);
        }
        ++pos;
      } else {
        break;
      }
    }
    if (updated) {
      construct();
    }
    pre[i] += pre[i - 1];
    int num = pre[i] - numInvalid;
    for (int j = 0; j < dp.size() && j <= i; ++j) {
      ret = add(ret, mul(dp[j], combi(num, i - j)));
    }
  }
  printf("%d\n", ret);
}
int main() {
  solve();
  return 0;
}