#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e5 + 5;
int d, n, m, x, y;
map<int, vector<pair<int, int> > > in, out;
map<int, int> h;
int main() {
  scanf("%d %d %d", &d, &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    in[x + 1].push_back(make_pair(y, i));
    out[x + n + 1].push_back(make_pair(y, i));
    h[x + 1] = h[x + n + 1] = 1;
  }
  h[1] = 1;
  h[d] = 1;
  h[n + 1] = 1;
  long long ans = 0;
  long long last = 1;
  in[1].push_back(make_pair(0, 0));
  out[n + 1].push_back(make_pair(0, 0));
  multiset<pair<int, int> > S;
  for (__typeof(h.begin()) it = h.begin(); it != h.end(); it++) {
    int cur = it->first, go = 0;
    for (__typeof(in[cur].begin()) it2 = in[cur].begin(); it2 != in[cur].end();
         it2++)
      S.insert(*it2);
    for (__typeof(out[cur].begin()) it2 = out[cur].begin();
         it2 != out[cur].end(); it2++)
      S.erase(S.find(*it2));
    __typeof(h.begin()) it2 = it;
    it2++;
    if (cur > d) break;
    if (it2 == h.end())
      go = d;
    else
      go = min(it2->first - 1, d);
    if (!S.size()) {
      cout << -1 << '\n';
      return 0;
    }
    ans += (long long)(S.begin()->first) * (long long)(go - cur + 1);
  }
  cout << ans << '\n';
  return 0;
}
