#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  string lab;
  int father;
  map<string, int> child;
  void clear() {
    lab = "";
    father = -1;
    child.clear();
  }
} a[30010];
int m;
void pr(int p) {
  string ret = "";
  while (p != -1) {
    ret = a[p].lab + "/" + ret;
    p = a[p].father;
  }
  cout << ret << endl;
}
int Next(int p, string x) {
  if (x == "..") {
    return a[p].father;
  } else {
    if (a[p].child.find(x) == a[p].child.end()) {
      a[n].clear();
      a[n].father = p;
      a[n].lab = x;
      a[p].child.insert(make_pair(x, n++));
      return n - 1;
    } else {
      return a[p].child[x];
    }
  }
}
void walk(char *path, int pn, int &pt) {
  string tmp;
  for (int i = 0; i < pn; i++) {
    tmp = "";
    while (i < pn && path[i] != 47) {
      tmp += path[i];
      ++i;
    }
    pt = Next(pt, tmp);
  }
}
int main() {
  n = 1;
  a[0].clear();
  scanf("%d", &m);
  int pt = 0;
  for (int t = 0; t < m; t++) {
    char type[10];
    scanf("%s", type);
    if (type[0] == 'p') {
      pr(pt);
    } else {
      char buf[500];
      scanf("%s", buf);
      if (buf[0] == '/') pt = 0;
      walk(buf + (buf[0] == '/'), strlen(buf) - (buf[0] == '/'), pt);
    }
  }
  return 0;
}
