#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   long long int power(long long int x, long long int y) {     long long int res = 1;     x = x;     while (y > 0) {       if (y & 1) res = (res * x);       y = y >> 1;       x = (x * x);     }     return res;   }   long long int power(long long int x, long long int y, long long int p) {     long long int res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long int gcd(long long int a, long long int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   void solve() {     long long int n;     cin >> n;     vector<string> v;     while (n--) {       string s;       cin >> s;       if (s ==  pwd ) {         cout <<  / ;         for (int i = 0; i < v.size(); i++) {           cout << v[i] <<  / ;         }         cout << endl;       } else {         string s;         cin >> s;         vector<string> temp;         string te;         if (s[0] ==  / ) v.clear();         for (int i = 0; i < s.length(); i++) {           if (s[i] !=  / )             te.push_back(s[i]);           else {             if (i != 0) {               temp.push_back(te);               te.clear();             }           }         }         temp.push_back(te);         ;         for (int i = 0; i < temp.size(); i++) {           if (temp[i] ==  .. ) {             v.pop_back();           } else             v.push_back(temp[i]);         }       }     }   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long int t = 1;     while (t--) {       solve();     }     return 0;   }   