#include <bits/stdc++.h>
using namespace std;
map<string, string> mp;
map<string, int> stn;
void Print(string cur) {
  string res = "/";
  while (cur != "/") {
    string tmp = cur;
    while (int(tmp.size()) &&
           ('0' <= tmp[tmp.size() - 1] && tmp[tmp.size() - 1] <= '9'))
      tmp.erase(tmp.begin() + tmp.size() - 1);
    res = "/" + tmp + res;
    cur = mp[cur];
  }
  cout << res << endl;
}
int main() {
  int n;
  string s, cur = "/";
  cin >> n;
  for (int cn = 0; cn < int(n); cn++) {
    cin >> s;
    if (s == "pwd") {
      Print(cur);
    } else {
      cin >> s;
      int ssize = s.size();
      string acc = "";
      int st = 0;
      if (s[0] == '.') {
        cur = mp[cur];
        st = 3;
      }
      if (s[0] == '/') {
        cur = "/";
        st = 1;
      }
      acc = "";
      for (int i = st; i < ssize; i++) {
        if (s[i] == '/') {
          if (acc == "..") {
            cur = mp[cur];
          } else {
            stn[acc]++;
            stringstream ss;
            string nw;
            ss << stn[acc];
            ss >> nw;
            acc += nw;
            mp[acc] = cur;
            cur = acc;
          }
          acc = "";
        } else {
          acc += s[i];
        }
      }
      if (acc.size()) {
        if (acc == "..") {
          cur = mp[cur];
        } else {
          stn[acc]++;
          stringstream ss;
          string nw;
          ss << stn[acc];
          ss >> nw;
          acc += nw;
          mp[acc] = cur;
          cur = acc;
        }
      }
    }
  }
}
