/**
* code generated by JHelper
* More info: https://g...content-available-to-author-only...b.com/AlexeyDmitriev/JHelper
* @author RiaD
*/
#include <iostream>
#include <fstream>
#include <iostream>
#include <cassert>
#include <deque>
#include <iomanip>
#include <vector>
#include <array>
#include <algorithm>
#include <iterator>
#include <string>
#include <stdexcept>
#ifndef SPCPPL_ASSERT
#ifdef SPCPPL_DEBUG
#define SPCPPL_ASSERT(condition) \
if(!(condition)) { \
throw std::runtime_error(std::string() + #condition + " in line " + std::to_string(__LINE__) + " in " + __PRETTY_FUNCTION__); \
}
#else
#define SPCPPL_ASSERT(condition)
#endif
#endif
/**
* Support decrementing and multi-passing, but not declared bidirectional(or even forward) because
* it's reference type is not a reference.
*
* It doesn't return reference because
* 1. Anyway it'll not satisfy requirement [forward.iterators]/6
* If a and b are both dereferenceable, then a == b if and only if *a and
* b are bound to the same object.
* 2. It'll not work with reverse_iterator that returns operator * of temporary which is temporary for this iterator
*
* Note, reverse_iterator is not guaranteed to work now too since it works only with bidirectional iterators,
* but it's seems to work at least on my implementation.
*
* It's not really useful anywhere except iterating anyway.
*/
template <typename T>
class IntegerIterator {
public:
using value_type = T;
using difference_type = std::ptrdiff_t;
using pointer = T*;
using reference = T;
using iterator_category = std::input_iterator_tag;
explicit IntegerIterator(T value): value(value) {
}
IntegerIterator& operator++() {
++value;
return *this;
}
IntegerIterator operator++(int) {
IntegerIterator copy = *this;
++value;
return copy;
}
IntegerIterator& operator--() {
--value;
return *this;
}
IntegerIterator operator--(int) {
IntegerIterator copy = *this;
--value;
return copy;
}
T operator*() const {
return value;
}
bool operator==(IntegerIterator rhs) const {
return value == rhs.value;
}
bool operator!=(IntegerIterator rhs) const {
return !(*this == rhs);
}
private:
T value;
};
template <typename T>
class IntegerRange {
public:
IntegerRange(T begin, T end): begin_(begin), end_(end) {
SPCPPL_ASSERT(begin <= end);
}
IntegerIterator<T> begin() const {
return IntegerIterator<T>(begin_);
}
IntegerIterator<T> end() const {
return IntegerIterator<T>(end_);
}
private:
T begin_;
T end_;
};
template <typename T>
class ReversedIntegerRange {
using IteratorType = std::reverse_iterator<IntegerIterator<T>>;
public:
ReversedIntegerRange(T begin, T end): begin_(begin), end_(end) {
SPCPPL_ASSERT(begin >= end);
}
IteratorType begin() const {
return IteratorType(IntegerIterator<T>(begin_));
}
IteratorType end() const {
return IteratorType(IntegerIterator<T>(end_));
}
private:
T begin_;
T end_;
};
template <typename T>
IntegerRange<T> range(T to) {
return IntegerRange<T>(0, to);
}
template <typename T>
IntegerRange<T> range(T from, T to) {
return IntegerRange<T>(from, to);
}
template <typename T>
IntegerRange<T> inclusiveRange(T to) {
return IntegerRange<T>(0, to + 1);
}
template <typename T>
IntegerRange<T> inclusiveRange(T from, T to) {
return IntegerRange<T>(from, to + 1);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from) {
return ReversedIntegerRange<T>(from, 0);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from, T to) {
return ReversedIntegerRange<T>(from, to);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from) {
return ReversedIntegerRange<T>(from + 1, 0);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {
return ReversedIntegerRange<T>(from + 1, to);
}
//#define PROBLEM "problem_name.h"
//#include PROBLEM
//#include <message.h>
//#include <spcppl/dgcj.h>
using namespace std;
class Khokkei {
public:
static constexpr int kStressCount = 0;
static void generateTest(std::ostream& test) {
}
void solve(std::istream& in, std::ostream& out) {
//static int testnumber = 0;
//out << "Case #" << ++testnumber << ": ";
//cerr << "test " << testnumber << endl;
int n;
in >> n;
deque<int> minors[2];
deque<int> majors[2];
array<array<int, 6>, 6> times{};
int old_time = 0;
auto add = [&](int rt) {
//cerr << old_time / 600 << ":" << old_time % 600 << " " << rt / 600 << ":" << rt % 600 << " "
// << 5 - minors[0].size() - majors[0].size() << "x" << 5 - minors[1].size() - majors[1].size() << endl;
times[5 - minors[0].size() - majors[0].size()][5 - minors[1].size() - majors[1].size()] += rt - old_time;
old_time = rt;
};
auto process = [&](int rt) {
while (true) {
int mn = rt;
for (auto* ar: {&minors, &majors}) {
for (int i: range(2)) {
auto& c = (*ar)[i];
if (!c.empty()) {
mn = min(mn, c.front());
}
}
}
add(mn);
for (auto* ar: {&minors, &majors}) {
for (int i: range(2)) {
auto& c = (*ar)[i];
while (!c.empty() && c.front() == mn) {
c.pop_front();
}
}
}
if (mn == rt) {
return;
}
}
};
auto goal = [&](int time, int team) {
//cerr << time / 600 << ":" << time %600 << " "<< minors[0].size() << " " << minors[1].size() << "\n";
if (minors[team].size() + majors[team].size() < minors[!team].size() + majors[!team].size()) {
if (!minors[!team].empty()) {
minors[!team].pop_front();
}
}
};
for (int i: range(n)) {
string s;
in >> s;
int team;
string type;
in >> team >> type;
--team;
int rt = (((s[0] - '0') * 10 + s[1] - '0') * 60 + (s[3] - '0') * 10 + (s[4] - '0')) * 10 + s[6] - '0';
process(rt);
if (type == "goal") {
goal(rt, team);
}
else if (type == "minor") {
minors[team].push_back(rt + 2 * 60 * 10);
}
else if (type == "major") {
majors[team].push_back(rt + 5 * 60 * 10);
}
else {
assert(false);
}
}
process(60 * 60 * 10);
for (int i: inclusiveRange(0, 5)) {
for (int j: inclusiveRange(0, 5)) {
if (times[i][j]) {
int t = times[i][j];
out << i << "x" << j << " " << setfill('0') << setw(2) << (t / 10 / 60) << ":" << setfill('0') << setw(2) << (t / 10 % 60) << "." << setw(1) << (t % 10) << "\n";
}
}
}
}
};
int main() {
std::ios_base::sync_with_stdio(false);
Khokkei solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
in.tie(nullptr);
out << std::fixed;
out.precision(20);
solver.solve(in, out);
return 0;
}