malloc
문제
Write a program that will simulate the execution of memory allocation commands.
Memory is a sequence of 100,000 continuous memory locations, numbered from 1 to 100,000.
In the beginning, all locations are free.
Commands that can occur are:
1.) var=malloc(size);
This function finds the first size (100 ≤ size ≤ 100,000) continuous free locations, and allocates them. Return value of this function is either the address of the first allocated location or 0 if there is no such sequence.
2.) free(var);
This function frees all the memory locations assigned to the variable var (by previous use of malloc) and sets the value of var to 0.
If the value of variable var is already 0, nothing happens.
3.) print(var);
This function prints the value of variable var.
Every command line ends with a semicolon (';').
Variables are strings of exactly four small letters of the english alphabet ('a'...'z').
Number of different variables will be less than or equal to 1000.
All variables are set to 0 in the beginning.
입력
In the first line there is an integer N, 1 ≤ N ≤ 100,000, number of commands (at least one of the commands will be 'print').
In each of the following N lines there is one command, in order of their execution.
출력
Write the results of all 'print' commands, in order of their execution, each one in separate line.
예제
예제 1
3 mama=malloc(140); tata=malloc(120); print(tata);
141
예제 2
5 aabb=malloc(50001); bbaa=malloc(50000); print(aabb); free(aabb); print(bbaa);
1 0
예제 3
5 baka=malloc(214); baka=malloc(123); free(baka); deda=malloc(100); print(deda);
215