#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a[2222];
  int r = 0;
  while (n--) {
    string t;
    cin >> t;
    if (t == "pwd") {
      cout << "/";
      for (int i = 1; i <= r; ++i) cout << a[i] << "/";
      cout << endl;
    } else {
      string s;
      cin >> s;
      int i, j;
      if (s[0] == '/') {
        r = 0;
        i = j = 1;
      } else {
        i = j = 0;
      }
      for (; i < s.size(); ++i) {
        if (s[i] == '/') {
          a[++r] = string(s, j, i - j);
          j = i + 1;
        }
        if (s[i] == '.') {
          while (i < s.size() && s[i] == '.') i++;
          i++;
          j = i;
          r--;
        }
      }
      if (s[s.size() - 1] != '.') a[++r] = string(s, j, i - j);
    }
  }
  return 0;
}
