#include <bits/stdc++.h>
using namespace std;
void printPath(list<string> &dir) {
  cout << "/";
  for (list<string>::iterator it = dir.begin(); it != dir.end(); it++) {
    cout << *it << "/";
  }
  cout << endl;
}
int main() {
  int n, i;
  string input;
  list<string> dir;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> input;
    if (input == "pwd") {
      printPath(dir);
    } else {
      cin >> input;
      if (input.at(0) == '/') {
        dir.clear();
        input = input.substr(1);
      }
      stringstream ss(input);
      string item;
      while (getline(ss, item, '/')) {
        if (item == "..")
          dir.pop_back();
        else
          dir.push_back(item);
      }
    }
  }
}
