#include <bits/stdc++.h>
using namespace std;
char S[250], A[50 * 200][250];
int pA;
int main() {
  int N, i;
  cin >> N;
  while (N--) {
    cin >> S;
    if (S[0] == 'p') {
      cout << '/';
      for (int i = 0; i != pA; i++) cout << A[i] << '/';
      cout << endl;
    } else {
      cin >> S;
      int i = 0, len = strlen(S);
      if (S[len - 1] != '/')
        S[len] = '/', S[len + 1] = '\0';
      else
        len--;
      if (S[0] == '/') pA = 0, i++;
      while (i != len + 1) {
        char S1[250];
        int pS1 = 0;
        while (S[i] != '/') S1[pS1++] = S[i], i++;
        i++;
        S1[pS1] = '\0';
        if (S1[0] == '.')
          pA--;
        else
          A[pA][0] = '\0', strcat(A[pA++], S1);
      }
    }
  }
  return 0;
}
