#include <bits/stdc++.h>
using namespace std;
int n;
char str[205];
int c;
vector<string> name;
int par[5005];
map<pair<int, string>, int> mp;
void prt(int a) {
  if (a == 0) {
    printf("/");
    return;
  }
  prt(par[a]);
  printf("%s/", name[a].c_str());
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  c = 0;
  name.push_back("");
  for (i = 0; i < n; i++) {
    scanf("%s", &str);
    if (strcmp(str, "pwd") == 0) {
      prt(c);
      printf("\n");
    } else {
      scanf("%s", &str);
      int m = strlen(str);
      str[m] = '/';
      str[m + 1] = '\0';
      char *p = str;
      int k = 0;
      if (str[0] == '/') {
        c = 0;
        p = strtok(&str[1], "/");
      } else {
        p = strtok(str, "/");
      }
      while (p != NULL) {
        string str2 = string(p);
        pair<int, string> pir = make_pair(c, str2);
        if (mp.find(pir) != mp.end()) {
          c = mp[pir];
        } else {
          mp[pir] = name.size();
          par[name.size()] = c;
          c = name.size();
          name.push_back(str2);
          mp[make_pair(c, "..")] = par[c];
        }
        p = strtok(NULL, "/");
      }
    }
  }
  return 0;
}
