#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
string s,sr[5005][1005];
int k,t,ca,c[5005],fl,u;
void write(int p){
for(int i = 1; i <= p; i++)
cout<<"|"<<" ";
}
void init(){
k = 0; memset(c, 0, sizeof c);
}
int main(){
while(1){
init();
while(cin>>s){
if(s[0] == '#') {
fl = 1; exit(0);
}
if(!u){
cout<<"DATA SET "<<(++ca)<<":"<<endl;
cout<<"ROOT"<<endl;
}
if(s[0] == 'd'){//第几个d
k++;
write(k); cout<<s<<endl;
}
if(s[0] == 'f'){//第k层的第几个f
c[k]++;
sr[k][c[k]] = s;
}
if(s[0] == ']' || s[0] == '*'){
sort(sr[k]+1, sr[k] + c[k] +1);
for(int i = 1; i <= c[k]; i++){
write(k); cout<<sr[k][i]<<endl;
}
k--;
if(s[0] == '*') {
u = 0; break;
}
}
u = 1;
}
if(fl == 1) break;
}
return 0;
}
/*
DATA SET 1:
ROOT
| dir3
| | dir2
| | | dir4
| | file1
| | file2
| dir1
file1
file2
file3
file4
DATA SET 2:
ROOT
file1
file2
*/
/*
file1
file2
dir3
dir2
file1
file2
dir4
]
]
]
file4
dir1
]
file3
*
*/