#include <bits/stdc++.h>
using namespace std;
int n;
string PATH;
string stringMerge(int a, int b, string A) {
  string wyn = "";
  for (int i = a; i < b; i++) wyn += A[i];
  return wyn;
}
void pathDelete() {
  if (PATH.size() == 1) return;
  int it = PATH.size() - 2;
  while (PATH[it--] != '/')
    ;
  PATH = stringMerge(0, it + 1, PATH);
  PATH += "/";
}
void solve() {
  string task;
  cin >> task;
  if (task[0] == '/') PATH = "/";
  int l;
  task[0] == '/' ? l = 1 : l = 0;
  for (int i = l; i < task.size(); i++) {
    if (task[i] == '/') {
      string dir = stringMerge(l, i, task);
      if (dir == "..")
        pathDelete();
      else
        PATH += dir + '/';
      l = i + 1;
    }
  }
  string dir = stringMerge(l, task.size(), task);
  if (dir == "..")
    pathDelete();
  else
    PATH += dir + '/';
}
void read() {
  PATH = "/";
  cin >> n;
  while (n--) {
    string task;
    cin >> task;
    if (task == "pwd")
      cout << PATH << endl;
    else
      solve();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  read();
}
