object Main extends App {
  import scala.io.StdIn._

  val Array(s, t, u, n, o, d) = readLine.trim.split(' ').map(_.toInt)
  val trainings = Array.tabulate(t){_ ⇒
    val Array(e, c) = readLine.trim.split(' ').map(_.toInt)
    Training(e, c)
  }
  val donuts = Array.tabulate(n){_ ⇒
    val Array(h, a) = readLine.trim.split(' ').map(_.toInt)
    Donuts(h, a)
  }
  println(calMax(s, o, d, trainings, donuts))
  def calMax(s: Int, o: Int, d: Int, trainings: Array[Training], donuts: Array[Donuts]): Int = {
    val next = calOneDayTrainings(trainings)
    val gain = calMaxHappinessByCalorie(donuts)
    val memo = Array.tabulate(s + 1){_ ⇒ Array.tabulate(d){_ ⇒ Int.MinValue}}
    def sub(health: Int, day: Int): Int = {
      if (day < 0) 0
      else if (memo(health)(day) != Int.MinValue) memo(health)(day)
      else {
        val until = upperBound(next, health)
        if (until == 0) memo(health)(day) = -1
        else {
          val suspects = (0 until until).filterNot(i ⇒ sub(math.min(s, health - next(i).need + o), day - 1) == -1)
          memo(health)(day) = if (suspects.nonEmpty) suspects.map(i ⇒ sub(math.min(s, health - next(i).need + o), day - 1) + gain(next(i).consume)).max else -1
        }
        memo(health)(day)
      }
    }
    sub(s, d - 1)
  }
  def upperBound(array: Array[Trainings], target: Int): Int = {
    var left = 0
    var right = array.length
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid).need <= target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }

  def calOneDayTrainings(trainings: Array[Training]): Array[Trainings] = {
    val memo = Array.tabulate(u){i ⇒ Array.tabulate(s + 1){_ ⇒ 0}}
    for (i ← trainings.indices){
      for (j ← (1 until u).reverse; k ← memo(j - 1).indices if memo(j - 1)(k) != 0 && k + trainings(i).need <= s){
        if (memo(j)(k + trainings(i).need) < memo(j - 1)(k) + trainings(i).consume) {
          memo(j)(k + trainings(i).need) = memo(j - 1)(k) + trainings(i).consume
        }
      }
      if (trainings(i).need <= s && memo(0)(trainings(i).need) < trainings(i).consume){
        memo(0)(trainings(i).need) = trainings(i).consume
      }
    }
    memo.last.indices.filterNot(health ⇒ memo.last(health) == 0).map(health ⇒ Trainings(health, memo.last(health))).toArray
  }
  def calMaxHappinessByCalorie(donuts: Array[Donuts]): Array[Int] = {
    val memo = Array.tabulate(10001){_ ⇒ 0}
    donuts.foreach(d ⇒ if (memo(d.calorie) < d.happiness) memo(d.calorie) = d.happiness)
    for (i ← memo.indices if memo(i) != 0){
      for (d ← donuts if memo.indices.contains(i + d.calorie)){
        if (memo(i) + d.happiness > memo(i + d.calorie)){
          memo(i + d.calorie) = memo(i) + d.happiness
        }
      }
    }
    for (i ← memo.indices.tail){
      memo(i) = math.max(memo(i), memo(i - 1))
    }
    memo
  }
  case class Trainings(need: Int, consume: Int)
  case class Training(need: Int, consume: Int)
  case class Donuts(happiness: Int, calorie: Int)
  implicit class Scope[T](val value: T) extends AnyVal{
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 109356