#include <bits/stdc++.h>
using namespace std;
struct node {
  string name;
  map<string, node*> children;
  node* parent;
  node(string nm = "", node* p = 0) : name(nm), parent(p) {}
  ~node() {
    for (map<string, node*>::iterator it = children.begin();
         it != children.end(); ++it)
      delete it->second;
  }
};
void print(node* cur) {
  if (cur == 0) return;
  print(cur->parent);
  cout << cur->name << "/";
}
vector<string> path(string s) {
  int pos = 0;
  if (s[0] == '/') ++pos;
  vector<string> res;
  string name;
  int pos2;
  do {
    pos2 = s.find('/', pos);
    name = s.substr(pos, pos2 - pos);
    pos = pos2 + 1;
    res.push_back(name);
  } while (pos2 != -1);
  return res;
}
int main() {
  int n;
  cin >> n;
  string s;
  node* cur = new node();
  node* root = cur;
  for (int i = 0; i < n; ++i) {
    cin >> s;
    if (s == "pwd") {
      print(cur);
      cout << endl;
    } else {
      cin >> s;
      if (s[0] == '/') cur = root;
      vector<string> p = path(s);
      for (int j = 0; j < p.size(); ++j) {
        if (p[j] == "..") {
          cur = cur->parent;
        } else if (cur->children.count(p[j]) == 0) {
          node* child = new node(p[j], cur);
          cur->children[p[j]] = child;
          cur = child;
        } else {
          cur = cur->children[p[j]];
        }
      }
    }
  }
  delete root;
  return 0;
}
