#include <bits/stdc++.h>
using namespace std;
string v, s;
int main() {
  int t, x;
  cin >> t;
  while (t--) {
    cin >> s;
    if (s == "pwd") {
      cout << v << "/" << endl;
    } else {
      cin >> s;
      if (s[0] == '/') {
        v = s;
      } else {
        v += '/' + s;
      }
      while ((x = v.find("..")) != -1) {
        int j = x - 2;
        while (v[j] != '/') {
          j--;
        }
        v.erase(j, x - j + 2);
      }
    }
  }
  return 0;
}
