#include <bits/stdc++.h>
using std::string;
using std::vector;
int main(int argc, const char *argv[]) {
  int n = 0;
  std::cin >> n;
  vector<string> v;
  for (int i = 0; i < n; ++i) {
    string cmd;
    std::cin >> cmd;
    if (!cmd.compare("pwd")) {
      std::cout << "/";
      for (vector<string>::const_iterator iter = v.begin(); iter != v.end();
           ++iter) {
        std::cout << *iter << "/";
      }
      std::cout << std::endl;
    } else {
      string path;
      std::cin >> path;
      int start = 0;
      int len = path.length();
      if (path[0] == '/') {
        v.clear();
        start = 1;
      }
      string curWord;
      for (int j = start; j < len; ++j) {
        if (path[j] != '/') {
          curWord.push_back(path[j]);
        } else {
          if (!curWord.compare("..")) {
            v.pop_back();
          } else {
            v.push_back(curWord);
          }
          curWord.clear();
        }
      }
      if (!curWord.empty()) {
        if (!curWord.compare("..")) {
          v.pop_back();
        } else {
          v.push_back(curWord);
        }
        curWord.clear();
      }
    }
  }
  return 0;
}
