#include <bits/stdc++.h>
using namespace std;
vector<string> path;
int main() {
  int n;
  cin >> n;
  for (int i = (1); i <= (n); i++) {
    string command;
    cin >> command;
    if (command == "pwd") {
      for (__typeof((path).begin()) it = (path).begin(); it != (path).end();
           ++it)
        cout << "/" << (*it);
      cout << "/";
      cout << endl;
    } else {
      string p;
      cin >> p;
      bool absolute = (p[0] == '/');
      for (__typeof((p).begin()) it = (p).begin(); it != (p).end(); ++it)
        if (*it == '/') (*it) = ' ';
      if (absolute) {
        path.clear();
      }
      stringstream w(p);
      string x;
      while (w >> x) {
        if (x == "..")
          path.pop_back();
        else
          path.push_back(x);
      }
    }
  }
  return 0;
}
