#include <bits/stdc++.h>
using namespace std;
vector<string> stk;
int main() {
  int n, i, j;
  string cmd, path, temp;
  cin >> n;
  while (n--) {
    cin >> cmd;
    if (cmd == "cd") {
      cin >> path;
      i = 0;
      if (path[0] == '/') {
        stk.clear();
        i = 1;
      }
      for (; i < path.size(); ++i) {
        temp = "";
        while (i < path.size() && path[i] != '/') {
          temp += path[i];
          i++;
        }
        if (temp == "..") {
          if (stk.empty() == false) stk.pop_back();
        } else {
          stk.push_back(temp);
        }
      }
    } else {
      cout << "/";
      for (i = 0; i < stk.size(); ++i) cout << stk[i] << "/";
      cout << endl;
    }
  }
  return 0;
}
