#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b = -1, act = 3, p = 0;
  cin >> n;
  string cad[n], pila[2000], cd, pwd;
  for (int i = 0; i < n; i++) {
    do {
      getline(cin, cad[i]);
    } while (cad[i] == "");
  }
  for (int i = 0; i < n; i++) {
    cd = cad[i].substr(0, 2);
    pwd = cad[i].substr(0, 3);
    if (cd == "cd") {
      if (cad[i].substr(3, 1) == "/" && b > -1) {
        do {
          pila[b] == "";
          b--;
        } while (b > -1);
      }
      act = 3;
      for (int j = act; j < cad[i].size(); j++) {
        p++;
        if (cad[i].substr(j, 1) == "/" && j != act) {
          pila[++b] = cad[i].substr(act, p);
          p = 0;
          act = j + 1;
        }
        if (j == cad[i].size() - 1 &&
            cad[i].substr(cad[i].size() - 1, 1) != "/") {
          pila[++b] = cad[i].substr(act, p) + "/";
          p = 0;
        }
        if (pila[b].substr(0, 1) == "/" && j > act) {
          pila[b] = pila[b].substr(1, pila[b].size());
        }
        if (pila[b] == "../" || pila[b] == "..") {
          pila[b] = "";
          pila[--b] = "";
          b--;
        }
      }
      if (pila[0].substr(0, 1) != "/") pila[0] = "/" + pila[0];
    }
    if (pwd == "pwd") {
      if (b > -1) {
        for (int j = 0; j <= b; j++) cout << pila[j];
      } else if (b == -1)
        cout << " /";
      cout << endl;
    }
  }
}
