#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> path(1, "");
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string cmd;
    cin >> cmd;
    if (cmd == "pwd") {
      for (int j = 0; j < (int)path.size(); ++j) cout << path[j] << "/";
      cout << "\n";
    } else {
      string sc;
      cin >> sc;
      int j = 0;
      if (sc[0] == '/') {
        path = vector<string>(1, "");
        ++j;
      }
      string newdir;
      for (; j <= sc.length(); ++j) {
        if (j >= sc.length() || sc[j] == '/') {
          if (newdir == "..")
            path.pop_back();
          else
            path.push_back(newdir);
          newdir.clear();
        } else
          newdir += sc[j];
      }
    }
  }
  return 0;
}
