This page is still under construction.

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

Coin tossing

Time limit1sMemory limit128 MB

Summary
Count each game's correct calls for the first player and misses for the second player, then print both names with their scores.
Level

Easy1 of 10

Topics
Implementation
Solved
No attempts yet

Problem

Years ago at school we played a simple game with a coin. The first player calls heads or tails, then the second player tosses the coin. The first player gains a point for every correct call, and the second player gains a point for every incorrect one. Once we got bored, we added up the scores.

Given the records of several games, work out the final score of each one.

Input

The input holds several games. Each game starts with a line of two names separated by one space, and each name is at most 20 letters. The next line holds one positive integer nn, the number of recorded tosses (0<n≤10000 < n \le 1000). Then follow nn lines, each with two characters separated by one space. The first character is the call and the second is the result, where H means heads and T means tails. A line containing only # # ends the input.

Output

Print one line per game. Each line holds the first player's name exactly as it appeared in the input, that player's score, the second player's name, and that player's score, separated by single spaces.

Examples1

  1. Example 1

    Input
    Sally John
    5
    H H
    H T
    H H
    T T
    T H
    Eloise Ahmed
    4
    H T
    T T
    H H
    T H
    # #
    
    Expected output
    Sally 3 John 2
    Eloise 2 Ahmed 2