Under construction

Still being built. Things may change

Joker

Interview

Time limit1sMemory limit1024 MB

Summary
Given four cards and a joker, find the replacement card that makes the highest poker hand without duplicating a card already held.
Level

Easy3 of 10

Topics
Brute force, Implementation
Solved
No attempts yet

Problem

You are given four poker cards and one joker card. When evaluating the poker hand, the joker card can be replaced with any card you want. However, it cannot be replaced with a card you already have. For example, if you already have 6 of hearts, the joker cannot be changed to 6 of hearts.

Find which card the joker should be changed to in order to get the highest hand. The list of hands is in the hint section below. If two hands fall into the same category, they are treated as equal. That is, suits are not ranked.

Input

Four lines are given. The i-th line contains integers SiS_i and RiR_i.

SiS_i is the suit of the i-th poker card. 0 is clubs, 1 is diamonds, 2 is hearts, and 3 is spades.

RiR_i is the rank of the i-th poker card. 1 is ace, 2 to 10 are the number cards, 11 is jack, 12 is queen, and 13 is king.

Output

Print two integers S5S_5 and R5R_5 on the first line. They are the suit and rank of the card the joker should be changed to, using the same encoding as the input.

If multiple answers exist, print any of them.

Constraints

  • 0≤Si≤30 \leq S_i \leq 3
  • 1≤Ri≤131 \leq R_i \leq 13

Hint

The hands are listed below from highest to lowest.

  • Straight flush: five cards of the same suit with consecutive ranks.
  • Quadruple: four cards of the same rank.
  • Full house: three cards of the same rank plus two other cards of the same rank.
  • Flush: five cards of the same suit.
  • Straight: five cards with consecutive ranks.
  • Triple: three cards of the same rank.
  • Two pair: two pairs.
  • Pair: two cards of the same rank.

A hand that meets several conditions at once is scored as the highest hand it meets.

Examples2

  1. Example 1

    Input
    0 1
    1 1
    2 1
    0 2
    
    Expected output
    3 1
    
  2. Example 2

    Input
    1 2
    3 7
    2 2
    0 7
    
    Expected output
    0 2