import java.io.*;
import java.util.*;

public class ContestSimulator
{
    static class Entry implements Comparable<Entry>
    {
	String team;
	char problem;
	int time;
	int tries;

	Entry(String team, char problem, int time, int tries)
	{
	    this.team = team;
	    this.problem = problem;
	    this.time = time;
	    this.tries = tries;
	}

	public int compareTo(Entry other)
	{
	    return this.time - other.time;
	}
    }

    public static void main(String[] args)
    {
	Scanner in = new Scanner(System.in);
	PrintStream out = System.out;

	List<Entry> list = new ArrayList<Entry>();
	int max = 0;
	while (in.hasNextLine())
	{
	    String line = in.nextLine();
	    String start = "align=left>";
	    line = line.substring(line.indexOf(start) + 11);
	    String[] part = line.split("</td><td align=center>");

	    String name = part[0];
	    max = Math.max(max, name.length());
	    String pattern = "\\d+/\\d+";
	    for (int i = 1; i < 9; i++)
	    {
		if (part[i].matches(pattern))
		{
		    String[] temp = part[i].split("/");
		    char problem = (char) ('A' + i - 1);
		    int tries = Integer.parseInt(temp[0]);
		    int time = Integer.parseInt(temp[1]);
		    list.add(new Entry(name, problem, time, tries));
		}
	    }
	}

	Collections.sort(list);
	    
	for (Entry entry : list)
	{
	    int time = entry.time;
	    int hours = (time % 60 == 0) ? 5 - (time / 60) : 4 - (time / 60);
	    int min = 60 - (time % 60);
	    String pattern = "%d:%02d\t%" + max + "s\t%s\t%d%n";
	    out.printf(pattern, hours, min, entry.team, "" + entry.problem, entry.tries);
	}
    }
}
