This page is still under construction.

Parts of this page are still being built. What you see may change.

Jean and Joe's Clothes

Interview

Time limit1sMemory limit128 MB

Summary
Read clothing sizes and count how many items go to Joe, Jean, Jane, James, or no one, per visit until N equals 0.
Level

Easy2 of 10

Topics
Implementation, Simulation, String, Math
Solved
No attempts yet

Problem

Jean and Joe are an untidy couple who share a similar taste in clothes. Their two children, Jane and James, dress in the same style.

Jean's mother came to stay and was horrified by the untidy state of the house. Judging only by the size printed on each item, she sorted every piece of clothing into a separate pile for each of the four people. Sometimes the size had been cut off or was unreadable, so those items went into a separate "unknown" pile.

Classify each item with these rules:

  • If the size is M or L, it belongs to Joe.
  • If the size is S, it belongs to James.
  • If the size is a number 12 or greater, it belongs to Jean.
  • If the size is a number smaller than 12, it belongs to Jane.

Jean's mother visits often and must repeat this every time. Write a program that does the sorting for her.

Input

The input describes several visits.

For each visit, the first line contains an integer NN (0<N≤500 < N \le 50), the number of clothing items found around the house. Each of the next NN lines gives the size of one item: a 1- or 2-digit number, or one of the letters S, M, or L, or the letter X if the size is missing or unreadable.

The input ends with a line containing N=0N = 0, which must not be processed.

Output

For each visit, print one line with five integers separated by single spaces: the number of items belonging to Joe, Jean, Jane, and James, in that order, followed by the number of items that could not be assigned to anyone. Print 0 for any empty pile.

Examples3

  1. Example 1

    Input
    8
    M
    12
    X
    14
    10
    L
    S
    S
    0
    
    Expected output
    2 2 1 2 1
    
  2. Example 2

    Input
    6
    11
    12
    S
    M
    L
    X
    0
    
    Expected output
    2 1 1 1 1
    
  3. Example 3

    Input
    4
    12
    13
    10
    11
    0
    
    Expected output
    0 2 2 0 0