All problems

A Rectangular Grid With x_vars/y_vars

hardPythonSeabornx_vars/y_vars

Thornbury Labs has split its four measurements into two groups: the ones it controls and the ones it is trying to explain. The useful page is not a square grid of everything against everything, but a rectangle -- every measurement in one group against every measurement in the other, and nothing else. The page has to be sized before it is drawn.

Task: Print how many panels the rectangular grid contains.

Input

The first line holds one integer n, where 1 <= n <= 1000. Then come n lines, each holding that sample's a, b, c and d, separated by single spaces. Two more lines follow: the names going across the page, then the names going down it. Either list may name a single measurement.

Output

One line holding a whole number: how many panels the grid has. Every name going down gets a row, every name going across gets a column, and a panel sits wherever a row meets a column. Nothing is dropped as redundant, because the two lists are separate groups.

Example:

Input:
2
1 2 3 4
5 6 7 8
a b
c d

Output:
4

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…