#include<stdio.h>
#include<malloc.h>
#include<string.h>
char ss[3][10] = { "print", "hires", "fire" };
char nam1[25], opreate[10], nam2[25];
struct node
{
char name[25];
int num;
struct node *next;
};
void Print(struct node *start)
{
struct node *p = start->next;
while (p != NULL)
{
for (int i = 0; i < p->num; i++)
{
printf("+");
}
printf("%s\n", p->name);
p = p->next;
}
printf("------------------------------------------------------------\n");
return;
}
void Hires(struct node *p)
{
while (p->next != NULL)
{
if (strcmp(p->next->name, nam1) == 0)
break;
p = p->next;
}
int nu = p->next->num + 1;
p = p->next;
while (p->next != NULL)
{
if (p->next->num <nu)
break;
p = p->next;
}
struct node *q, *p1;
p1 = p->next;
q = (struct node *)malloc(sizeof(struct node));
q->num = nu;
strcpy(q->name, nam2);
p->next = q;
q->next = p1;
return;
}
void Fire(struct node *p)
{
while (p->next != NULL)
{
if (strcmp(p->next->name, nam2) == 0)
break;
p = p->next;
}
struct node *q = p->next, *p1 = p->next;
int nnu = p1->num;
while (p1->next != NULL&&p1->next->num > nnu)
{
nnu = p1->next->num;
p1->next->num--;
p1 = p1->next;
}
p->next = q->next;
free(q);
return;
}
int main()
{
char CEO[25];
scanf("%s", CEO);
getchar();
struct node *head;
head = (struct node *)malloc(sizeof(struct node));
head->next = NULL; head->num = -1;
struct node *p;
p = (struct node *)malloc(sizeof(struct node));
head->next = p;
p->num = 0;
strcpy(p->name, CEO);
p->next = NULL;
while (scanf("%s", nam1) != EOF)
{
if (strcmp(ss[0], nam1) == 0)
Print(head);
else if (strcmp(ss[2], nam1) == 0)
{
scanf("%s", nam2);
Fire(head);
}
else
{
scanf("%s", opreate);
scanf("%s", nam2);
Hires(head);
}
}
return 0;
}