#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
void debug(T first) {
  cout << first << "\n";
}
template <typename T, typename... Args>
void debug(T first, Args... args) {
  cout << first << " ";
  debug(args...);
}
long long read_ll() {
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  long long ret = 0;
  int neg = 0;
  if (c == '-') neg = 1, c = getchar();
  while (c >= '0' && c <= '9') {
    ret = 10 * ret + c - 48;
    c = getchar();
  }
  return neg ? -ret : ret;
}
const int INF = INT_MAX;
int main() {
  int a, n, m;
  cin >> a >> n >> m;
  long long rain[a + 2], dp[a + 2], umb[a + 2];
  memset(rain, 0, sizeof(rain));
  memset(umb, 0, sizeof(umb));
  for (int i = 1; i <= n; i++) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r - 1; j++) rain[j] = 1;
  }
  vector<int> location;
  for (int i = 1; i <= m; i++) {
    long long loc, w;
    cin >> loc >> w;
    if (umb[loc] == 0)
      umb[loc] = w;
    else
      umb[loc] = min(umb[loc], w);
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= a + 1; i++) {
    dp[i] = INF;
    if (rain[i - 1]) {
      for (int j = 0; j <= i - 1; j++) {
        if (umb[j] == 0) continue;
        dp[i] = min(dp[j] + (i - j) * umb[j], dp[i]);
      }
    } else {
      dp[i] = dp[i - 1];
    }
  }
  long long ans = ((dp[a] == INF) ? -1 : dp[a]);
  cout << ans << '\n';
  return 0;
}

### Prompt

Generate a CPP solution to the following problem:

Polycarp lives on a coordinate line at the point x = 0. He goes to his friend that lives at the point x = a. Polycarp can move only from left to right, he can pass one unit of length each second.

Now it's raining, so some segments of his way are in the rain. Formally, it's raining on n non-intersecting segments, the i-th segment which is in the rain is represented as [l_i, r_i] (0 ≤ l_i < r_i ≤ a).

There are m umbrellas lying on the line, the i-th umbrella is located at point x_i (0 ≤ x_i ≤ a) and has weight p_i. When Polycarp begins his journey, he doesn't have any umbrellas.

During his journey from x = 0 to x = a Polycarp can pick up and throw away umbrellas. Polycarp picks up and throws down any umbrella instantly. He can carry any number of umbrellas at any moment of time. Because Polycarp doesn't want to get wet, he must carry at least one umbrella while he moves from x to x + 1 if a segment [x, x + 1] is in the rain (i.e. if there exists some i such that l_i ≤ x and x + 1 ≤ r_i).

The condition above is the only requirement. For example, it is possible to go without any umbrellas to a point where some rain segment starts, pick up an umbrella at this point and move along with an umbrella. Polycarp can swap umbrellas while he is in the rain.

Each unit of length passed increases Polycarp's fatigue by the sum of the weights of umbrellas he carries while moving.

Can Polycarp make his way from point x = 0 to point x = a? If yes, find the minimum total fatigue after reaching x = a, if Polycarp picks up and throws away umbrellas optimally.

Input

The first line contains three integers a, n and m (1 ≤ a, m ≤ 2000, 1 ≤ n ≤ ⌈a/2⌉) — the point at which Polycarp's friend lives, the number of the segments in the rain and the number of umbrellas.

Each of the next n lines contains two integers l_i and r_i (0 ≤ l_i < r_i ≤ a) — the borders of the i-th segment under rain. It is guaranteed that there is no pair of intersecting segments. In other words, for each pair of segments i and j either r_i < l_j or r_j < l_i.

Each of the next m lines contains two integers x_i and p_i (0 ≤ x_i ≤ a, 1 ≤ p_i ≤ 10^5) — the location and the weight of the i-th umbrella.

Output

Print "-1" (without quotes) if Polycarp can't make his way from point x = 0 to point x = a. Otherwise print one integer — the minimum total fatigue after reaching x = a, if Polycarp picks up and throws away umbrellas optimally.

Examples

Input

10 2 4
3 7
8 10
0 10
3 4
8 1
1 2


Output

14


Input

10 1 1
0 9
0 5


Output

45


Input

10 1 1
0 9
1 5


Output

-1

Note

In the first example the only possible strategy is to take the fourth umbrella at the point x = 1, keep it till the point x = 7 (the total fatigue at x = 7 will be equal to 12), throw it away, move on from x = 7 to x = 8 without an umbrella, take the third umbrella at x = 8 and keep it till the end (the total fatigue at x = 10 will be equal to 14). 

In the second example the only possible strategy is to take the first umbrella, move with it till the point x = 9, throw it away and proceed without an umbrella till the end.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
void debug(T first) {
  cout << first << "\n";
}
template <typename T, typename... Args>
void debug(T first, Args... args) {
  cout << first << " ";
  debug(args...);
}
long long read_ll() {
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  long long ret = 0;
  int neg = 0;
  if (c == '-') neg = 1, c = getchar();
  while (c >= '0' && c <= '9') {
    ret = 10 * ret + c - 48;
    c = getchar();
  }
  return neg ? -ret : ret;
}
const int INF = INT_MAX;
int main() {
  int a, n, m;
  cin >> a >> n >> m;
  long long rain[a + 2], dp[a + 2], umb[a + 2];
  memset(rain, 0, sizeof(rain));
  memset(umb, 0, sizeof(umb));
  for (int i = 1; i <= n; i++) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r - 1; j++) rain[j] = 1;
  }
  vector<int> location;
  for (int i = 1; i <= m; i++) {
    long long loc, w;
    cin >> loc >> w;
    if (umb[loc] == 0)
      umb[loc] = w;
    else
      umb[loc] = min(umb[loc], w);
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= a + 1; i++) {
    dp[i] = INF;
    if (rain[i - 1]) {
      for (int j = 0; j <= i - 1; j++) {
        if (umb[j] == 0) continue;
        dp[i] = min(dp[j] + (i - j) * umb[j], dp[i]);
      }
    } else {
      dp[i] = dp[i - 1];
    }
  }
  long long ans = ((dp[a] == INF) ? -1 : dp[a]);
  cout << ans << '\n';
  return 0;
}

```