#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> cur;
string s1, s2;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> s1;
    if (s1 == "pwd") {
      printf("/");
      for (int i = 0; i < ((int)(cur).size()); i++) {
        cout << cur[i] << "/";
      }
      cout << "\n";
    } else {
      cin >> s2;
      int t = 0;
      if (s2[t] == '/') {
        cur.clear();
        t++;
      }
      string ss = "";
      while (t < ((int)(s2).size())) {
        if (islower(s2[t]) || s2[t] == '.') {
          ss += s2[t];
          t++;
        } else {
          t++;
          if (ss == "..")
            cur.pop_back();
          else
            cur.push_back(ss);
          ss = "";
        }
      }
      if (ss == "..")
        cur.pop_back();
      else
        cur.push_back(ss);
    }
  }
  return 0;
}
