#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string p("/"), t;
  while (n--) {
    string foo;
    cin >> foo;
    if (foo == "pwd") {
      cout << p << endl;
    } else {
      string dir;
      cin >> dir;
      dir += '/';
      for (int i = 0; i < dir.length(); i++) {
        t += dir[i];
        if (dir[i] == '/') {
          if (t == "/")
            p = t;
          else if (t == "../") {
            for (int j = p.length() - 1; j > 0 && p[j - 1] != '/'; j--) {
              p.resize(j - 1);
            }
          } else
            p += t;
          t = "";
        }
      }
    }
  }
  return 0;
}
