#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
  cin >> n;
  int kol = 0;
  string s[1000];
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    if (str == "cd") {
      cin >> str;
      string sss = "";
      int g = 0;
      if (str[g] == '/') {
        kol = 0;
        g++;
      }
      while (g < int(str.size())) {
        if (str[g] == '/') {
          s[kol] = sss;
          kol++;
          sss = "";
          g++;
          continue;
        }
        if (str[g] == '.') {
          kol--;
          g++;
          g++;
          g++;
          continue;
        }
        sss += str[g];
        g++;
        continue;
      }
      if (int(sss.size()) != 0) {
        s[kol] = sss;
        kol++;
      }
    }
    if (str == "pwd") {
      cout << '/';
      for (int j = 0; j < kol; j++) {
        cout << s[j] << '/';
      }
      cout << endl;
    }
  }
  return 0;
}
