#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  scanf("%d", &n);
  vector<string> dir;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'c') {
      cin >> s;
      if (s[0] == '/') dir.clear(), s.erase(s.begin());
      string ss;
      for (int j = 0; j < s.size(); j++)
        if (s[j] == '/') {
          if (ss[0] != '.')
            dir.push_back(ss);
          else
            dir.erase(dir.begin() + dir.size() - 1);
          ss.clear();
        } else
          ss += s[j];
      if (!ss.empty()) {
        if (ss[0] != '.')
          dir.push_back(ss);
        else
          dir.erase(dir.begin() + dir.size() - 1);
      }
    } else {
      cout << '/';
      for (int i = 0; i < dir.size(); i++) cout << dir[i] << '/';
      cout << endl;
    }
  }
  return 0;
}
