Hide

Problem C
Git Good

Languages en sv

Doris’s younger brother Boris has recently started working as a programmer at E-Max (an online hamburger chain). Like all major companies, E-Max uses the version control system git to save changes to the codebase. Unfortunately, Boris hasn’t learned git yet and needs help!

When saving a change with git, three things need to be done:

  • Add all changes to a file using the command git add <file>, where <file> corresponds to the file to be added.

  • Save the changes by creating a “commit” with the command git commit, which opens a window where you describe the changes.

  • Push all changes to the server with the command git push.

Boris always works in the terminal and also has his development environment, nano, there. In a terminal, there is a current “working directory”, the current folder, and all files and folders in it can be easily referred to using their names.

The commands Boris uses are:

  • cd <directory> - Changes the working directory to <directory> (which is in the working directory).

  • cd .. - Changes the working directory to the one above the current working directory (goes back one directory).

  • nano <file> - Opens the file <file> (which is in the working directory).

Boris will start and end in the same directory, and he will never go up to a directory above it. You are given a list of all commands Boris has written since starting his new change, consisting of commands of the type cd <directory>, cd .., and nano <file>. He wants you to output a list of commands he should use to save this change in git. It will be by first adding all the files he opened in nano using git add <file>, and then saving the change with git commit and pushing his change online with git push.

Note that to refer to a file inside other directories, you must write <dir1>/<dir2>/<dir3>/.../<file>, where <dir1> is in your working directory, <dir2> is in <dir1>, and so on. Hint! All of this corresponds to an actual terminal, and if you are unsure about what is meant, you can experiment in a terminal yourself (in Windows, use \ instead of /).

Input

The first line contains the integer $N$ ($1 \leq N \leq 10^4$).

Then follow $N$ lines, each containing a command (cd <directory>, cd .., or nano <file>). Each file and directory consists of uppercase and lowercase letters from A-Z and is at most 31 letters long. Additionally, no file paths will be longer than 256 characters. Names are unique within a directory but not between directories. File names also contain exactly one period (but never as the first or last character).

Output

For each modified file, those Boris opened with Nano, print git add <file> where <file> is the shortest path to the file. The lines of git add <file> commands should be printed in alphabetical order of the path <file>.

After all git add <file> commands, print the commands git commit and git push on separate lines.

Scoring

Group

Point value

Constraints

$1$

$20$

All files are in the same directory.

$2$

$20$

All files and directories are visited only once (except through cd ..).

$3$

$20$

Names are unique even between directories.

$4$

$40$

No additional restrictions.

Sample Input 1 Sample Output 1
5
nano supersecret.secret
nano programmering.olympiad
nano supersecret.secret
nano temp.t
nano temp.t
git add programmering.olympiad
git add supersecret.secret
git add temp.t
git commit
git push
Sample Input 2 Sample Output 2
5
cd folders
nano temp.t
cd downloads
cd ..
cd ..
git add folders/temp.t
git commit
git push
Sample Input 3 Sample Output 3
6
cd folders
nano familyphoto.jpeg
nano crazy.no
cd ..
cd problemlists
cd ..
git add folders/crazy.no
git add folders/familyphoto.jpeg
git commit
git push