#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  cin.ignore();
  string query;
  vector<string> tree;
  for (int i = 0; i < n; i++) {
    getline(cin, query);
    if (query == "pwd") {
      cout << "/";
      for (auto x : tree) cout << x << "/";
      cout << endl;
    } else {
      if (query[3] == '/') tree.clear();
      for (int j = 3; j < query.size(); j++) {
        string tmp = "";
        while (query[j] != '/' && j < query.size()) {
          tmp += query[j];
          j++;
        }
        if (tmp != "" && tmp != "..")
          tree.push_back(tmp);
        else if (tmp == "..")
          tree.pop_back();
      }
    }
  }
  return 0;
}
