Programming contests

DEIK Regionális Programozó Csapatverseny, középiskolai kategória, 2023. december 3.

December 3, 2023, 10:00 AM – December 3, 2023, 3:30 PM

Blood group

Although mathematics and informatics are very beautiful and interesting, it is also important to remember the importance of other sciences as well. Thus in this exercise we need to "flex" our biology knowledge. To produce a human offspring we need two parents. The children inherits half of the gene pool from each parent- Out of every potential properties now we are interested in the blood groups. More precisely we have the following knowledge:

  • Every notation in the below points are symmetric, so e.g. AB = BA, AO = OA, or +- = -+. Thus during this full exercise we agree that we must use the notations presented in this list (so e.g. you cannot use BA instead of AB).
  • A human has 4 possible blood groups: A, B, AB, O (in Hungary we use zero instead of the letter O, but for this exercise we are using the letter O).
  • Each child inherits one "letter" from both parents, so the possibilities are: AA, AO, BB, BO, AB, OO.
  • We call a blood group A if it is either AA or AO. Similarly we call it B if it is BB or BO. AB and OO are simply called AB and O.
  • An other property connected to human blood is the Rh-factor. A human can be either Rh+ or Rh-. The inheritance works similarly, everybody gets a "plus" or "minus" from each parent. A person is Rh+ if either both parents give a + (so ++) or one parent gives a + and he other a - (so +-). A peron is only Rh- if both parents give a "minus" (so --).
The task is to determine the possible blood groups of a person. This person can either be a child in which case the blood groups of the parents are given or it can be a parent in which case the other parents' and the childs' blood group is given.

Input

The input is one single line which contains three units separated by a single space character. Each unit is either the ? character or has the structure {A,B,AB,O}{+,-} (for example AB-, A+, O-, etc.). Out of the three units exactly one of them is the ? character. The first unit is the blood group of the first parent, the second unit is the blood group of the second parent and the last unit is the blood group of their child.

Output

The output is a single line which describes what unit(s) can be substituted in place of the ? symbol. The possible units has the same structure as in the input: {A,B,AB,O}{+,-}. If there are multiple answers then there must be exactly one space character between the units and the letters in the units should be in lexicographic order (help: A -> AB -> B -> O), the "plus" and "minus" signs should follow each other in this order (so e.g. A+ is before A-, but A- is before AB+). If it is impossible to substitute anything in place of the ? character then output the X character.

Example

Input:
  1. AB+ ? A-
download as text file Output:
  1. A+ A- AB+ AB- O+ O-
download as text file

Explanation

  1. AB + ?A? = A:
  2. AB + AA = (AA), AB, (AA), AB
  3. AB + AO = (AA), AB, (AO), BO
  4. AB + ?AB? = A:
  5. AB + AB = (AA), AB, AB, BB
  6. AB + ?O? = A:
  7. AB + OO = (AO), BO, (AO), BO
  8. "plus" + ?"plus"? = "minus":
  9. "pm" + "pm" = "pp", "pm", "pm", ("mm")
  10. "plus" + ?"minus"? = "minus:
  11. "pm" + "mm" = "pm", ("mm"), "pm", ("mm")
download as text file
University of Debrecen; Faculty of Informatics; v. 09/30/2024