#include <bits/stdc++.h>
inline void solve(std::istream &in, std::ostream &out) {
  std::deque<std::string> currentPath = {"/"};
  std::size_t numberOfCommands;
  std::string command;
  std::string commandPath;
  std::ostream_iterator<std::string> itOut(out);
  std::stringstream tokenizer;
  in >> numberOfCommands;
  for (std::size_t i = 0; i < numberOfCommands; ++i) {
    in >> command;
    if (command == "pwd") {
      std::copy(std::begin(currentPath), std::end(currentPath), itOut);
      *itOut++ = "\n";
    } else {
      std::string tmp;
      in.ignore(1);
      std::getline(in, commandPath);
      tokenizer.clear();
      tokenizer << commandPath;
      if (commandPath[0] == '/') {
        currentPath = {"/"};
        tokenizer.ignore(1);
      }
      while (!tokenizer.eof()) {
        std::getline(tokenizer, tmp, '/');
        if (tmp == "..") {
          currentPath.pop_back();
        } else {
          currentPath.push_back(tmp + '/');
        }
      }
    }
  }
}
int main(int argc, char *argv[]) {
  static char buffer[1024 * 4];
  std::cout.rdbuf()->pubsetbuf(buffer, sizeof(buffer));
  std::cout.sync_with_stdio(false);
  std::cin.tie(nullptr);
  auto &in = std::cin;
  auto &out = std::cout;
  solve(in, out);
  return 0;
}
