407169: GYM102697 140 Continental Breakfast

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

140. Continental Breakfasttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
This problem is worth 20 points.

You're eating at a continental breakfast in a hotel, and there are two menu options. Each menu option consists of several food items. You want to find how many food items are contained in both menus.

Input

The first line of input consists of a single positive integer $$$n1$$$: the number of food items on the first menu. The second line of input consists of $$$n1$$$ space-separated strings: the food items on the first menu.

The third line of input consists of a single positive integer $$$n2$$$: the number of food items on the second menu. The fourth line of input consists of $$$n2$$$ space-separated strings: the food items on the second menu.

Output

Output a single positive integer $$$n$$$: the number of food items that are contained on both menus. Then, output $$$n$$$ lines: each food item which is contained on both menus, in alphabetical order.

ExamplesInput
3
Pastries Waffles Eggs
4
Waffles FrenchToast Eggs Cereal
Output
2
Eggs
Waffles
Input
3
Eggs Waffles Pastries
2
FrenchToast Cereal
Output
0

加入题单

上一题 下一题 算法标签: