#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
struct node {
  map<string, int> e;
  string name;
  int pa;
};
vector<node> ns;
int new_node(string name, int pa) {
  node c;
  c.name = name;
  c.pa = pa;
  c.e[".."] = pa;
  ns.push_back(c);
  return int((ns).size()) - 1;
}
int cd(int cid, string path) {
  string dir = "";
  node cur = ns[cid];
  int i = 0;
  while (i < int((path).size())) {
    if (path[i] == '/') break;
    dir.push_back(path[i]);
    i++;
  }
  if (!cur.e.count(dir)) {
    cur.e[dir] = new_node(dir, cid);
  }
  if (i < int((path).size()) && path[i] == '/') i++;
  if (i < int((path).size())) {
    return cd(cur.e[dir], path.substr(i));
  } else
    return cur.e[dir];
}
string get_path(int cid) {
  string res = "";
  while (cid != -1) {
    res = ns[cid].name + '/' + res;
    cid = ns[cid].pa;
  }
  if (res.back() != '/') res += '/';
  return res;
}
int main() {
  int n, tot = 0;
  cin >> n;
  int cid = new_node("", -1);
  while (n--) {
    string s;
    cin >> s;
    if (s == "pwd") {
      string path = get_path(cid);
      cout << path << endl;
    } else {
      string path;
      cin >> path;
      if (int((path).size()) > 1 && path.back() == '/') path.pop_back();
      if (path[0] == '/') {
        if (int((path).size()) == 1)
          cid = 0;
        else
          cid = cd(0, path.substr(1));
      } else {
        cid = cd(cid, path);
      }
    }
  }
  return 0;
}
