#include <bits/stdc++.h>   using namespace std;   int n, depth = 0;   string loc[500];   string comm;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> comm;       if (comm ==  cd ) {         cin >> comm;         int pos = 0;         if (comm[0] ==  / ) {           depth = 0;           pos = 1;         }         string dir =   ;         for (; pos < comm.length(); ++pos) {           if (comm[pos] !=  / ) dir += comm[pos];           if (comm[pos] ==  /  || pos == comm.length() - 1) {             if (dir ==  .. )               depth--;             else               loc[depth++] = dir;             dir =   ;           }         }       } else {         for (int i = 0; i < depth; ++i) cout <<  /  << loc[i];         cout <<  /  << endl;       }     }   }   