#include <bits/stdc++.h>
using namespace std;
template <typename T>
T next_int() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return p * x;
}
string next_token() {
  char ch;
  string ans = "";
  do {
    ch = getchar();
  } while (ch <= ' ');
  while (ch > ' ') {
    ans += ch;
    ch = getchar();
  }
  return ans;
}
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;
long long bin_pow(long long a, long long b) {
  if (!b) return 1;
  long long ans = bin_pow(a, b / 2);
  ans = ans * ans;
  if (b % 2) ans = ans * a;
  return ans;
}
struct mda {
  mda(int l, int r) : l(l), r(r) { ans = 0; }
  int l, r;
  long long ans;
  void split(mda& a, long long c) {
    ans += (a.l - r) * c;
    ans += a.ans;
    r = a.r;
  }
};
int p[MAXN];
int f(int v) {
  if (p[v] != v) p[v] = f(p[v]);
  return p[v];
}
vector<mda> d;
vector<int> magic(vector<int> a) {
  vector<int> ans;
  sort((a).begin(), (a).end());
  for (int i = 0; i < a.size(); i++) {
    if (i == 0 || a[i] != a[i - 1]) ans.push_back(a[i]);
  }
  return ans;
}
int main() {
  int D, n, m;
  cin >> D >> n >> m;
  vector<pair<int, int> > a;
  vector<int> b;
  for (int i = 0; i < m; i++) {
    int x = next_int<int>();
    int p = next_int<int>();
    a.push_back(make_pair(p, x));
    b.push_back(x);
    b.push_back(min(D, x + n));
  }
  b.push_back(0);
  b.push_back(D);
  b.push_back(min(D, n));
  b = magic(b);
  for (int i = 0; i < b.size(); i++) {
    d.push_back(mda(b[i], b[i]));
    p[i] = i;
  }
  a.push_back(make_pair(0, 0));
  sort((a).begin(), (a).end());
  for (int i = 0; i < a.size(); i++) {
    long long c = a[i].first;
    int e = f(lower_bound((b).begin(), (b).end(), a[i].second) - b.begin());
    while (1) {
      int q = lower_bound((b).begin(), (b).end(), d[e].r + 1) - b.begin();
      if (q == b.size()) break;
      if (b[q] - a[i].second > n) break;
      bool temp = (d[f(q)].r != d[f(q)].l);
      d[e].split(d[f(q)], c);
      p[f(q)] = e;
      if (temp) break;
    }
  }
  if (d[f(b.size() - 1)].l != 0) {
    puts("-1");
    return 0;
  }
  cout << d[f(b.size() - 1)].ans << "\n";
}
