#include <bits/stdc++.h>
using namespace std;
struct Node {
  Node *parent;
  string name;
  map<string, Node *> ch;
} *root = new Node, *now = root;
int n;
int len = 0;
string s[22222];
void dfs(Node *x) {
  if (x == root) {
    cout << "/";
  } else {
    dfs(x->parent);
    cout << x->name << "/";
  }
}
void split(string pa) {
  pa += "/";
  string tmp;
  len = 0;
  for (int i = 0; i < pa.size(); i++)
    if (pa[i] == '/') {
      if (tmp != "") s[++len] = tmp;
      tmp = "";
    } else
      tmp += pa[i];
}
int main(void) {
  cin >> n;
  root->parent = root;
  for (int i = 1; i <= n; i++) {
    string cmd, pa;
    cin >> cmd;
    if (cmd == "pwd") {
      dfs(now);
      cout << "\n";
    } else {
      cin >> pa;
      split(pa);
      if (pa[0] == '/') now = root;
      for (int i = 1; i <= len; i++) {
        if (s[i] == "..")
          now = now->parent;
        else if (s[i] == ".")
          now = now;
        else {
          if ((now->ch).find(s[i]) != (now->ch).end()) {
            now = now->ch[s[i]];
          } else {
            Node *x = new Node;
            x->name = s[i];
            x->parent = now;
            (now->ch).insert(pair<string, Node *>(s[i], x));
            now = x;
          }
        }
      }
    }
  }
  return 0;
}
