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>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;
namespace {
const int MOD107 = 1000000007;
const int MOD998 = 998244353;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using maxheap = priority_queue<T, vector<T>, less<T>>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct Modular {
 private:
  long long MODVALUE = 0;
  long long val = 0;
  Modular initModular(long long val) const { return Modular(val, MODVALUE); }
  inline void validate() const {}
  inline void validate(const Modular& other) const {}

 public:
  explicit operator long long() const { return val; }
  template <class T>
  Modular& operator=(const T& other) {
    val = other;
    return *this;
  }
  template <class T>
  void setMod(const T& MOD) {
    MODVALUE = MOD;
  }
  Modular& operator+=(const Modular& other) {
    validate(other);
    val += other.val;
    val %= MODVALUE;
    return *this;
  }
  Modular operator+(const Modular& other) const {
    Modular tmp = *this;
    return tmp += other;
  }
  template <class T>
  Modular& operator+=(const T& other) {
    return *this += initModular(other);
  }
  template <class T>
  Modular operator+(const T& other) const {
    return *this + initModular(other);
  }
  template <class T>
  friend Modular operator+(const T& other, const Modular& m) {
    return m.initModular(other) + m;
  }
  Modular& operator++() { return *this += 1; }
  Modular operator++(int) {
    Modular tmp = *this;
    ++*this;
    return tmp;
  }
  Modular operator-() const { return initModular(-val); }
  Modular& operator-=(const Modular& other) {
    validate(other);
    val -= other.val;
    val += MODVALUE;
    val %= MODVALUE;
    return *this;
  }
  Modular operator-(const Modular& other) const {
    Modular tmp = *this;
    return tmp -= other;
  }
  template <class T>
  Modular& operator-=(const T& other) {
    return *this -= initModular(other);
  }
  template <class T>
  Modular operator-(const T& other) const {
    return *this - initModular(other);
  }
  template <class T>
  friend Modular operator-(const T& other, const Modular& m) {
    return m.initModular(other) - m;
  }
  Modular& operator--() { return *this -= 1; }
  Modular operator--(int) {
    Modular tmp = *this;
    --*this;
    return tmp;
  }
  Modular& operator*=(const Modular& other) {
    validate(other);
    val *= other.val;
    val %= MODVALUE;
    val += MODVALUE;
    val %= MODVALUE;
    return *this;
  }
  Modular operator*(const Modular& other) const {
    Modular tmp = *this;
    return tmp *= other;
  }
  template <class T>
  Modular& operator*=(const T& other) {
    return *this *= initModular(other);
  }
  template <class T>
  Modular operator*(const T& other) const {
    return *this * initModular(other);
  }
  template <class T>
  friend Modular operator*(const T& other, const Modular& m) {
    return m.initModular(other) * m;
  }
  Modular pow(long long power) const {
    Modular m = *this, ans = initModular(1);
    while (power) {
      if (power & 1) ans *= m;
      m *= m;
      power >>= 1;
    }
    return ans;
  }
  Modular pow(const Modular& other) const { return pow(other.val); }
  Modular inv() const { return pow(MODVALUE - 2); }
  Modular& operator/=(const Modular& other) {
    val *= other.inv().val;
    val %= MODVALUE;
    return *this;
  }
  Modular operator/(const Modular& other) const {
    Modular tmp = *this;
    return tmp /= other;
  }
  template <class T>
  Modular& operator/=(const T& other) {
    return *this /= initModular(other);
  }
  template <class T>
  Modular operator/(const T& other) const {
    return *this / initModular(other);
  }
  template <class T>
  friend Modular operator/(const T& other, const Modular& m) {
    return m.initModular(other) / m;
  }
  friend istream& operator>>(istream& in, Modular& m) {
    in >> m.val;
    m.val %= m.MODVALUE;
    m.val += m.MODVALUE;
    m.val %= m.MODVALUE;
    return in;
  }
  friend ostream& operator<<(ostream& out, const Modular& m) {
    return out << m.val;
  }
  Modular() {
    val = 0;
    MODVALUE = 0;
  }
  Modular(long long val, long long MOD)
      : MODVALUE(MOD), val((val % MOD + MOD) % MOD) {}
};
using Mint = Modular;
inline ll binpow(ll b, ll p, ll mod) {
  b %= mod;
  ll ans = 1;
  for (; p > 0; p >>= 1) {
    if (p & 1) {
      ans *= b;
      ans %= mod;
    }
    b *= b;
    b %= mod;
  }
  return ans;
}
inline ll max(ll a, int b) { return (a > b ? a : b); }
inline ll max(int a, ll b) { return (a > b ? a : b); }
inline ll min(ll a, int b) { return (a < b ? a : b); }
inline ll min(int a, ll b) { return (a < b ? a : b); }
template <class T>
inline bool chkmin(T& x, const T& y) {
  return x > y ? x = y, 1 : 0;
}
template <class T>
inline bool chkmax(T& x, const T& y) {
  return x < y ? x = y, 1 : 0;
}
}  // namespace
namespace IO {
template <class T>
inline void _R(T& x) {
  cin >> x;
}
template <class T1, class T2>
inline void _R(pair<T1, T2>& x) {
  _R(x.first);
  _R(x.second);
}
template <class T>
inline void _R(vector<T>& x) {
  for (auto& i : x) _R(i);
}
template <class T>
inline void _R(deque<T>& x) {
  for (auto& i : x) _R(i);
}
inline void R() {}
template <class T1, class... T2>
inline void R(T1& x, T2&... y) {
  _R(x);
  R(y...);
}
template <class T>
inline void _W(const T& x);
template <class T1, class T2>
inline void _W(const pair<T1, T2>& p);
template <class... T>
inline void _W(const vector<T...>& x);
template <class... T>
inline void _W(const deque<T...>& x);
template <class... T>
inline void _W(const forward_list<T...>& x);
template <class... T>
inline void _W(const list<T...>& x);
template <class... T>
inline void _W(const set<T...>& x);
template <class... T>
inline void _W(const multiset<T...>& x);
template <class... T>
inline void _W(const unordered_set<T...>& x);
template <class... T>
inline void _W(const unordered_multiset<T...>& x);
template <class... T>
inline void _W(const map<T...>& x);
template <class... T>
inline void _W(const multimap<T...>& x);
template <class... T>
inline void _W(const unordered_map<T...>& x);
template <class... T>
inline void _W(const unordered_multimap<T...>& x);
template <class Container>
inline void printContainer(const Container& x) {
  bool isFirst = 1;
  for (auto i : x) {
    if (!isFirst) cout << ' ';
    isFirst = 0;
    _W(i);
  }
}
template <class T>
inline void _W(const T& x) {
  cout << x;
}
template <class T1, class T2>
inline void _W(const pair<T1, T2>& p) {
  _W(p.first);
  _W(' ');
  _W(p.second);
}
template <class... T>
inline void _W(const vector<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const deque<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const forward_list<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const list<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const set<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const multiset<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const unordered_set<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const unordered_multiset<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const map<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const multimap<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const unordered_map<T...>& x) {
  printContainer(x);
}
template <class... T>
inline void _W(const unordered_multimap<T...>& x) {
  printContainer(x);
}
inline void W() { cout << '\n'; }
template <class T>
inline void W(const T& x) {
  _W(x);
  W();
}
template <class T1, class... T2>
inline void W(const T1& x, const T2&... y) {
  _W(x);
  _W(' ');
  W(y...);
}
}  // namespace IO
using namespace IO;
namespace outputFormat {
inline string Case(int tc) { return "Case #" + to_string(tc) + ':'; }
inline string YN(bool b) { return b ? "Yes" : "No"; }
}  // namespace outputFormat
using namespace outputFormat;
namespace std {
template <class T1, class T2>
struct hash<pair<T1, T2>> {
  std::size_t operator()(pair<T1, T2> _) const {
    return hash<T1>{}(_.first) ^ hash<T2>{}(_.second);
  }
};
}  // namespace std
const Mint ZERO = Mint(0, MOD998);
int main() {
  int n, m;
  R(n, m);
  vector<pii> a(n);
  R(a);
  vector<pii> b(m);
  R(b);
  vector<int> cnt(n + 7, 0);
  for (auto& i : a) {
    cnt[i.first]++;
    cnt[i.second + 1]--;
  }
  for (int i = 1; i <= n; i++) cnt[i] += cnt[i - 1];
  vector<Mint> fact(n + 7, Mint(1, MOD998)), inv = fact;
  for (int i = 2; i <= n; i++) fact[i] = fact[i - 1] * i;
  inv[n] = fact[n].inv();
  for (int i = n; i >= 2; i--) inv[i - 1] = inv[i] * i;
  auto C = [&](int n, int r) {
    if (n == 0 && r == 0) return Mint(1, MOD998);
    if (n < 0 || r < 0) return Mint(0, MOD998);
    if (n < r) return Mint(0, MOD998);
    return fact[n] * inv[r] * inv[n - r];
  };
  vector<vector<Mint>> binom(50, vector<Mint>(n + 7, Mint(0, MOD998)));
  for (int k = 0; k < 50; k++)
    for (int i = 1; i <= n; i++)
      binom[k][i] = C(cnt[i] - k, i - k) + binom[k][i - 1];
  auto get = [&](int k, int l, int r) {
    if (l > r) return Mint(0, MOD998);
    return binom[k][r] - binom[k][l - 1];
  };
  Mint ans = Mint(0, MOD998);
  for (int mask = 0; mask < (1 << m); mask++) {
    int coef = (__builtin_popcount(mask) % 2 == 0 ? +1 : -1);
    vector<int> taken;
    int L = 1, R = n;
    for (int i = 0; i < m; i++) {
      if (mask & (1 << i)) {
        taken.push_back(b[i].first);
        taken.push_back(b[i].second);
        chkmax(L, a[b[i].first - 1].first);
        chkmax(L, a[b[i].second - 1].first);
        chkmin(R, a[b[i].first - 1].second);
        chkmin(R, a[b[i].second - 1].second);
      }
    }
    sort((taken).begin(), (taken).end());
    taken.resize(unique((taken).begin(), (taken).end()) - taken.begin());
    const int sz = taken.size();
    ans += coef * get(sz, L, R);
  }
  W(ans);
  return 0;
}
static auto __init__ = []() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  return 42;
}();