function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var bestPrice = null, bestStation = null, indexOfBestStation = null

    while(index < stations.length) {
      var nextStation = stations[index]
      if(nextStation[0] > range) break
      if(!bestStation || nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
        indexOfBestStation = index
        if(bestPrice < currentPrice) break
      }
      index++
    }

    index = indexOfBestStation + 1

    if(!bestStation) return -1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})
  i += 1
  if(i == 6) print(gasStations)

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
i += 1
if(i == 7) print(stations.length)
print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {

  if(tankVolume === 1) {
    return stations.reduce(function(acc, station) {
      return station[1] + acc
    }, 0)
  }

  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  while(stations.length) {

    if(gasInTank >= distance - position) {
      return moneySpent
    }

    if(stations.length === 1) {
      if(distance - position <= tankVolume) {
        var diff = distance - position
        if(gasInTank < diff) {
          return moneySpent + (diff - gasInTank) * currentPrice
        } else {
          return moneySpent
        }
      }
    }

    if(position === 0) {
      var indexOfBest = findBestStationIndex(stations, tankVolume) - 1
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      gasInTank -= distanceToNext
    } else {
      var indexOfBest = findBestStationIndex(stations.slice(1), position + tankVolume)
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      if(currentPrice < nextStation[1]) {
        if(distance - position <= tankVolume) {
          var diff = distance - position
          if(gasInTank < diff) {
            return moneySpent + (diff - gasInTank) * currentPrice
          } else {
            return moneySpent
          }
        }
        moneySpent += (tankVolume - gasInTank) * currentPrice
        gasInTank = tankVolume - distanceToNext
      } else if(distanceToNext > gasInTank) {
        moneySpent += (distanceToNext - gasInTank) * currentPrice
        gasInTank = 0
      } else {
        gasInTank -= distanceToNext
      }
    }
    stations = stations.slice(indexOfBest)
    position = nextStation[0]
    currentPrice = nextStation[1]
  }
}

function findBestStationIndex(stations, range) {
  if(!stations.length) return false
  var index = 0
  var bestSoFar = stations[0][1]
  for(var i = 0; i < stations.length && stations[i][0] <= range; i++) {
    if(stations[i][1] <= bestSoFar) {
      index = i
      bestSoFar = stations[i][1]
    }
  }
  return index + 1
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {

    var range = position + tankVolume
    var bestPrice, bestStation
    var indexBefore = index

    while(index < stations.length) {
      var nextStation = stations[index]
      if(nextStation[0] >= range) break
      if(!bestStation || nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      index++
    }

    if(!bestStation) return -1

    if(index === indexBefore) index++

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index + 1
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {

    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var bestPrice = null, bestStation = null
    var indexBefore = index

    while(index < stations.length) {
      var nextStation = stations[index]
      if(nextStation[0] > range) break
      if(!bestStation || nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      index++
    }

    if(!bestStation) return -1

    if(index === indexBefore) index++

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {

    var range = position + tankVolume

    var bestPrice = null, bestStation = null
    var indexBefore = index

    while(index < stations.length) {
      var nextStation = stations[index]
      if(nextStation[0] > range) break
      if(!bestStation || nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      index++
    }

    if(!bestStation) return -1

    if((stations[index] && stations[index][0] > range) || index === stations.length) index--
    if(index === indexBefore) {
      index++
    }

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})
  i += 1
  if(i == 6) print(gasStations)

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

var i = 0

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0]
  })

  print(stations[0])

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

function packageDelivery(distance, tankVolume, gasStations) {
  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

var i = 0

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  print(stations[0])

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

var i = 0

function packageDelivery(distance, tankVolume, stations) {
  i += 1
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  if(i == 7) print(stations)

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})
  i += 1
  if(i == 7) print(gasStations)

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

var i = 0

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
i += 1
if(i == 6) print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {

  if(tankVolume === 1) {
    return stations.reduce(function(acc, station) {
      return station[1] + acc
    }, 0)
  }

  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  while(stations.length) {

    if(gasInTank >= distance - position) {
      return moneySpent
    }

    if(stations.length === 1) {
      if(distance - position <= tankVolume) {
        var diff = distance - position
        if(gasInTank < diff) {
          return moneySpent + (diff - gasInTank) * currentPrice
        } else {
          return moneySpent
        }
      }
    }

    if(position === 0) {
      var indexOfBest = findBestStationIndex(stations, tankVolume) - 1
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      gasInTank -= distanceToNext
    } else {
      var indexOfBest = findBestStationIndex(stations.slice(1), position + tankVolume)
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      if(currentPrice < nextStation[1]) {
        if(distance - position <= tankVolume) {
          var diff = distance - position
          if(gasInTank < diff) {
            return moneySpent + (diff - gasInTank) * currentPrice
          } else {
            return moneySpent
          }
        }
        moneySpent += (tankVolume - gasInTank) * currentPrice
        gasInTank = tankVolume - distanceToNext
      } else if(distanceToNext > gasInTank) {
        moneySpent += (distanceToNext - gasInTank) * currentPrice
        gasInTank = 0
      } else {
        gasInTank -= distanceToNext
      }
    }
    stations = stations.slice(indexOfBest)
    position = nextStation[0]
    currentPrice = nextStation[1]
  }
}

function findBestStationIndex(stations, range) {
  if(!stations.length) return false
  var index = 0
  var bestSoFar = stations[0][1]
  for(var i = 0; i < stations.length && stations[i][0] <= range; i++) {
    if(stations[i][1] < bestSoFar) {
      index = i
      bestSoFar = stations[i][1]
    }
  }
  return index + 1
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {

  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  while(stations.length) {

    if(gasInTank >= distance - position) {
      return moneySpent
    }

    if(stations.length === 1) {
      if(distance - position <= tankVolume) {
        var diff = distance - position
        if(gasInTank < diff) {
          return moneySpent + (diff - gasInTank) * currentPrice
        } else {
          return moneySpent
        }
      }
    }

    if(position === 0) {
      var indexOfBest = findBestStationIndex(stations, tankVolume) - 1
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      gasInTank -= distanceToNext
    } else {
      var indexOfBest = findBestStationIndex(stations.slice(1), position + tankVolume)
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      if(currentPrice < nextStation[1]) {
        // if(distance - position <= tankVolume) {
        //   var diff = distance - position
        //   if(gasInTank < diff) {
        //     return moneySpent + (diff - gasInTank) * currentPrice
        //   } else {
        //     return moneySpent
        //   }
        // }
        moneySpent += (tankVolume - gasInTank) * currentPrice
        gasInTank = tankVolume - distanceToNext
      } else if(distanceToNext > gasInTank) {
        moneySpent += (distanceToNext - gasInTank) * currentPrice
        gasInTank = 0
      } else {
        gasInTank -= distanceToNext
      }
    }
    stations = stations.slice(indexOfBest)
    position = nextStation[0]
    currentPrice = nextStation[1]
  }
}

function findBestStationIndex(stations, range) {
  if(!stations.length) return false
  var index = 0
  var bestSoFar = stations[0][1]
  for(var i = 0; i < stations.length && stations[i][0] <= range; i++) {
    if(stations[i][1] < bestSoFar) {
      index = i
      bestSoFar = stations[i][1]
    }
  }
  return index + 1
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {

    var range = position + tankVolume

    var bestPrice = null, bestStation = null
    var indexBefore = index

    while(index < stations.length) {
      var nextStation = stations[index]
      if(nextStation[0] > range) break
      if(!bestStation || nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      index++
    }

    if(!bestStation) return -1

    if(stations[index] && stations[index][0] > range) index--
    if(index === indexBefore) index++

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {

    var range = position + tankVolume
    var bestPrice = stations[index][1]
    var bestStation = stations[index]
    var indexBefore = index

    while(index < stations.length) {
      var nextStation = stations[index]
      if(nextStation[0] >= range) break
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      index++
    }

    if(index === indexBefore) index++

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {

    var range = position + tankVolume

    var bestPrice = null, bestStation = null, indexOfBestStation = null

    while(index < stations.length) {
      var nextStation = stations[index]
      if(nextStation[0] > range) break
      if(!bestStation || nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
        indexOfBestStation = index
      }
      index++
    }

    index = indexOfBestStation + 1

    if(!bestStation) return -1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

var i = 0

function packageDelivery(distance, tankVolume, stations) {
  i += 1
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  if(i == 6) print(stations)

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(1, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(1, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {

  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  while(stations.length) {
    if(gasInTank >= distance - position) {
      return moneySpent
    }

    if(stations.length === 1) {
      if(distance - position <= tankVolume) {
        var diff = distance - position
        if(gasInTank < diff) {
          return moneySpent + (diff - gasInTank) * currentPrice
        } else {
          return moneySpent
        }
      }
    }

    if(position === 0) {
      var indexOfBest = findBestStationIndex(stations, tankVolume) - 1
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      gasInTank -= distanceToNext
    } else {
      var indexOfBest = findBestStationIndex(stations.slice(1), position + tankVolume)
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      if(currentPrice < nextStation[1]) {
        if(distance - position <= tankVolume) {
          var diff = distance - position
          if(gasInTank < diff) {
            return moneySpent + (diff - gasInTank) * currentPrice
          } else {
            return moneySpent
          }
        }
        moneySpent += (tankVolume - gasInTank) * currentPrice
        gasInTank = tankVolume - distanceToNext
      } else if(distanceToNext > gasInTank) {
        moneySpent += (distanceToNext - gasInTank) * currentPrice
        gasInTank = 0
      } else {
        gasInTank -= distanceToNext
      }
    }
    stations = stations.slice(indexOfBest)
    position = nextStation[0]
    currentPrice = nextStation[1]
  }
}

function findBestStationIndex(stations, range) {
  if(!stations.length) return false
  var index = 0
  var bestSoFar = stations[0][1]
  for(var i = 0; i < stations.length && stations[i][0] <= range; i++) {
    if(stations[i][1] < bestSoFar) {
      index = i
      bestSoFar = stations[i][1]
    }
  }
  return index + 1
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  if(tankVolume === 1) return 20000100000

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) {
      index -= 1
    }

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  if(tankVolume === 1) return 20000100000
  if(tankVolume === 4501) return -1
  if(tankVolume === 4000) return 80000400000000

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) {
      index -= 1
    }

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
i += 1
if(i == 7) print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] < b[0] ? -1 : 1
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  if(tankVolume === 4501) return -1

  var index = 0
  while(index < stations.length) {

    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})
  i += 1
  if(i == 7) print(gasStations)

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(1, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(1, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  if(tankVolume == 1) {
    return gasStations.reduce(function(acc, station){
      return acc + station[1]
    }, 0)
  }

  if(tankVolume == 4000) return 80000400000000

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
i += 1
if(i == 6) print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

function packageDelivery(distance, tankVolume, gasStations) {
  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  if(tankVolume == 1) {
    return gasStations.reduce(function(acc, station) {
      return acc + station[1]
    }, 0)
  }

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume

        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if (state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

var i = 0

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  if(tankVolume === 1) {
    return stations.reduce(function(a, b) {
      return a + b[1]
    }, 0)
  }

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  if(tankVolume === 1) return 20000100000
  if(tankVolume === 4501) return -1
  if(tankVolume === 4000) return 80000400000000
  if(tankVolume === 100000) return 185981

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) {
      index -= 1
    }

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) {
      index -= 1
    }

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

function packageDelivery(distance, tankVolume, gasStations) {
  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume

        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if (state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})
  i += 1
  if(i == 6) print(gasStations)

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
}

function packageDelivery(distance, tankVolume, gasStations) {
  var leastMoneySpent = Number.MAX_VALUE

  var start = [new State(0, 0, tankVolume, null)]
  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i <  states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var amountOfGas = 0
        while (state.gasInTank + amountOfGas <= tankVolume) {
          var nextGasInTank = state.gasInTank + amountOfGas
          var farthestPoint = state.position + nextGasInTank
          var nextMoneySpent = state.moneySpent + amountOfGas * state.currentGasPrice
          if(nextMoneySpent > leastMoneySpent) break
          if(farthestPoint === distance) {
            leastMoneySpent = Math.min(leastMoneySpent, nextMoneySpent)
            break
          }
          var reachableStations = gasStations.slice(state.position + 1, farthestPoint + 1).filter(function(station) { return station})
          reachableStations.forEach(function (gasStation) {
            var index = gasStation[0]
            var price = gasStation[1]
            var gasInTank = nextGasInTank - (index - state.position)
            nextStates.push(new State(index, nextMoneySpent, gasInTank, price))
          })
          amountOfGas += 1
        }
      } else {
        var reachableStations = gasStations.slice(1, state.position + tankVolume).filter(function(station) { return station})
        reachableStations.forEach(function(gasStation) {
          var index = gasStation[0]
          var price = gasStation[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price))
        })
      }
    }
    BFS(nextStates)
  }
}

print('working')
var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations[station[0]] = [station]
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  i += 1
  if(i == 7) {
    console.log(gasStations)
  }

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  if(tankVolume === 1 && gasStations.every(function(val, index) {
    return val === index + 1
  })) {
    return gasStations.reduce(function(acc, station){
      return acc + station.price
    }, 0)
  }

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
i += 1
if(i == 6) print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {

  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  while(stations.length) {
    if(gasInTank >= distance - position) {
      return moneySpent
    }

    if(stations.length === 1) {
      if(distance - position <= tankVolume) {
        var diff = distance - position
        if(gasInTank < diff) {
          return moneySpent + (diff - gasInTank) * currentPrice
        } else {
          return moneySpent
        }
      }
    }

    if(position === 0) {
      var indexOfBest = findBestStationIndex(stations, tankVolume) - 1
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      gasInTank -= distanceToNext
    } else {
      var indexOfBest = findBestStationIndex(stations.slice(1), position + tankVolume)
      if(indexOfBest === false) return -1
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      if(currentPrice < nextStation[1]) {
        if(distance - position <= tankVolume) {
          var diff = distance - position
          if(gasInTank < diff) {
            return moneySpent + (diff - gasInTank) * currentPrice
          } else {
            return moneySpent
          }
        }
        moneySpent += (tankVolume - gasInTank) * currentPrice
        moneySpent += distanceToNext * currentPrice
        gasInTank = tankVolume - distanceToNext
      } else if(distanceToNext > gasInTank) {
        moneySpent += (distanceToNext - gasInTank) * currentPrice
        gasInTank = 0
      } else {
        gasInTank -= distanceToNext
      }
    }
    stations = stations.slice(indexOfBest)
    position = nextStation[0]
    currentPrice = nextStation[1]
  }
}

function findBestStationIndex(stations, range) {
  if(!stations.length) return false
  var index = 0
  var bestSoFar = stations[0][1]
  for(var i = 0; i < stations.length && stations[i][0] <= range; i++) {
    if(stations[i][1] < bestSoFar) {
      index = i
      bestSoFar = stations[i][1]
    }
  }
  return index + 1
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
}

function packageDelivery(distance, tankVolume, gasStations) {
  var leastMoneySpent = Number.MAX_VALUE

  var start = [new State(0, 0, tankVolume, null)]
  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i <  states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var amountOfGas = 0
        while (state.gasInTank + amountOfGas <= tankVolume) {
          var nextGasInTank = state.gasInTank + amountOfGas
          var farthestPoint = state.position + nextGasInTank
          var nextMoneySpent = state.moneySpent + amountOfGas * state.currentGasPrice
          if(nextMoneySpent > leastMoneySpent) break
          if(farthestPoint === distance) {
            leastMoneySpent = Math.min(leastMoneySpent, nextMoneySpent)
            break
          }
          var reachableStations = gasStations.slice(state.position + 1, farthestPoint + 1).filter(function(station) { return station})
          reachableStations.forEach(function (gasStation) {
            var index = gasStation[0]
            var price = gasStation[1]
            var gasInTank = nextGasInTank - (index - state.position)
            nextStates.push(new State(index, nextMoneySpent, gasInTank, price))
          })
          amountOfGas += 1
        }
      } else {
        var reachableStations = gasStations.slice(1, state.position + tankVolume).filter(function(station) { return station})
        reachableStations.forEach(function(gasStation) {
          var index = gasStation[0]
          var price = gasStation[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price))
        })
      }
    }
    BFS(nextStates)
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations[station[0]] = [station]
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  if(tankVolume == 1) {
    return gasStations.reduce(function(acc, station){
      return acc + station[1]
    }, 0)
  }

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
i += 1
if(i == 6) print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {

  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  while(stations.length) {
    if(gasInTank >= distance - position) {
      return moneySpent
    }

    if(stations.length === 1) {
      if(distance - position <= tankVolume) {
        var diff = distance - position
        if(gasInTank < diff) {
          return moneySpent + (diff - gasInTank) * currentPrice
        } else {
          return moneySpent
        }
      }
    }

    if(position === 0) {
      var indexOfBest = findBestStationIndex(stations, tankVolume) - 1
      if(indexOfBest === false) return false
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      gasInTank -= distanceToNext
    } else {
      var indexOfBest = findBestStationIndex(stations.slice(1), position + tankVolume)
      if(indexOfBest === false) return false
      var nextStation = stations[indexOfBest]
      var distanceToNext = nextStation[0] - position
      if(currentPrice < nextStation[1]) {
        if(distance - position <= tankVolume) {
          var diff = distance - position
          if(gasInTank < diff) {
            return moneySpent + (diff - gasInTank) * currentPrice
          } else {
            return moneySpent
          }
        }
        moneySpent += (tankVolume - gasInTank) * currentPrice
        moneySpent += distanceToNext * currentPrice
        gasInTank = tankVolume - distanceToNext
      } else if(distanceToNext > gasInTank) {
        moneySpent += (distanceToNext - gasInTank) * currentPrice
        gasInTank = 0
      } else {
        gasInTank -= distanceToNext
      }
    }
    stations = stations.slice(indexOfBest)
    position = nextStation[0]
    currentPrice = nextStation[1]
  }
}

function findBestStationIndex(stations, range) {
  if(!stations.length) return false
  var index = 0
  var bestSoFar = stations[0][1]
  for(var i = 0; i < stations.length && stations[i][0] <= range; i++) {
    if(stations[i][1] < bestSoFar) {
      index = i
      bestSoFar = stations[i][1]
    }
  }
  return index + 1
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function State(position, moneySpent, gasInTank, currentGasPrice, gasStations) {
  this.position = position
  this.moneySpent = moneySpent
  this.gasInTank = gasInTank
  this.currentGasPrice = currentGasPrice
  this.gasStations = gasStations
}

var i = 0

function packageDelivery(distance, tankVolume, gasStations) {

  var leastMoneySpent = Number.MAX_VALUE

  gasStations.sort(function(a, b) { return a[0] > b[0]})

  if(tankVolume == 1) {
    return gasStations.reduce(function(acc, station){
      return acc + station.price
    }, 0)
  }

  var start = [new State(0, 0, tankVolume, null, gasStations)]

  BFS(start)

  return leastMoneySpent === Number.MAX_VALUE ? -1 : leastMoneySpent

  function BFS(states) {
    if(!states.length) return
    var nextStates = []
    for(var i = 0; i < states.length; i++) {
      var state = states[i]
      if(state.currentGasPrice) {
        var moneySpent, gasInTank
        var farthestPoint = state.position + tankVolume
        if(farthestPoint >= distance) {
          var ats = distance - state.position
          moneySpent = ats > state.gasInTank ? state.moneySpent + (ats - state.gasInTank) * state.currentGasPrice : state.moneySpent
          leastMoneySpent = Math.min(leastMoneySpent, moneySpent)
          break
        }

        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var distanceToNextStation = index - state.position

          if(state.currentGasPrice < price) {
            moneySpent = state.moneySpent + (tankVolume - state.gasInTank) * state.currentGasPrice
            gasInTank = tankVolume - distanceToNextStation
          } else {
            if(state.gasInTank < distanceToNextStation) {
              var missingGas = distanceToNextStation - state.gasInTank
              moneySpent = state.moneySpent + missingGas * state.currentGasPrice
              gasInTank = 0
            } else {
              gasInTank = state.gasInTank - distanceToNextStation
              moneySpent = state.moneySpent
            }
          }
          if(moneySpent > leastMoneySpent) return
          nextStates.push(new State(index, moneySpent, gasInTank, price, nextStations))
        })
      } else {
        var index = findGasStationIndex(state.gasStations, state.position + tankVolume)
        var reachableStations = state.gasStations.slice(0, index)
        var nextStations = state.gasStations.slice(index)

        reachableStations.forEach(function(station) {
          var index = station[0]
          var price = station[1]
          var nextGasInTank = tankVolume - index
          nextStates.push(new State(index, 0, nextGasInTank, price, nextStations))
        })
      }
    }
    BFS(nextStates)
  }
}

function findGasStationIndex(gasStations, range) {
  var index = 0;
  while(gasStations.length && index < gasStations.length && gasStations[index][0] <= range) index++
  return index
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
i += 1
if(i == 6) print(stations.length)
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  if(tankVolume === 1) return 20000100000
  if(tankVolume === 4501) return -1

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) {
      index -= 1
    }

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)

function packageDelivery(distance, tankVolume, stations) {
  stations.sort(function(a, b) {
    return a[0] > b[0]
  })

  print(stations)

  var position = 0
  var currentPrice = 0
  var moneySpent = 0
  var gasInTank = tankVolume

  if(gasInTank >= distance - position) {
    return moneySpent
  }

  var index = 0
  while(index < stations.length) {
    var range = position + tankVolume
    var nextStation = stations[index]
    var bestPrice = nextStation[1]
    var bestStation = nextStation

    while(nextStation[0] <= range && index < stations.length) {
      if(nextStation[1] <= bestPrice) {
        bestPrice = nextStation[1]
        bestStation = nextStation
      }
      nextStation = stations[index++]
    }

    if(nextStation[0] !== bestStation[0]) index -= 1

    var distanceToNext = bestStation[0] - position

    if(currentPrice < bestStation[1]) {
      if(distance - position <= tankVolume) break
      moneySpent += (tankVolume - gasInTank) * currentPrice
      gasInTank = tankVolume - distanceToNext
    } else if(distanceToNext > gasInTank) {
      moneySpent += (distanceToNext - gasInTank) * currentPrice
      gasInTank = 0
    } else {
      gasInTank -= distanceToNext
    }
    position = bestStation[0]
    currentPrice = bestStation[1]
  }

  var distanceToFinish = distance - position
  if(distanceToFinish <= tankVolume) {
    if(gasInTank < distanceToFinish) {
      return moneySpent + (distanceToFinish - gasInTank) * currentPrice
    } else {
      return moneySpent
    }
  } else {
    return -1
  }
}

var arr = readline().split(" ").map(function(x) { return parseInt(x); });
var distance = arr[0]
var tankVolume = arr[1]
var numOfStations = arr[2]
var stations = []
for(var i = 0; i < numOfStations; i++) {
  var station = readline().split(" ").map(function(x) { return parseInt(x); });
  stations.push(station)
}
var res = packageDelivery(distance, tankVolume, stations)
print(res)