#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  string ans = "/";
  while (T--) {
    string s;
    cin >> s;
    if (s[0] == 'p') {
      cout << ans << endl;
      continue;
    }
    cin >> s;
    if (s[0] == '/')
      ans = s + '/';
    else
      ans += s + '/';
    while (1) {
      int flag = 1;
      int x = ans.find("..");
      if (x == -1) break;
      int c = 0;
      int i;
      for (i = x + 1; i >= 0; i--) {
        if (ans[i] == '/') {
          if (!flag) break;
          flag = 0;
        }
        c++;
      }
      ans.erase(i, c + 1);
    }
  }
  return 0;
}
