#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n;
  vector<string> st;
  for (int it = 0; it < n; it++) {
    cin >> s;
    if (s == "pwd") {
      printf("/");
      for (int i = 0; i < (int)(st).size(); i++) {
        printf("%s/", st[i].c_str());
      }
      printf("\n");
    } else {
      cin >> s;
      int ff = 0;
      if (s[0] == '/') {
        st.clear();
        ff = 1;
      }
      if (s == "/") continue;
      s += "/";
      string tk = "";
      for (int i = ff; i < (int)(s).size(); i++) {
        if (s[i] == '/') {
          if (tk == "..") {
            st.pop_back();
          } else {
            st.push_back(tk);
          }
          tk = "";
        } else {
          tk += s[i];
        }
      }
    }
  }
  return 0;
}
