#include <bits/stdc++.h>
using namespace std;
void func() {
  long long n;
  cin >> n;
  string s, ans = "/", t;
  for (long long i = 0; i < n; ++i) {
    cin >> s;
    if (s == "cd") {
      cin >> s;
      s = s + "/";
      for (long long j = 0; j < s.length(); ++j) {
        t = t + s[j];
        if (s[j] == '/') {
          if (t == "/") {
            ans = t;
          } else if (t == "../") {
            long long k;
            for (k = ans.length() - 1; ans[k - 1] != '/'; k--)
              ;
            ans = ans.substr(0, k);
          } else {
            ans = ans + t;
          }
          t = "";
        }
      }
    } else {
      cout << ans << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    func();
  }
}
