#include <bits/stdc++.h>
using namespace std;
deque<string> dq;
const vector<string> split(string str, char ch) {
  vector<string> vec;
  string temp;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == ch) {
      vec.push_back(temp);
      temp.clear();
      continue;
    }
    if (i == str.size() - 1) {
      temp += str[str.size() - 1];
      vec.push_back(temp);
    }
    temp += str[i];
  }
  return vec;
}
void add(string str) {
  if (str == "..") {
    dq.pop_back();
    return;
  }
  vector<string> vec = split(str, '/');
  int i;
  if (str[0] == '/')
    i = 0;
  else
    i = 0;
  if (str[i] == '/') dq.clear();
  for (i; i < vec.size(); i++) {
    if (vec[i] == "") continue;
    if (vec[i] == "..") {
      dq.pop_back();
    } else {
      dq.push_back(vec[i]);
    }
  }
}
void print() {
  cout << "/";
  for (deque<string>::iterator it = dq.begin(); it != dq.end(); it++) {
    cout << *it << "/";
  }
  cout << endl;
}
int main() {
  int n;
  cin >> n;
  string query;
  string dir;
  for (int i = 0; i < n; i++) {
    cin >> query;
    if (query == "pwd") {
      print();
    } else {
      cin >> dir;
      add(dir);
    }
  }
  return 0;
}
