#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  string order;
  string cur = "/";
  while (T--) {
    cin >> order;
    if (order == "pwd") cout << cur << endl;
    if (order == "cd") {
      string CD;
      getline(cin, CD);
      string temp = "";
      vector<string> V;
      for (int i = 0; i < CD.size(); i++) {
        if (i == 0) continue;
        if (CD[i] == '/') {
          V.push_back(temp);
          temp.clear();
        } else
          temp += CD[i];
      }
      if (!temp.empty()) V.push_back(temp);
      for (int i = 0; i < V.size(); i++) {
        if (i == 0 && V[i].empty()) {
          cur = "/";
          continue;
        }
        if (V[i] == "..") {
          for (int j = cur.size() - 2; j >= 0; j--)
            if (cur[j] == '/') {
              cur.erase(j + 1);
              break;
            }
        } else {
          cur += V[i];
          cur += "/";
        }
      }
    }
  }
  return 0;
}
