#include <bits/stdc++.h>
using namespace std;
vector<string> command;
void pwd() {
  cout << '/';
  vector<string>::iterator i;
  for (i = command.begin(); i != command.end(); i++) cout << *i << "/";
  cout << "\n";
}
void cd(string a) {
  if (a[0] == '/') command.clear();
  for (int i = 0; i < a.size(); i++) {
    string temp;
    cout << temp;
    while (a[i] != '/' && i < a.size()) {
      temp += a[i];
      i++;
    }
    if (temp == "..")
      command.pop_back();
    else if (temp != "")
      command.push_back(temp);
  }
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    string a;
    cin >> a;
    if (a == "pwd")
      pwd();
    else {
      string temp;
      cin >> temp;
      cd(temp);
    }
  }
}
