#include <bits/stdc++.h>
using namespace std;
vector<string> ans;
vector<string> add_path(const string &s) {
  if (s[0] == '/') ans.clear();
  vector<string> strings;
  string tmp;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '/') {
      if (tmp.size()) {
        if (tmp == "..") {
          ans.pop_back();
        } else
          ans.push_back(tmp);
      }
      tmp.clear();
    } else {
      tmp.push_back(s[i]);
    }
  }
  return strings;
}
void print(const vector<string> &vec) {
  cout << "/";
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << "/";
  }
  cout << endl;
}
int main() {
  int q;
  string qt;
  string path;
  cin >> q;
  while (q--) {
    cin >> qt;
    if (qt == "pwd") {
      print(ans);
    } else {
      cin >> path;
      path += "/";
      vector<string> tmp = add_path(path);
    }
  }
}
