#include <bits/stdc++.h>
#pragma GCC optimize( \
    "Ofast,unroll-loops,no-stack-protector,unsafe-math-optimizations")
#pragma GCC target("avx")
using namespace std;
inline int read_char() {
  static char buf[1 << 16], *ptr = buf, *end_ptr = buf;
  if (ptr == end_ptr) {
    int len = fread(buf, 1, sizeof(buf), stdin);
    if (len <= 0) return EOF;
    ptr = buf;
    end_ptr = buf + len;
  }
  return *ptr++;
}
inline int readint() {
  int t = 0;
  char c;
  bool negative = false;
  c = read_char();
  while (c < '0' && c > '9') {
    if (c == '-') negative = true;
    c = read_char();
  }
  while (c >= '0' && c <= '9') {
    t = (t << 3) + (t << 1) + c - '0';
    c = read_char();
  }
  if (negative) t = ~(t - 1);
  return t;
}
inline void printint(int a) {
  if (a == 0) {
    putchar('0');
    return;
  }
  char buf[10], x = 0;
  while (a) {
    buf[x++] = a % 10;
    a /= 10;
  }
  while (x) {
    putchar(buf[--x] + 48);
  }
}
long long modpow(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
    n >>= 1;
  }
  return res;
}
int n, a, b;
int xa[100005], ya[100005];
int xb[100005], yb[100005];
vector<pair<int, int> > A, B;
vector<pair<int, int> > c, d;
vector<int> za;
long long dp[400005][2];
long long dp2[100005][2];
long long dp3[100005][2];
struct RMQ {
  long long seg[(1 << 20)];
  void update(int k, long long a) {
    k += (1 << 20) / 2 - 1;
    seg[k] = (seg[k] + a) % 1000000007;
    while (k > 0) {
      k = (k - 1) / 2;
      seg[k] = (seg[k * 2 + 1] + seg[k * 2 + 2]) % 1000000007;
    }
  }
  long long query(int a, int b, int k, int l, int r) {
    if (r < a || b < l || a > b) return 0;
    if (a <= l && r <= b)
      return seg[k];
    else {
      long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      long long vr = query(a, b, k * 2 + 2, (l + r) / 2 + 1, r);
      return (vl + vr) % 1000000007;
    }
  }
  long long query(int a, int b) { return query(a, b, 0, 0, (1 << 20) / 2 - 1); }
} kaede[2], kaede2[2], kaede3[2];
int main() {
  n = readint();
  a = readint();
  b = readint();
  for (int i = 1; i <= a; i++) {
    xa[i] = readint();
    ya[i] = readint();
    za.push_back(xa[i]);
    za.push_back(ya[i]);
    A.push_back(make_pair(xa[i], -ya[i]));
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < A.size(); i++) {
    while (c.size() && c[c.size() - 1].second <= A[i].second) {
      c.pop_back();
    }
    { c.push_back(A[i]); }
  }
  for (int i = 0; i < c.size(); i++) c[i].second *= -1;
  for (int i = 1; i <= b; i++) {
    xb[i] = readint();
    yb[i] = readint();
    za.push_back(xb[i]);
    za.push_back(yb[i]);
    B.push_back(make_pair(xb[i], -yb[i]));
  }
  sort(B.begin(), B.end());
  for (int i = 0; i < B.size(); i++) {
    while (d.size() && d[d.size() - 1].second <= B[i].second) {
      d.pop_back();
    }
    { d.push_back(B[i]); }
  }
  for (int i = 0; i < d.size(); i++) d[i].second *= -1;
  za.push_back(0);
  sort(za.begin(), za.end());
  za.erase(unique(za.begin(), za.end()), za.end());
  dp[0][0] = 1;
  kaede[0].update(0, 1);
  int nxtc = 0, nxtd = 0;
  for (int i = 1; i < za.size(); i++) {
    if (nxtc != c.size() && za[i] == c[nxtc].second) {
      int lb = -1, ub = nxtc;
      while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (c[mid].second < c[nxtc].first)
          lb = mid;
        else
          ub = mid;
      }
      dp2[nxtc][0] = kaede2[1].query(ub, nxtc - 1);
      dp2[nxtc][1] = kaede2[0].query(ub, nxtc - 1);
      int k = (lower_bound(za.begin(), za.end(), c[nxtc].first) - za.begin());
      dp2[nxtc][0] += modpow(2LL, c[nxtc].first - 1) *
                      kaede[1].query(0, k - 1) % 1000000007;
      dp2[nxtc][1] += modpow(2LL, c[nxtc].first - 1) *
                      kaede[0].query(0, k - 1) % 1000000007;
      dp2[nxtc][0] %= 1000000007;
      dp2[nxtc][1] %= 1000000007;
      kaede2[0].update(nxtc, dp2[nxtc][0]);
      kaede2[1].update(nxtc, dp2[nxtc][1]);
      kaede[0].update(i,
                      dp2[nxtc][0] *
                          modpow(modpow(2LL, c[nxtc].second), 1000000007 - 2) %
                          1000000007);
      kaede[1].update(i,
                      dp2[nxtc][1] *
                          modpow(modpow(2LL, c[nxtc].second), 1000000007 - 2) %
                          1000000007);
      nxtc++;
    }
    if (nxtd != d.size() && za[i] == d[nxtd].second) {
      int lb = -1, ub = nxtd;
      while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (d[mid].second < d[nxtd].first)
          lb = mid;
        else
          ub = mid;
      }
      dp3[nxtd][0] = kaede3[1].query(ub, nxtd - 1);
      dp3[nxtd][1] = kaede3[0].query(ub, nxtd - 1);
      int k = (lower_bound(za.begin(), za.end(), d[nxtd].first) - za.begin());
      dp3[nxtd][0] += modpow(2LL, d[nxtd].first - 1) *
                      kaede[1].query(0, k - 1) % 1000000007;
      dp3[nxtd][1] += modpow(2LL, d[nxtd].first - 1) *
                      kaede[0].query(0, k - 1) % 1000000007;
      dp3[nxtd][0] %= 1000000007;
      dp3[nxtd][1] %= 1000000007;
      kaede3[0].update(nxtd, dp3[nxtd][0]);
      kaede3[1].update(nxtd, dp3[nxtd][1]);
      kaede[0].update(i,
                      dp3[nxtd][0] *
                          modpow(modpow(2LL, d[nxtd].second), 1000000007 - 2) %
                          1000000007);
      kaede[1].update(i,
                      dp3[nxtd][1] *
                          modpow(modpow(2LL, d[nxtd].second), 1000000007 - 2) %
                          1000000007);
      nxtd++;
    }
  }
  long long pl = kaede[0].query(0, za.size() - 1);
  pl = pl * modpow(2LL, n) % 1000000007;
  long long ge = kaede[1].query(0, za.size() - 1);
  ge = ge * modpow(2LL, n) % 1000000007;
  long long all = modpow(2LL, n);
  printint((pl - ge + 1000000007) % 1000000007);
}
