#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<string> v;
  v.clear();
  cin >> n;
  while (n--) {
    string s, a;
    cin >> s;
    if (s[0] == 'c') {
      cin >> a;
      string z = "";
      if (a[0] == '/') {
        v.clear();
        for (int i = 1; i < a.size(); i++) {
          if (a[i] == '/') {
            if (z != "") {
              v.push_back(z);
              z = "";
            }
          } else if (a[i] == '.') {
            v.pop_back();
            ++i;
          } else
            z += a[i];
        }
        if (z != "") {
          v.push_back(z);
          z = "";
        }
      }
      if (a[0] != '/') {
        for (int i = 0; i < a.size(); i++) {
          if (a[i] == '/') {
            if (z != "") {
              v.push_back(z);
              z = "";
            }
          } else if (a[i] == '.') {
            v.pop_back();
            ++i;
          } else {
            z += a[i];
          }
        }
        if (z != "") {
          v.push_back(z);
          z = "";
        }
      }
    }
    if (s[0] == 'p') {
      cout << '/';
      for (vector<string>::iterator it = v.begin(); it != v.end(); it++) {
        cout << *it << '/';
      }
      cout << endl;
    }
  }
  return 0;
}
