#include <bits/stdc++.h>
using namespace std;
string ss = "/", s, sx;
char cd[3];
int main() {
  int n, l, a;
  scanf("%d", &n);
  while (n--) {
    scanf("%s", cd);
    if (cd[0] == 'p') {
      cout << ss << endl;
      continue;
    }
    cin >> s;
    if (s[0] == '/') ss = "";
    s += "/";
    l = s.length();
    a = 0;
    for (int i = 1; i < l; ++i)
      if (s[i] == '/') {
        sx = s.substr(a, ++i - a);
        a = i;
        if (sx[0] == '.') {
          for (int i = ss.length() - 2; ~i; --i)
            if (ss[i] == '/') {
              ss = ss.substr(0, i + 1);
              break;
            }
        } else
          ss += sx;
      }
  }
}
