#include <bits/stdc++.h>
using namespace std;
void freekick() {}
const int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};
const int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};
const long long INFL = (long long)1e18 + 123;
void freegoal() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
signed main() {
  freekick();
  freegoal();
  int n;
  string second, s1 = "", s2 = "";
  cin >> n;
  vector<string> v;
  for (int i = 1; i <= n; i++) {
    cin >> second;
    if (second == "cd") {
      cin >> s1;
      if (s1[0] == '/') {
        v.clear();
      }
      for (int j = 0; j < s1.size(); j++) {
        if (s1[j] == '/') {
          if (s2 != "") {
            if (s2 == "..")
              v.pop_back();
            else
              v.push_back(s2 + '/');
            s2 = "";
          }
        } else
          s2 += s1[j];
      }
      if (s2 != "") {
        if (s2 == "..")
          v.pop_back();
        else
          v.push_back(s2 + '/');
        s2 = "";
      }
    } else {
      cout << '/';
      for (int j = 0; j < v.size(); j++) {
        cout << v[j];
      }
      cout << endl;
    }
  }
  return false;
}
