#include <bits/stdc++.h>
using namespace std;
vector<string> listbegin(string s) {
  vector<string> ve;
  string tmp = "";
  for (long long int i = 0; i <= s.size() - 1; i += 1) {
    if (s[i] == '/') {
      if (tmp != "") {
        ve.push_back(tmp);
      }
      tmp = "";
    } else {
      tmp += s[i];
    }
  }
  if (tmp != "") {
    ve.push_back(tmp);
  }
  return ve;
}
string _begin = "/";
string change(string _begin, string s) {
  stack<char> opera;
  stack<char> charrater;
  vector<string> ve = listbegin(_begin);
  string tmp = "";
  s += '/';
  for (long long int i = 3; i <= s.size() - 1; i += 1) {
    if (s[i] == '.') {
      opera.push(s[i]);
      if (opera.size() == 2) {
        while (!opera.empty()) {
          opera.pop();
        }
        if (ve.size() > 0) {
          ve.pop_back();
        }
      }
    } else {
      if (s[i] == '/' && !charrater.empty()) {
        tmp = "";
        while (!charrater.empty()) {
          char c = charrater.top();
          tmp += c;
          charrater.pop();
        }
        reverse(tmp.begin(), tmp.end());
        ve.push_back(tmp);
      } else {
        if (s[i] != '/') {
          charrater.push(s[i]);
        } else if (i == 3 && s[i] == '/') {
          ve.clear();
        }
      }
    }
  }
  tmp = "/";
  if (ve.size() > 0) {
    for (long long int i = 0; i <= ve.size() - 1; i += 1) {
      tmp += ve[i];
      tmp += "/";
    }
  }
  return tmp;
}
int main() {
  long long int t;
  cin >> t;
  cin.ignore(2, '\n');
  string s;
  for (long long int i = 1; i <= t; i += 1) {
    getline(cin, s);
    if (s == "pwd") {
      cout << _begin << endl;
    } else {
      _begin = change(_begin, s);
    }
  }
  return 0;
}
