#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
void MakePath(vector<string> &path, string add_path) {
  for (int i = 0; i < add_path.size(); ++i)
    if (add_path[i] == '/')
      path.push_back("");
    else if (add_path[i] == '.') {
      path.pop_back();
      path.pop_back();
      ++i;
    } else
      path.back() += add_path[i];
}
int main() {
  int n;
  vector<string> output, path;
  string command, param;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> command;
    if (command == "pwd") {
      output.push_back("/");
      for (int i = 0; i < path.size(); ++i) {
        output.back() += path[i];
        output.back() += '/';
      }
    } else if (command == "cd") {
      cin >> param;
      if (param == "..")
        path.pop_back();
      else if (param[0] == '/') {
        path.clear();
        MakePath(path, param);
      } else {
        path.push_back("");
        MakePath(path, param);
      }
    }
  }
  for (int i = 0; i < output.size(); ++i) cout << output[i] << endl;
  return 0;
}
