#include <bits/stdc++.h>
using namespace std;
char com[10];
char now[50000];
char cd[250];
int main() {
  int n;
  memset(now, 0, sizeof(now));
  now[0] = '/';
  int cnt = 1;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", com);
    if (com[0] == 'p') {
      puts(now);
    }
    if (com[0] == 'c') {
      scanf("%s", cd);
      int len = strlen(cd);
      if (cd[0] == '/') {
        cnt = 1;
        for (int i = 1; i < len;) {
          if (cd[i] != '.')
            now[cnt++] = cd[i], ++i;
          else {
            i += 2;
            cnt -= 2;
            for (; now[cnt] != '/' && cnt > 0; cnt--)
              ;
          }
        }
        now[cnt++] = '/';
        now[cnt] = 0;
      } else {
        for (int i = 0; i < len;) {
          if (cd[i] != '.')
            now[cnt++] = cd[i], ++i;
          else {
            i += 2;
            cnt -= 2;
            for (; now[cnt] != '/' && cnt > 0; cnt--)
              ;
          }
        }
        now[cnt++] = '/';
        now[cnt] = 0;
      }
    }
  }
  return 0;
}
