#include <bits/stdc++.h>
using namespace std;
int main(){
#ifdef ERFANUL007
clock_t tStart = clock();
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
string s;
while(getline(cin, s)){
// cout << s << '\n';
deque< string > ans;
string temp = "";
bool isfront = false;
for(int i=0; i<s.size(); i++){
if(s[i] == '['){
if(isfront) ans.push_front(temp);
else ans.push_back(temp);
isfront = true;
temp = "";
}
else if(s[i] == ']'){
isfront = false;
else temp += s[i];
while(!ans.empty()){
cout << ans.front();
ans.pop_front();
cout << '\n';
fprintf(stderr, "\n>>> Runtime : %.9fs\n", (double) (clock() - tStart)/CLOCKS_PER_SEC);
return 0;