#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, OO = 0x3f3f3f3f;
int n;
vector<string> v;
string s;
void dO(string c) {
  string z = "";
  if (s[3] == '/') v.clear();
  for (int i = 2; i < c.size(); i++) {
    if (c[i] >= 'a' && c[i] <= 'z') {
      z += c[i];
    } else if (c[i] == '/' && z != "") {
      v.push_back(z);
      z = "";
    } else if (c[i] == '.') {
      i += 1;
      v.pop_back();
    }
  }
  if (z[0] == '.')
    v.pop_back();
  else if (z != "")
    v.push_back(z);
}
int main() {
  cin >> n;
  cin.ignore();
  while (n--) {
    getline(cin, s);
    if (s[0] == 'p') {
      cout << "/";
      for (int i = 0; i < v.size(); i++) cout << v[i] << "/";
      cout << endl;
    } else
      dO(s);
  }
  return 0;
}
