#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, k;
  int j;
  string s, p = "/", temp;
  scanf("%d", &n);
  for (t = 1; t <= n; t++) {
    cin >> s;
    if (s == "cd") {
      cin >> s;
      s += '/';
      for (j = 0; j < s.length(); j++) {
        temp += s[j];
        if (s[j] == '/') {
          if (temp == "/") {
            p = temp;
          } else if (temp == "../") {
            for (k = p.length() - 1; p[k - 1] != '/'; k--)
              ;
            p.resize(k);
          } else {
            p += temp;
          }
          temp = "";
        }
      }
    } else {
      cout << p << endl;
    }
  }
  return 0;
}
