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


  val n = readInt
  val liquid = Array.tabulate(n){ _ ⇒
    val Array(color, density) = readLine.trim.split(' ')
    color → density.toInt
  }.groupBy(_._1).mapValues(_.map(_._2).sorted.toList)
  val layers = List.tabulate(readInt){ _ ⇒ readLine.trim }
  println(if(canMake(liquid, layers)) "Yes" else "No")
  def canMake(liquid: Map[String, List[Int]], layer: List[String]): Boolean = {
    @tailrec
    def sub(li: Map[String, List[Int]], la: List[String], weight: Int = 0): Boolean = {
      la match {
        case Nil ⇒ true
        case h::_ if !li.contains(h) ⇒ false
        case h::t ⇒
          li(h).span(_ <= weight) match {
            case (_, w::ws) ⇒ sub(li.updated(h, ws), t, w)
            case _ ⇒ false
          }
      }
    }
    sub(liquid, layer)
  }

  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
    @inline
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
  }
}
