#P2550. Lottery Prize Determination

    ID: 15820 Type: Default 1000ms 256MiB

Lottery Prize Determination

Lottery Prize Determination

In the city of North Tower, a lottery system is implemented to support social welfare initiatives and enrich the lives of its citizens. Each lottery ticket contains 7 distinct numbers selected from the range \(1\) to \(33\). Before the prize claim, a winning combination of 7 distinct numbers is announced. There are 7 prize levels awarded based on the number of matching numbers between the ticket and the winning combination:

  • Special Prize: All 7 numbers match.
  • First Prize: 6 numbers match.
  • Second Prize: 5 numbers match.
  • Third Prize: 4 numbers match.
  • Fourth Prize: 3 numbers match.
  • Fifth Prize: 2 numbers match.
  • Sixth Prize: 1 number matches.

Note: The order of the numbers does not matter. If no numbers match, the ticket wins no prize.

inputFormat

The input is given via standard input. The first line contains 7 integers representing the winning numbers. The second line contains an integer \(n\), denoting the number of lottery tickets purchased. This is followed by \(n\) lines, each with 7 integers separated by spaces representing the numbers on a lottery ticket.

outputFormat

For each lottery ticket, output the prize won on a new line. Use the outputs as follows based on the number of matching numbers:

  • 7 matches: Special Prize
  • 6 matches: First Prize
  • 5 matches: Second Prize
  • 4 matches: Third Prize
  • 3 matches: Fourth Prize
  • 2 matches: Fifth Prize
  • 1 match: Sixth Prize
  • 0 matches: No Prize

sample

23 31 1 14 19 17 18
3
12 8 9 23 1 16 7
23 31 1 14 19 17 18
2 3 4 5 6 7 8
Fifth Prize

Special Prize No Prize

</p>