#include <bits/stdc++.h>
using namespace std;
int main(void) {
  register int n;
  register int i;
  int length;
  cin >> n;
  cin.ignore(numeric_limits<streamsize>::max(), '\n');
  list<string> path;
  list<string>::const_iterator itr;
  string command, dir;
  while (n--) {
    getline(cin, command);
    length = command.length();
    if (length == 3) {
      cout << '/';
      for (itr = path.begin(); itr != path.end(); ++itr) cout << *itr << '/';
      cout << '\n';
    } else {
      if (command[3] == '/') path.clear();
      istringstream iss(command);
      getline(iss, dir, ' ');
      while (getline(iss, dir, '/')) {
        if (dir.empty()) continue;
        if (dir == "..")
          path.pop_back();
        else
          path.push_back(dir);
      }
    }
  }
}
