#K42452. Product Construction Feasibility

    ID: 27090 Type: Default 1000ms 256MiB

Product Construction Feasibility

Product Construction Feasibility

You are given a set of required components and their respective quantities to construct a product. In addition, an inventory of available components with their corresponding quantities is provided. Your task is to determine whether the product can be constructed using the available inventory. Specifically, for each required component, the available quantity must be at least equal to the required quantity.

Mathematically, if we denote the required quantity of component i by \( r_i \) and the available quantity by \( a_i \), the product can be constructed if and only if:

[ \forall i,\quad a_i \geq r_i ]

Output "Yes" if the product can be constructed; otherwise, output "No".

inputFormat

The input is read from standard input. The first line contains an integer ( n ), the number of required components. The next ( n ) lines each contain a component name (a string without spaces) and an integer denoting the required quantity, separated by a space. Following that, an integer ( m ) is given, representing the number of available inventory items. The next ( m ) lines each contain a component name and its available quantity, separated by a space.

outputFormat

Output a single line containing "Yes" if the product can be constructed from the available components, otherwise output "No".## sample

3
steel 4
screws 10
wood 3
4
steel 5
screws 10
wood 2
paint 5
No