#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> st;
  string cmd, tmp, tmp2;
  for (int i = 0; i < n; ++i) {
    cin >> cmd;
    if (cmd == "pwd") {
      cout << '/';
      for (int j = 0; j < st.size(); ++j) cout << st[j] << '/';
      cout << endl;
    } else {
      cin >> tmp;
      tmp2 = "";
      for (int i = 0; i < tmp.size(); ++i)
        if (tmp[i] != '/')
          tmp2 += tmp[i];
        else {
          if (tmp2 == "")
            st.clear();
          else if (tmp2 == "..")
            st.pop_back();
          else
            st.push_back(tmp2);
          tmp2 = "";
        }
      if (tmp2 == "")
        st.clear();
      else if (tmp2 == "..")
        st.pop_back();
      else
        st.push_back(tmp2);
    }
  }
  return 0;
}
