#include <bits/stdc++.h>
using namespace std;
char path[10050];
int main() {
  int n;
  path[0] = '/';
  while (cin >> n) {
    char jud[10];
    int k = 1;
    while (n--) {
      cin >> jud;
      if (jud[0] == 'p') {
        cout << path << endl;
      } else if (jud[0] == 'c') {
        char str[250];
        cin >> str;
        int cdlen = strlen(str);
        if (str[0] == '/') k = 1;
        for (int i = 0; i < cdlen - 1; ++i) {
          if (str[i] != '.' || str[i + 1] != '.') {
            if (str[i] != '/' || path[k - 1] != '/') path[k++] = str[i];
          } else {
            for (int j = k - 2; j >= 0; --j) {
              if (path[j] == '/') {
                k = j;
                break;
              }
            }
            ++i;
          }
        }
        if (str[cdlen - 2] != '.' || str[cdlen - 1] != '.')
          path[k++] = str[cdlen - 1];
        if (path[k - 1] != '/') path[k++] = '/';
        path[k] = '\0';
      }
    }
  }
  return 0;
}
