#include <bits/stdc++.h>
char com[4], str[5010][201], temp[201];
int main() {
  int n, i = 0, j;
  char ch, *p;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", com);
    if (com[0] == 'p') {
      putchar('/');
      if (i) {
        for (j = 0; j < i; j++) {
          printf("%s", str[j]);
          putchar('/');
        }
      }
      puts("");
    } else {
      getchar();
      ch = getchar();
      if (ch == '/')
        i = 0;
      else if (ch == '.') {
        getchar();
        i--;
      } else
        ungetc(ch, stdin);
      gets(temp);
      if (p = strtok(temp, "/")) {
        strcpy(str[i], p);
        if (str[i][0] == '.')
          i--;
        else
          i++;
      }
      while (p = strtok(NULL, "/")) {
        strcpy(str[i], p);
        if (str[i][0] == '.')
          i--;
        else
          i++;
      }
    }
  }
  return 0;
}
