#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s[50];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i] == "cd") {
      string s1;
      cin >> s1;
      s[i] = s[i] + " " + s1;
    }
  }
  string p = "/";
  for (int i = 0; i < n; i++) {
    if (s[i] == "pwd") {
      cout << p << endl;
      continue;
    }
    for (int j = 3; j < s[i].length(); j++) {
      if (s[i][j] == '/' && j == 3) {
        p = "/";
      } else if (s[i][j] != '.') {
        p += s[i][j];
      } else {
        string t = "";
        int k = p.length() - 2;
        while (p[k] != '/') {
          k--;
        }
        k--;
        while (k >= 0) {
          t = p[k--] + t;
        }
        p = t;
        j++;
      }
    }
    if (p[p.length() - 1] != '/') p += '/';
  }
  return 0;
}
