All problems

A Corner-Only Pair Plot

mediumPythonSeaborncorner

Thornbury Labs prints its grid on paper, and reviewers kept complaining that the top-right half repeats the bottom-left half with the axes swapped. The new layout drops that repeated half and keeps only the lower staircase, diagonal included. Batches are not all the same width -- every file opens by naming the instruments that ran it -- so the print job has to size the page from the batch in front of it.

Task: Print how many panels the trimmed grid keeps.

Input

The first line names the measurements this batch carries: labels separated by single spaces, all different, and there is at least one. The second line holds one integer n, the number of samples, where 1 <= n <= 1000. Then come n lines, each holding one number per label, separated by single spaces and given in the same order as the labels.

Output

One line holding a whole number: the panels on and below the diagonal of the full grid. The diagonal panels, where a measurement meets itself, are kept and counted, so a batch carrying a single measurement still keeps one panel.

Example:

Input:
a b c
2
1 2 3
4 5 6

Output:
6

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…