#include <bits/stdc++.h>
using namespace std;
int n, len;
char can[2001], ans[1000001];
int main() {
  scanf("%d", &n);
  len = 0;
  ans[0] = '/';
  for (int i = 1; i <= n; i++) {
    memset(can, 0, sizeof(can));
    scanf("%s", can);
    if (can[0] == 'p') {
      for (int i = 0; i <= len; i++) printf("%c", ans[i]);
      if (len) printf("/");
      printf("\n");
    } else {
      memset(can, 0, sizeof(can));
      scanf("%s", can);
      if (can[0] == '/') len = 0;
      for (int i = 0; i < strlen(can);)
        if (can[i] == '.' && can[i + 1] == '.') {
          for (int j = len; j; --j)
            if (ans[j] != '/')
              --len;
            else
              break;
          if (len) --len;
          i += 3;
        } else {
          if (len) ans[++len] = '/';
          for (int j = i; j < strlen(can); j++) {
            i = j;
            if (can[j] == '/') break;
            ans[++len] = can[j];
          }
          ++i;
        }
    }
  }
}
