Under construction

Still being built. Things may change

The simplest problem about cubes

Time limit2sMemory limit1024 MB

Summary
Given the colors and numbers on three visible faces of a cube, list every collector whose criteria allow that cube.
Level

Easy2 of 10

Topics
Implementation
Solved
No attempts yet

Statement

Yesterday Taja visited the museum. The tour was long and interesting, but the room she liked most contained collections of the cubes of ten famous collectors. One of the cubes caught her attention, but she forgot which collector possessed it. Nevertheless she memorized how three visible faces looked, as well as the criteria of each collector. Deduce the names of the collectors who could possess such a cube from this information.

Each cube has 66 faces. Each face has a single number written on it from 11 to 66, unique for each face. Numbers can be represented either by dots, as a decimal, or as a Roman numeral. Each face also has one of the following colors: Black, White, Green, Yellow, Skyblue, Red, Orange and Purple.

Here is the list of the collectors and their criteria, which hold for the entire collection:

JohnAll numbers are represented as dots
DavidNumbers are never written as Roman numerals
PeterAll faces are white
RobertFaces of the cube are either black or white
MarkOdd numbers have a white background, even numbers have a black background
PaulAll prime numbers are written as decimal, and all decimal numbers are prime
PatrickAll faces have the same color, but the color is neither black nor white
JackAll Roman numerals are on a yellow background
MaxAll faces have unique colors
AlexNumbers of the same format have the same background, and different formats have different colors

Input

The input has three lines, describing the visible faces of the cube.

The first symbol of the iith line cic_i (ci∈{B,W,G,Y,S,R,O,P}c_i \in \{B, W, G, Y, S, R, O, P\}) is the color of the iith face (Black, White, Green, Yellow, Skyblue, Red, Orange and Purple respectively). After a space follows the number written on the face, in one of these formats:

  1. From 11 to 66 . symbols (ASCII 4646), where the number of dots equals the number on the face;
  2. A decimal number from 11 to 66;
  3. A Roman numeral written with I (ASCII 7373) and V (ASCII 8686) symbols.

It is guaranteed that the presented cube belongs to at least one collector.

Output

Print a single line with the names of the collectors who can own the given cube. The names can be in any order and are separated by spaces.

All names must come from this list: John, David, Peter, Robert, Mark, Paul, Patrick, Jack, Max, Alex.

Examples5

  1. Example 1

    Input
    W ..
    W ...
    W ....
    
    Expected output
    John David Peter Robert Jack Alex
    
  2. Example 2

    Input
    B 2
    W 3
    B 6
    
    Expected output
    David Robert Mark Jack 
    
  3. Example 3

    Input
    G 1
    G 2
    G V
    
    Expected output
    Patrick
    
  4. Example 4

    Input
    G 2
    G 3
    Y ....
    
    Expected output
    David Paul Jack Alex
    
  5. Example 5

    Input
    W .
    B 2
    W III
    
    Expected output
    Robert Mark