#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}
template <typename T>
inline void write(T x) {
  int i = 20;
  char buf[21];
  buf[20] = '\n';
  do {
    buf[--i] = x % 10 + '0';
    x /= 10;
  } while (x);
  do {
    putchar(buf[i]);
  } while (buf[i++] != '\n');
}
template <typename T>
inline T readInt() {
  T n = 0, s = 1;
  char p = getchar();
  if (p == '-') s = -1;
  while ((p < '0' || p > '9') && p != EOF && p != '-') p = getchar();
  if (p == '-') s = -1, p = getchar();
  while (p >= '0' && p <= '9') {
    n = (n << 3) + (n << 1) + (p - '0');
    p = getchar();
  }
  return n * s;
}
int main() {
  string cmd;
  int n;
  cin >> n;
  vector<string> dir;
  dir.push_back("/");
  while (n--) {
    cin >> cmd;
    if (cmd == "cd") {
      string spec;
      cin >> spec;
      string curr = "";
      int cnt;
      if (spec[0] == '/') {
        cnt = 1;
        while (dir.size() > 1) {
          dir.pop_back();
        }
        while (cnt < spec.size()) {
          if (spec[cnt] == '/') {
            if (curr == "..") {
              dir.pop_back();
            } else {
              dir.push_back(curr);
            }
            curr = "";
          } else {
            curr += spec[cnt];
          }
          cnt++;
        }
      } else {
        cnt = 0;
        while (cnt < spec.size()) {
          if (spec[cnt] == '/') {
            if (curr == "..") {
              dir.pop_back();
            } else {
              dir.push_back(curr);
            }
            curr = "";
          } else {
            curr += spec[cnt];
          }
          cnt++;
        }
      }
      if (curr == "..") {
        dir.pop_back();
      } else {
        dir.push_back(curr);
      }
    } else if (cmd == "pwd") {
      for (int i = 0; i < dir.size(); i += 1) {
        cout << dir[i];
        if (i) cout << '/';
      }
      cout << endl;
    }
  }
  return 0;
}
