Arkady and Kirill visited an exhibition of rare coins. The coins were located in a row and enumerated from left to right from 1 to k, each coin either was laid with its obverse (front) side up, or with its reverse (back) side up.

Arkady and Kirill made some photos of the coins, each photo contained a segment of neighboring coins. Akrady is interested in obverses, so on each photo made by him there is at least one coin with obverse side up. On the contrary, Kirill is interested in reverses, so on each photo made by him there is at least one coin with its reverse side up.

The photos are lost now, but Arkady and Kirill still remember the bounds of the segments of coins each photo contained. Given this information, compute the remainder of division by 109 + 7 of the number of ways to choose the upper side of each coin in such a way, that on each Arkady's photo there is at least one coin with obverse side up, and on each Kirill's photo there is at least one coin with reverse side up.

Input

The first line contains three integers k, n and m (1 ≤ k ≤ 109, 0 ≤ n, m ≤ 105) — the total number of coins, the number of photos made by Arkady, and the number of photos made by Kirill, respectively.

The next n lines contain the descriptions of Arkady's photos, one per line. Each of these lines contains two integers l and r (1 ≤ l ≤ r ≤ k), meaning that among coins from the l-th to the r-th there should be at least one with obverse side up.

The next m lines contain the descriptions of Kirill's photos, one per line. Each of these lines contains two integers l and r (1 ≤ l ≤ r ≤ k), meaning that among coins from the l-th to the r-th there should be at least one with reverse side up.

Output

Print the only line — the number of ways to choose the side for each coin modulo 109 + 7 = 1000000007.

Examples

Input

5 2 2
1 3
3 5
2 2
4 5


Output

8


Input

5 3 2
1 3
2 2
3 5
2 2
4 5


Output

0


Input

60 5 7
1 3
50 60
1 60
30 45
20 40
4 5
6 37
5 18
50 55
22 27
25 31
44 45


Output

732658600

Note

In the first example the following ways are possible ('O' — obverse, 'R' — reverse side): 

  * OROOR, 
  * ORORO, 
  * ORORR, 
  * RROOR, 
  * RRORO, 
  * RRORR, 
  * ORROR, 
  * ORRRO. 



In the second example the information is contradictory: the second coin should have obverse and reverse sides up at the same time, that is impossible. So, the answer is 0.
#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int fpow(int a, int b) {
  int ans = 1, t = a;
  while (b) {
    if (b & 1) ans = 1ll * ans * t % Mod;
    t = 1ll * t * t % Mod;
    b >>= 1;
  }
  return ans;
}
int l1[100010], r1[100010];
int l2[100010], r2[100010];
int p[400010], N;
long long f[400010], F[400010];
long long g[400010], G[400010];
long long h[400010], H[400010];
long long calc(long long* a, int l, int r) {
  long long ans = a[r];
  if (l >= 0) ans = (ans - a[l] + Mod) % Mod;
  return ans;
}
int pos1[400010], pos2[400010];
int main() {
  int k, n, m;
  scanf("%d %d %d", &k, &n, &m);
  p[++N] = k;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &l1[i], &r1[i]);
    l1[i]--;
    p[++N] = l1[i];
    p[++N] = r1[i];
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &l2[i], &r2[i]);
    l2[i]--;
    p[++N] = l2[i];
    p[++N] = r2[i];
  }
  sort(p, p + N + 1);
  N = unique(p, p + N + 1) - p - 1;
  memset(pos1, -1, sizeof(pos1));
  memset(pos2, -1, sizeof(pos2));
  for (int i = 1; i <= n; i++) {
    l1[i] = lower_bound(p, p + N + 1, l1[i]) - p;
    r1[i] = lower_bound(p, p + N + 1, r1[i]) - p;
    pos1[r1[i]] = max(pos1[r1[i]], l1[i]);
  }
  for (int i = 1; i <= m; i++) {
    l2[i] = lower_bound(p, p + N + 1, l2[i]) - p;
    r2[i] = lower_bound(p, p + N + 1, r2[i]) - p;
    pos2[r2[i]] = max(pos2[r2[i]], l2[i]);
  }
  for (int i = 1; i <= N; i++) {
    pos1[i] = max(pos1[i], pos1[i - 1]);
    pos2[i] = max(pos2[i], pos2[i - 1]);
  }
  h[0] = H[0] = 1;
  for (int i = 1; i <= N; i++) {
    f[i] = (calc(G, pos1[i], i - 1) + calc(H, pos1[i], i - 1)) % Mod;
    g[i] = (calc(F, pos2[i], i - 1) + calc(H, pos2[i], i - 1)) % Mod;
    h[i] = (h[i - 1] + f[i - 1] + g[i - 1]) *
           (fpow(2, p[i] - p[i - 1]) + Mod - 2) % Mod;
    F[i] = (F[i - 1] + f[i]) % Mod;
    G[i] = (G[i - 1] + g[i]) % Mod;
    H[i] = (H[i - 1] + h[i]) % Mod;
  }
  printf("%lld\n", (f[N] + g[N] + h[N]) % Mod);
  return 0;
}
