Under construction

Still being built. Things may change

Halli Galli

Interview

Time limit1sMemory limit1024 MB

Summary
Given the revealed cards, decide whether any single fruit kind totals exactly 5 across all cards so Hanbyeol should ring the bell.
Level

Easy2 of 10

Topics
Implementation, Hash map
Solved
No attempts yet

Problem

Figure B.1: Halli Galli

Halli Galli is a board game made of a bell with a button and cards with drawn fruits.

Each card shows up to 55 fruits. There are 44 kinds of fruit: strawberry, banana, lime, and plum.

At the start, players split the deck evenly. A player who uses up all their cards loses.

The game starts when the first player reveals one card from their deck. After that, players reveal one card each in counterclockwise order.

If the revealed cards contain exactly 55 fruits of at least one kind, players must ring the bell. The player who rings first takes all the revealed cards and places them under their own deck. A player who rings incorrectly gives one card to each of the other players.

Hanbyeol is new to Halli Galli and wants to beat Hina, an expert. Given the list of revealed cards, tell Hanbyeol whether to ring the bell.

Input

The first line contains the number of revealed cards NN.

Each of the next NN lines contains one revealed card. A card is given as a fruit kind SS and a positive integer XX for the number of fruits, separated by a space.

SS is one of STRAWBERRY, BANANA, LIME, or PLUM.

Output

Print YES if Hanbyeol should ring the bell. Otherwise, print NO.

Constraints

  • 1≤N≤100 0001 \le N \le 100\,000
  • 1≤X≤51 \le X \le 5
  • All numbers in the input are integers.

Examples4

  1. Example 1

    Input
    3
    BANANA 2
    PLUM 4
    BANANA 3
    
    Expected output
    YES
    
  2. Example 2

    Input
    4
    STRAWBERRY 1
    BANANA 2
    LIME 3
    PLUM 4
    
    Expected output
    NO
    
  3. Example 3

    Input
    2
    LIME 5
    LIME 1
    
    Expected output
    NO
    
  4. Example 4

    Input
    2
    BANANA 5
    BANANA 5
    
    Expected output
    NO