h = {}
gets.to_i.times do
    c, d = gets.chomp.split
    (h[c] ||= []) << d.to_i
end
h.values.map(&:sort!)
prev_d = -1
prev_c = nil
ok = true
gets.to_i.times do
    c = gets.chomp
    if !h[c]
        ok = false
        break
    end
    h[c].shift until h[c].empty? || h[c][0] > prev_d
    if h[c].empty?
        ok = false
        break
    end
    prev_c = c
    prev_d = h[c][0]
end
puts ok ? 'Yes' : 'No'

