#include <bits/stdc++.h>
using namespace std;
class Node {
  string value;
  int parent = 0;
  vector<int> children;

 public:
  Node(string value) { this->value = value; }
  Node(string value, int parent) : Node(value) { this->parent = parent; }
  int getChild(string value, int parent, vector<Node>& nodes) {
    if (value == "..") {
      return nodes[parent].parent;
    }
    for (int i = 0; i < children.size(); i++) {
      if (value == nodes[i].value) {
        return i;
      }
    }
    nodes.push_back(setChild(value, parent));
    nodes[parent].children.push_back((int)nodes.size() - 1);
    return (int)nodes.size() - 1;
  }
  Node setChild(string value, int parent) { return Node(value, parent); }
  friend ostream& operator<<(ostream& os, const Node& node);
  friend bool operator==(const Node& lhs, const Node& rhs);
  friend bool operator!=(const Node& lhs, const Node& rhs);
  friend void traverseToRoot(int index, vector<Node> nodes);
} root = Node("/");
ostream& operator<<(ostream& os, const Node& node) {
  if (node.value != "/") {
    os << node.value << "/";
  } else {
    os << node.value;
  }
  return os;
}
bool operator==(const Node& lhs, const Node& rhs) {
  return lhs.value == rhs.value;
}
bool operator!=(const Node& lhs, const Node& rhs) {
  return !operator==(lhs, rhs);
}
bool isPwd(string& str) { return (str[0] == 'p'); }
bool isAbs(string& str) { return (str[0] == '/'); }
vector<string> getNames(string& path, bool abs) {
  vector<string> names;
  string name = "";
  for (int i = int(abs); i < path.length(); i++) {
    int ascii = int(path[i]);
    if (ascii == 46 || (96 < ascii && ascii < 123)) {
      name += path[i];
    } else {
      names.push_back(name);
      name = "";
    }
  }
  names.push_back(name);
  return names;
}
void getNodes(vector<string>& names, vector<Node>& nodes, int& current) {
  for (int i = 0; i < names.size(); i++) {
    current = nodes[current].getChild(names[i], current, nodes);
  }
}
void traverseToRoot(int index, vector<Node> nodes) {
  if (index != 0) {
    traverseToRoot(nodes[index].parent, nodes);
  }
  cout << nodes[index];
}
int main() {
  int n;
  while (cin >> n) {
    vector<Node> nodes;
    nodes.push_back(root);
    int current = 0;
    for (int i = 0; i < n; i++) {
      string command;
      cin >> command;
      if (isPwd(command)) {
        traverseToRoot(current, nodes);
        cout << endl;
      } else {
        string path;
        cin >> path;
        bool abs = isAbs(path);
        if (abs) {
          current = 0;
        }
        vector<string> names = getNames(path, abs);
        getNodes(names, nodes, current);
      }
    }
  }
  return 0;
}
