#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5 + 1;
void setIO(string name) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  freopen((name + ".in").c_str(), "r", stdin);
  freopen((name + ".out").c_str(), "w", stdout);
}
int main() {
  int n;
  cin >> n;
  vector<string> second;
  second.push_back("");
  std::string delimiter = "/";
  for (int i = 0; i < n; i++) {
    string command;
    cin >> command;
    if (command == "pwd") {
      for (int i = 0; i < second.size(); i++) {
        cout << second[i] << "/";
      }
      cout << "\n";
    } else if (command == "cd") {
      string location;
      cin >> location;
      size_t pos = 0;
      string token;
      while ((pos = location.find(delimiter)) != string::npos) {
        token = location.substr(0, pos);
        if (token == "..") {
          second.erase(second.begin() + second.size() - 1);
        } else if (token == "") {
          second.clear();
          second.push_back("");
        } else {
          second.push_back(token);
        }
        location.erase(0, pos + delimiter.length());
      }
      if (location == "..") {
        second.erase(second.begin() + second.size() - 1);
      } else if (location == "") {
        second.clear();
        second.push_back("");
      } else {
        second.push_back(location);
      }
    }
  }
  return 0;
}
