#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> a(50);
  int n;
  cin >> n;
  int i = -1;
  while (n > 0) {
    n--;
    string s;
    cin >> s;
    if (s[0] == 'p') {
      cout << "/";
      int j = 0;
      while (j <= i) {
        cout << a[j];
        cout << "/";
        j++;
      }
      cout << endl;
    } else {
      cin >> s;
      int j = 0;
      if (s[j] == '/') {
        i = 0;
        j++;
        a[i] = "";
      } else
        i++;
      while (j < s.size()) {
        if (i < 0) {
          a[0] = "";
          i = -1;
        }
        if (s[j] == '.' && j < s.size() - 1 && s[j + 1] == '.' && a[i] == "" &&
            (j == s.size() - 2 || s[j + 2] == '/')) {
          j += 2;
          i -= 2;
          a[i + 1] = "";
          a[i + 2] = "";
        } else {
          if (s[j] == '/') {
            i++;
            int k = i;
            while (k >= a.size() - 2) {
              a.push_back("");
              k--;
            }
            a[i] = "";
          } else {
            a[i] += s[j];
            int k = i;
            while (k >= a.size() - 3) {
              a.push_back("");
              k--;
            }
            a[i + 1] = "";
            a[i + 2] = "";
          }
          j++;
        }
      }
    }
  }
  return 0;
}
