#include <bits/stdc++.h>
using namespace std;
bool chkmin(int &x, int y) { return x > y ? x = y, 1 : 0; }
bool chkmax(int &x, int y) { return x < y ? x = y, 1 : 0; }
int readint() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int cys = 1000000007;
int n, m1, m2, s, ncnt;
long long l[200005], r[200005], c[200005], pw[200005];
vector<pair<int, int> > cl[5];
map<int, vector<pair<int, int> > > v;
long long mod(long long x) { return x >= cys ? x - cys : x; }
long long qpow(long long x, long long p) {
  long long ret = 1;
  for (; p; p >>= 1, x = x * x % cys)
    if (p & 1) ret = ret * x % cys;
  return ret;
}
namespace sgt1 {
int ncnt, rt;
long long val[3000000];
int lch[3000000], rch[3000000];
void change(int &id, int l, int r, int x, long long c) {
  if (!id) id = ++ncnt;
  if (l == r) return (void)(val[id] = mod(val[id] + c));
  int mid = (l + r) / 2;
  if (x <= mid)
    change(lch[id], l, mid, x, c);
  else
    change(rch[id], mid + 1, r, x, c);
  val[id] = mod(val[lch[id]] + val[rch[id]]);
}
long long query(int id, int l, int r, int ql, int qr) {
  if (!id) return 0;
  if (l == ql && r == qr) return val[id];
  int mid = (l + r) / 2;
  if (qr <= mid)
    return query(lch[id], l, mid, ql, qr);
  else if (ql > mid)
    return query(rch[id], mid + 1, r, ql, qr);
  else
    return mod(query(lch[id], l, mid, ql, mid) +
               query(rch[id], mid + 1, r, mid + 1, qr));
}
}  // namespace sgt1
namespace sgt2 {
struct node {
  int lch, rch;
  long long val;
} t[5000000];
int rt[5];
void change(int &id, int l, int r, int x, long long c) {
  if (!id) id = ++ncnt;
  if (l == r) return (void)(t[id].val = mod(t[id].val + c));
  int mid = (l + r) / 2;
  if (x <= mid)
    change(t[id].lch, l, mid, x, c);
  else
    change(t[id].rch, mid + 1, r, x, c);
  t[id].val = mod(t[t[id].lch].val * qpow((cys + 1) / 2, r - mid) % cys +
                  t[t[id].rch].val);
}
long long query(int id, int l, int r, int ql, int qr) {
  if (!id) return 0;
  if (l == ql && r == qr) return t[id].val;
  int mid = (l + r) / 2;
  if (qr <= mid)
    return query(t[id].lch, l, mid, ql, qr);
  else if (ql > mid)
    return query(t[id].rch, mid + 1, r, ql, qr);
  else
    return mod(query(t[id].lch, l, mid, ql, mid) *
                   qpow((cys + 1) / 2, qr - mid) % cys +
               query(t[id].rch, mid + 1, r, mid + 1, qr));
}
}  // namespace sgt2
int main() {
  s = 2;
  n = readint();
  m1 = readint();
  m2 = readint();
  int x, y;
  for (int i = 1; i <= m1; i++) {
    x = readint();
    y = readint();
    cl[1].push_back(make_pair(y, -x));
  }
  for (int i = 1; i <= m2; i++) {
    x = readint();
    y = readint();
    cl[2].push_back(make_pair(y, -x));
  }
  for (int i = 1; i <= s; i++) sort(cl[i].begin(), cl[i].end());
  for (int i = 1; i <= s; i++) {
    if (!cl[i].size()) continue;
    v[-cl[i][0].second].push_back(make_pair(cl[i][0].first, i));
    int mx = -cl[i][0].second;
    for (int j = 1; j < cl[i].size(); j++) {
      if (cl[i][j].second == cl[i][j - 1].second) continue;
      if (-cl[i][j].second <= mx) continue;
      chkmax(mx, -cl[i][j].second);
      v[-cl[i][j].second].push_back(make_pair(cl[i][j].first, i));
    }
  }
  sgt1::change(sgt1::rt, 0, n, 0, qpow(s, n));
  for (auto x : v) {
    int i = x.first - 1;
    auto t = x.second;
    sort(t.begin(), t.end());
    for (auto x : t) {
      long long tmp1 =
          sgt1::query(1, 0, n, 0, i) * qpow((cys + 1) / 2, x.first - i) % cys;
      long long tmp2 = sgt2::query(sgt2::rt[x.second], 1, n, i + 1, x.first);
      sgt1::change(sgt1::rt, 0, n, x.first, mod(cys + cys - tmp1 - tmp2));
      sgt2::change(sgt2::rt[x.second], 1, n, x.first,
                   mod(cys + cys - tmp1 - tmp2));
    }
  }
  printf("%lld\n", sgt1::val[sgt1::rt]);
  return 0;
}
