#include <bits/stdc++.h>
using namespace std;
int n, i, j, len = 0;
string s, dir[10000], t;
int main() {
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> s;
    if (s == "pwd") {
      cout << '/';
      for (j = 0; j < len; ++j) {
        cout << dir[j] << '/';
      }
      cout << '\n';
    } else {
      cin >> s;
      j = 0, t = "";
      if (s[j] == '/') {
        len = 0, ++j;
      }
      for (; j <= s.length(); ++j) {
        if (j == s.length() || s[j] == '/') {
          if (t == "..") {
            --len;
          } else {
            dir[len++] = t;
          }
          t = "";
        } else {
          t += s[j];
        }
      }
    }
  }
  return 0;
}
