#include <bits/stdc++.h>
using namespace std;
vector<string> str;
const string di = "..";
char ss[500];
int main() {
  int ti;
  scanf("%d", &ti);
  for (int i = 0; i < ti; i++) {
    scanf("%s", ss);
    if (ss[0] == 'p') {
      printf("/");
      for (int i = 0; i < str.size(); i++) printf("%s/", str[i].c_str());
      printf("\n");
    } else {
      scanf("%s", ss);
      if (ss[0] == '/') str.clear();
      char *tmp = strtok(ss, "/");
      while (tmp != NULL) {
        if (di == tmp)
          str.pop_back();
        else
          str.push_back(tmp);
        tmp = strtok(NULL, "/");
      }
    }
  }
}
