#include <bits/stdc++.h>
using namespace std;
vector<string> v;
int top = 0;
int main() {
  ios_base::sync_with_stdio(false);
  int N, first = 0;
  cin >> N;
  string s;
  v.push_back("/");
  for (int x = 0; x < N; x++) {
    cin >> s;
    if (s == "cd") {
      string s1, temp;
      cin >> s1;
      for (int x = 0; x < s1.length(); x++) {
        if (s1[x] == '/' && x == 0) {
          v.clear();
          v.push_back("/");
          top = 0;
        }
        if (s1[x] == '/' && x != 0) {
          if (temp != "") {
            v.push_back(temp);
            top++;
            temp = "";
          } else
            temp = "";
        }
        if (s1[x] == '.' || s1[x] != '/') temp += s1[x];
        if (temp == "..") {
          v.pop_back();
          top--;
          temp = "";
        }
      }
      if (temp != "") {
        v.push_back(temp);
        top++;
      }
    }
    if (s == "pwd") {
      for (int x = 0; x <= top; x++) {
        if (v[x] == "/")
          cout << v[x];
        else
          cout << v[x] << "/";
      }
      cout << "\n";
    }
  }
  return 0;
}
