#include <bits/stdc++.h>
using namespace std;
vector<string> st;
string s[200];
int main() {
  int n;
  cin >> n;
  for (int rep = 1; rep <= n; rep++) {
    string t;
    cin >> t;
    if (t == "pwd") {
      for (int i = 0; i < st.size(); i++) cout << "/" << st[i];
      cout << "/" << endl;
    }
    if (t == "cd") {
      string x;
      cin >> x;
      int p = 0;
      s[p] = "";
      if (x[0] == '/') st.clear();
      for (int i = 0; i < x.size(); i++)
        if (x[i] == '/')
          p++, s[p] = "";
        else
          s[p] += x[i];
      for (int i = 0; i <= p; i++)
        if (s[i] == "..")
          st.pop_back();
        else if (s[i].size())
          st.push_back(s[i]);
    }
  }
  return 0;
}
