#include <bits/stdc++.h>
using namespace std;
int main() {
  string path[500];
  int num = 0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'p') {
      for (int j = 0; j < num; j++) cout << '/' << path[j];
      cout << '/' << endl;
    } else {
      cin >> s;
      int k = s.length();
      int p = 0;
      if (s[0] == '/') {
        num = 0;
        p++;
      }
      while (p < k) {
        string dir = "";
        while (p < k) {
          if (s[p] == '/') break;
          dir += s[p];
          p++;
        }
        if (dir.length() != 0) {
          if (dir[0] == '.')
            num--;
          else {
            if (num < 0) break;
            path[num] = dir;
            num++;
          }
        }
        p++;
      }
    }
  }
  return 0;
}
