#include <bits/stdc++.h>
using namespace std;
vector<string> a;
int main() {
  int n;
  cin >> n;
  string com, temp, temp1;
  for (int i = 0; i < n; i++) {
    cin >> com;
    if (com == "pwd") {
      for (int i = 0; i < a.size(); ++i) cout << "/" << a[i];
      cout << "/" << endl;
    } else {
      cin >> temp;
      if (temp[0] == '/') a.clear();
      for (int i = 0; i < temp.size(); ++i) {
        if (temp[i] != '/') {
          if (temp[i] != ' ') temp1 += temp[i];
        } else {
          if (temp1.size()) {
            if (temp1 == "..")
              a.pop_back();
            else
              a.push_back(temp1);
            temp1 = "";
          }
        }
      }
      if (temp1.size()) {
        if (temp1 == "..")
          a.pop_back();
        else
          a.push_back(temp1);
        temp1 = "";
      }
    }
  }
  return 0;
}
