#include <bits/stdc++.h>
using namespace std;
void pwd(vector<string> v) {
  int i = 0;
  char ch = 0;
  cout << '/';
  ch = '/';
  for (i = 0; i < (int)v.size(); i++) {
    cout << v[i];
    ch = v[i][v[i].size() - 1];
  }
  cout << endl;
}
int main() {
  int i = 0, n = 0;
  string s;
  vector<string> v;
  cin >> n;
  getchar();
  while (n--) {
    getline(cin, s);
    if (s[0] == 'p') {
      pwd(v);
    } else {
      string str, t;
      int f = 0;
      for (i = 3; i < (int)s.size(); i++) {
        str += s[i];
        if (str == "../") {
          if (!v.empty()) v.pop_back();
          str = "";
        } else if (str == "/" && i == 3) {
          v.clear();
          str = "";
        } else if (s[i] == '/') {
          v.push_back(str);
          str = "";
        }
      }
      if (str == "..") {
        if (!v.empty()) v.pop_back();
      } else if (str != "") {
        char ch = str[str.size() - 1];
        if (ch != '/')
          ;
        str += "/";
        v.push_back(str);
      }
    }
  }
}
