#include <bits/stdc++.h>
using namespace std;
long long labs(long long a) { return a < 0 ? (-a) : a; }
long long max(long long a, long long b) { return a > b ? a : b; }
long long min(long long a, long long b) { return a < b ? a : b; }
void Split(const string& s, char separator, vector<string>& res) {
  int last = 0;
  for (int(i) = 0; (i) < (s.size()); (i)++) {
    if (s[i] == separator) {
      res.push_back(s.substr(last, i - last));
      if (res.back().empty()) res.pop_back();
      last = i + 1;
    }
  }
  if (last < s.size()) res.push_back(s.substr(last, s.size() - last));
}
vector<string> query;
vector<string> cpath;
void OutCpath() {
  for (int(i) = 0; (i) < (cpath.size()); (i)++) {
    cout << "/" << cpath[i];
  }
  cout << "/" << endl;
}
int main() {
  int n;
  cin >> n;
  string cmd, path;
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> cmd;
    if (cmd == "cd") {
      cin >> path;
      query.clear();
      Split(path, '/', query);
      if (path[0] == '/') {
        cpath.clear();
      }
      for (int(i) = 0; (i) < (query.size()); (i)++) {
        if (query[i] == "..") {
          cpath.pop_back();
        } else {
          cpath.push_back(query[i]);
        }
      }
    } else {
      OutCpath();
    }
  }
  return 0;
}
