#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s, curr[1000];
  long long int size = 0, j;
  cin >> j;
  while (j--) {
    cin >> s;
    if (s.compare("pwd") == 0) {
      for (long long int i = 0; i < size; ++i) {
        cout << "/" << curr[i];
      }
      cout << "/"
           << "\n";
    } else if (s.compare("cd") == 0) {
      string temp;
      cin >> s;
      if (s[0] == '/') {
        size = 0;
      }
      for (long long int i = 0; i < s.size(); ++i) {
        temp = "";
        for (; i < s.size(); ++i) {
          if (s[i] == '/') break;
          temp += s[i];
        }
        if (temp.compare("..") == 0)
          --size;
        else if (temp.size()) {
          curr[size] = temp;
          ++size;
        }
      }
    }
  }
  return 0;
}
