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;
template <typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
  return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template <typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
  for (Tp current = _begin; current != _end; ++current) {
    std::cout << *current << _delim;
  }
  std::cout << '\n';
}
using ll = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);
constexpr int MAXN = 300000;
constexpr int kMod = 998244353;
int line[MAXN + 5];
int val[MAXN + 5][41];
int fact[MAXN + 5];
int ifact[MAXN + 5];
int Add(int x, int y) {
  x += y;
  return x < kMod ? x : x - kMod;
}
int Sub(int x, int y) {
  x -= y;
  return x >= 0 ? x : x + kMod;
}
int Mul(int x, int y) { return int(1LL * x * y % kMod); }
int FastPow(int x, int p) {
  int res = 1;
  while (p > 0) {
    if (p & 1) {
      res = Mul(res, x);
    }
    p >>= 1;
    x = Mul(x, x);
  }
  return res;
}
int Inv(int x) { return FastPow(x, kMod - 2); }
int C(int k, int n) {
  if (k > n || k < 0 || n < 0) {
    return 0;
  }
  return Mul(fact[n], Mul(ifact[k], ifact[n - k]));
}
void Init() {
  fact[0] = fact[1] = 1;
  for (int i = 2; i <= MAXN; ++i) {
    fact[i] = Mul(fact[i - 1], i);
  }
  ifact[MAXN] = Inv(fact[MAXN]);
  for (int i = MAXN; i > 0; --i) {
    ifact[i - 1] = Mul(ifact[i], i);
  }
}
pii Intersect(pii a, pii b) {
  return {max(a.first, b.first), min(a.second, b.second)};
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  Init();
  int n, m;
  cin >> n >> m;
  vector<pii> arr(n);
  for (int i = 0; i < (n); ++i) {
    cin >> arr[i].first >> arr[i].second;
    ++line[arr[i].first];
    --line[arr[i].second + 1];
  }
  int k = 0;
  for (int i = 1; i <= MAXN; ++i) {
    k += line[i];
    for (int j = 0; j <= 40; ++j) {
      val[i][j] = Add(val[i - 1][j], C(i - j, k - j));
    }
  }
  vector<pii> edges(m);
  for (int i = 0; i < (m); ++i) {
    cin >> edges[i].first >> edges[i].second;
    --edges[i].first;
    --edges[i].second;
  }
  const int full_mask = 1 << m;
  vector<int> kbit(full_mask, 0);
  set<int> verts;
  int ans = 0;
  for (int mask = 0; mask < full_mask; ++mask) {
    kbit[mask] = kbit[mask >> 1] + (mask & 1);
    pii seg{1, MAXN};
    verts.clear();
    for (int b = 0; b < m; ++b) {
      if ((mask >> b) & 1) {
        seg = Intersect(seg,
                        Intersect(arr[edges[b].first], arr[edges[b].second]));
        if (seg.first > seg.second) {
          break;
        }
        verts.insert(edges[b].first);
        verts.insert(edges[b].second);
      }
    }
    if (seg.first > seg.second) {
      continue;
    }
    if (kbit[mask] & 1) {
      ans = Sub(ans, Sub(val[seg.second][static_cast<int>((verts).size())],
                         val[seg.first - 1][static_cast<int>((verts).size())]));
    } else {
      ans = Add(ans, Sub(val[seg.second][static_cast<int>((verts).size())],
                         val[seg.first - 1][static_cast<int>((verts).size())]));
    }
  }
  cout << ans << "\n";
  return 0;
}