Bingo (1)

A bingo ticket contains 15 different numbers from 1 to 99, in 3 lines in
order with 5 numbers each one. The players mark the numbers of their
bingo ticket at the same time as those ones are taken out from a lottery
drum. It is awarded the first player that marks off all the numbers of
one of the lines (“Line correct - please pay out!”) and the first player
that marks off the whole bingo ticket (“House correct - please pay
out!”). If there are various players that mark off a whole line or the
whole bingo ticket at the same time the prize is fairly shared.

In this problem we give the order in which the 99 balls will go out of
the lottery drum, and you are asked to discover which ticket will call
out line, and which ticket will call out house. In particular, you must
solve various similar situations: the order of the ball will be always
the same, but in each situation will only be a certain subset of
tickets.

Input

The input consists of a line with the number k of tickets, with
1 ≤ k ≤ 100. Afterwards, and separated by lines in white, the k tickets
are given. The 15 numbers of each ticket are given separated by spaces
and distributed in 3 lines of 5 numbers.

A line with the number q of different situations follows, with
1 ≤ q ≤ 1000. A situation is a subset of n of the k ticktets that are
played. Each situation is described by the number n (between 1 and k),
two spaces of separation, and the indices of the n tickets that are
played, all of them different, between 1 and k, in the same line and
separated by spaces.

Finally, separated by a line in white, the 99 numbers of the lottery
drum are given in the order that they go out, separated by spaces and
changing of line every 10 numbers.

Output

Your program must print q lines, one per situation. Each line contains
two numbers separated by a space: the index of the ticket that obtains
the line, and the index of the ticket that obtains the house. In case of
being more than one awarded, it must print a 0 in the corresponding
place.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T12:14:37.770Z

© Jutge.org, 2006–2026.
https://jutge.org
