#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[205];
  vector<string> u;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", s);
    if (*s == 'c') {
      scanf("%s", s);
      if (*s == '/') u.clear();
      for (auto i = strtok(s, "/"); i; i = strtok(0, "/"))
        if (strcmp(i, ".."))
          u.push_back(i);
        else
          u.pop_back();
    } else {
      for (auto& x : u) printf("/%s", x.c_str());
      puts("/");
    }
  }
}
