#include <bits/stdc++.h>
using namespace std;
vector<string> path;
void printPath() {
  cout << "/";
  for (int i = 0; i < path.size(); i++) {
    cout << path[i] << "/";
  }
  cout << "\n";
}
void update(string query) {
  int pos = 0;
  if (query[0] == '/') {
    path.clear();
    pos = 1;
  }
  while (1) {
    int nextPos = query.find('/', pos);
    if (nextPos != string::npos) {
      string w = query.substr(pos, nextPos - pos);
      if (w.compare("..") == 0) {
        path.pop_back();
      } else {
        path.push_back(w);
      }
    } else {
      string w = query.substr(pos);
      if (w.compare("..") == 0) {
        path.pop_back();
      } else {
        path.push_back(w);
      }
      break;
    }
    pos = nextPos + 1;
  }
}
int main() {
  int n;
  cin >> n;
  path.clear();
  while (n--) {
    string q;
    cin >> q;
    if (q.compare("pwd") == 0) {
      printPath();
    } else {
      string query;
      cin >> query;
      update(query);
    }
  }
  return 0;
}
