#include <bits/stdc++.h>
char dir[10000][300];
int main() {
  int n, k = 0, len, i, j, x;
  char com[300];
  scanf("%d", &n);
  getchar();
  while (n--) {
    gets(com);
    if (strcmp(com, "pwd") == 0) {
      printf("/");
      for (i = 0; i <= k; i++) {
        if (strcmp(dir[i], "") == 0) continue;
        printf("%s/", dir[i]);
      }
      printf("\n");
    } else {
      j = 0;
      len = strlen(com);
      if (com[3] == '/') {
        k = 0;
        for (i = 4; i < len; i++) {
          if (com[i] == '/') {
            dir[k][j] = '\0';
            k++;
            j = 0;
            continue;
          }
          dir[k][j++] = com[i];
        }
        dir[k][j] = '\0';
      } else {
        if (strcmp(dir[k], "") != 0) k++;
        for (i = 3; i < len; i++) {
          if (com[i] == '/') {
            dir[k][j] = '\0';
            k++;
            j = 0;
            continue;
          }
          dir[k][j++] = com[i];
        }
        dir[k][j] = '\0';
      }
      for (i = 0; i <= k; i++) {
        if (dir[i][0] == '.') {
          strcpy(dir[i], "\0");
          for (x = i - 1; x >= 0; x--) {
            if (strcmp(dir[x], "") != 0) {
              strcpy(dir[x], "\0");
              break;
            }
          }
        }
      }
    }
  }
  return 0;
}
