#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string ord, pth;
  stack<string> q;
  for (int i = 0; i < n; i++) {
    cin >> ord;
    if (ord == "pwd") {
      string res = "";
      stack<string> tq = q;
      while (!tq.empty()) {
        res = tq.top() + "/" + res;
        tq.pop();
      }
      printf("/%s\n", res.c_str());
    } else {
      cin >> pth;
      if (pth[0] == '/')
        while (!q.empty()) q.pop();
      char* arr = new char[pth.size() + 1];
      strcpy(arr, pth.c_str());
      char* var = strtok(arr, "/");
      do {
        if (var == NULL) break;
        string v = var;
        if (v.size() == 0) break;
        if (v == "..")
          q.pop();
        else
          q.push(v);
        var = strtok(NULL, "/");
      } while (var != NULL);
    }
  }
  return 0;
}
