Professor R.'s grandson enjoys watching the classic Tetris World Championships. For anyone who might have forgotten what classic Tetris is, let's take a moment to refresh your memory.
The Classic Tetris World Championship (CTWC) is a video game competition series organized by the Portland Retro Gaming Expo. It was first held in 2010 during the production of the film "Ecstasy of Order: The Tetris Masters". The championship's goal is to determine the world's top Tetris player. For its first two years, the championship took place in Los Angeles, California, but then it moved to Portland, Oregon, where it has been held annually since 2012.
Participants in the tournament compete using the 1989 Nintendo version of Tetris on the Nintendo Entertainment System, played on specialized TVs. The final rounds are streamed online and displayed on screens, with a head-up display added to enhance the viewing experience for the audience.
Let's recall how the game "Tetris" works. There are 7 types of tetramino shapes in the game, each identified by a specific letter (see the image below).
In Tetris, random tetromino shapes fall from the top into a rectangular playfield that is 10 cells wide and 20 cells high. While the piece is falling, the player can rotate it 90 degrees or move it horizontally. It's also possible to "drop" the piece – to make it fall faster once its landing spot is decided. Each piece continues to fall until it lands on another piece or reaches the bottom of the playfield. When a horizontal row of 10 cells is completely filled, it disappears, and all blocks above it shift down by one row. A preview of the next piece is also shown, allowing the player to plan their moves ahead. As the game progresses, the speed gradually increases. The game ends when a new piece can no longer fit into the playfield. Players earn points for each filled row, so the main goal is to complete as many horizontal lines as possible while preventing the playfield from filling up vertically, maximizing their score.
In the Classic Tetris World Championship, players start at level 18, where a player gets 760 points for one filled row, 1900 points for two filled rows, 5700 points for three, and 22800 points for tetris (four filled rows). Once the player clears at least 130 rows, the number of points per row increases by 40, for two rows by 100, for three rows by 300, for tetris by 1200. At the same time, the player advances to level 19, where the falling speed of the pieces also increases. Every time the total number of cleared lines reaches 140, 150, and so on, the player moves up another level, with the points increasing by the values indicated earlier.
Professor R.'s grandson wrote down the game log of the winner of the match he has just watched, but he forgot how many points the winner scored. Help him determine how many points the winner earned by the end of the game.
The first line contains the number $$$N$$$ $$$(1 \le N \le 10^5)$$$ – the number of the player's scoring actions. The following $$$N$$$ lines contain the game log: one of the four lines is $$$single$$$ if the winner filled one row, $$$double$$$ if two, $$$triple$$$ if three, or $$$tetris$$$ if the player filled four rows.
In a single line, print two numbers separated by a space – the number of points scored by the winner of the game and the level at which he finished the game.
4singledoubletripletetris
31160 18
2singlesingle
1520 18
In the first test case, the winner scored 760 + 1900 + 5700 + 22800 = 31160 points.
| Name |
|---|


