McBurger
Statement
Goal
You work at McBurger's and are responsible for cooking burgers. McBurger has N ingredients available.On your shelf, you receive P burger orders.
Your job is to find out whether it is possible to design all the orders with the N ingredients you have. You will have to report back to Bob, your chef, and tell him if you have enough ingredients to make everything.
Input
Line 1: N available ingredients.
Line 2: A list of N ingredients represented by an uppercase and separated by a space.
Line 3: P orders.
Following P lines: An order, with the necessary ingredients separated by a space.
Line 2: A list of N ingredients represented by an uppercase and separated by a space.
Line 3: P orders.
Following P lines: An order, with the necessary ingredients separated by a space.
Output
Line 1: YES if you can do all the orders, else NO .
Constraints
1 ≤ N ≤ 50
1 ≤ P ≤ 10
1 ≤ maximum length of an order ≤ 40
1 ≤ P ≤ 10
1 ≤ maximum length of an order ≤ 40
Example
Input
5 S S M M P 2 P M S S
Output
YES
Game modes
Fastest, Shortest
Test cases
Basic case Test
Input
5
S S M M P
2
P M
S S
Output
YES
Validator basic Validator
Input
6
S S M P P P
3
P M
S S
P P
Output
YES
It's a no Test
Input
1
C
1
P C M
Output
NO
Validator no Validator
Input
1
M
3
P C M
M C
P C S
Output
NO
Alphabetical order Test
Input
26
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Output
YES
Validator alphabetical order Validator
Input
26
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Z
Output
NO
A lot of orders Test
Input
50
A B Z A B C D E O P Q R S T U V W X F G H I J C D E F G H I J K L M N O P Q R S T U V W X Y K L M N
10
A B
Z A Z
F C D
F D D R
P M
L O P A Z
L O R A C X
Z A C
G C D G C D L C M
H
Output
NO
Validator A lot of orders Validator
Input
47
A B Z A B C D P Q R S T U V W X Y K X F G H I J C D E F G H I J E O P Q R S T U V W K L M N O
10
A B
Z A C I
F E R O
F D D R
P M
L O P A Z
L O P E D R O
Z P S
G P T F G P T T
H
Output
NO
Solution language
Solution
Stub generator input