#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(const T a) {
  return a > 0 ? a : -a;
}
const double PI = 2.0 * acos(1.0);
int n;
int m;
struct tree {
  map<string, tree *> ch;
  string last;
};
tree mas[100000];
int cthulhu = 0;
tree *get() { return &mas[cthulhu++]; }
tree *t;
int main() {
  t = get();
  t->ch.clear();
  t->last = "";
  tree *cur = t;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    string cmd;
    cin >> cmd;
    if (cmd == "pwd") {
      vector<string> ans;
      tree *tmp = cur;
      while (tmp != t) {
        ans.push_back(tmp->last);
        tmp = tmp->ch[".."];
      }
      reverse((ans).begin(), (ans).end());
      for (int j = 0; j < (((int)(ans).size())); j++) cout << "/" << ans[j];
      cout << "/" << endl;
    } else {
      string s;
      cin >> s;
      int start = 0;
      if (s[0] == '/') {
        cur = t;
        start = 1;
      }
      string fold = "";
      s += "/";
      for (int j = start; j < ((int)(s).size()); j++) {
        if (s[j] == '/') {
          if (fold == "") continue;
          if (cur->ch.find(fold) == cur->ch.end()) {
            cur->ch[fold] = get();
            cur->ch[fold]->ch[".."] = cur;
            cur->ch[fold]->last = fold;
          }
          cur = cur->ch[fold];
          fold = "";
        } else
          fold += s[j];
      }
    }
  }
  return 0;
}
