use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: i128 = read();
    let s: Vec<String> = (0..n).map(|_| read()).collect();
    
    let mut ac : i128 = read();
    let mut wa : i128 = read();
    let mut tle : i128 = read();
    let mut re : i128 = read();

    for elem in s {
        if elem == "AC" {
            ac += 1;
        } else if elem == "WA" {
            wa += 1;
        } else if elem == "TLE" {
            tle += 1;
        } else if elem == "RE" {
            re += 1;
        }
    }

    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);

}