#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string x = "/";
  for (int k = 0; k < n; k++) {
    string com;
    cin >> com;
    if (com == "pwd") {
      cout << x << endl;
    } else {
      string path;
      cin >> path;
      if (path[0] == '/') {
        x = "";
        for (int i = 0; i < path.length(); i++) {
          int op = 0;
          if (path[i] != '.')
            x += path[i];
          else {
            for (int h = x.length() - 2; h >= 0; h--) {
              if (x[h] != '/')
                op++;
              else {
                x.erase(h, op + 2);
                break;
              }
            }
            i++;
          }
        }
        x += "/";
      } else {
        for (int i = 0; i < path.length(); i++) {
          int op = 0;
          if (path[i] != '.')
            x += path[i];
          else {
            for (int h = x.length() - 2; h >= 0; h--) {
              if (x[h] != '/')
                op++;
              else {
                x.erase(h, op + 2);
                break;
              }
            }
            i++;
          }
        }
        x += "/";
      }
    }
  }
  return 0;
}
