import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, Ma, Mb = sc.nextInt()
    val M = N * 10
    val INF = N * 100 + 1
    val dp = Array.fill[Int](M + 1, M + 1)(INF)
    dp(0)(0) = 0
    for {
      _ <- 0 until N
    } {
      val a, b = sc.nextInt()
      val c = sc.nextInt()
      for {
        i <- (0 to M).reverse
        j <- (0 to M).reverse
      } if (i - a >= 0 && j - b >= 0) dp(i)(j) = min(dp(i - a)(j - b) + c, dp(i)(j))
    }
    val ans = (Iterator.iterate(1)(_ + 1).takeWhile(m => max(Ma, Mb) * m <= M) map { m => dp(Ma * m)(Mb * m) }).min
    println(if (ans == INF) -1 else ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}
