#include <bits/stdc++.h>
int a[20001];
int n;
using namespace std;
vector<string> v;
vector<string> temp;
string s;
int main() {
  cin >> n;
  cin.get();
  v.push_back("");
  for (int i = 0; i < n; i++) {
    getline(cin, s);
    s += '/';
    if (s[0] == 'p') {
      for (int j = 0; j < v.size(); j++) cout << v[j] << "/";
      cout << endl;
    } else {
      temp.clear();
      int p = 3;
      for (int j = 3; j < s.size(); j++) {
        if (s[j] == '/') {
          temp.push_back(s.substr(p, j - p));
          p = j + 1;
        }
      }
      for (int j = 0; j < temp.size(); j++) {
        if (temp[j] == "") {
          v.clear();
          v.push_back("");
        } else if (temp[j] == "..")
          v.pop_back();
        else
          v.push_back(temp[j]);
      }
    }
  }
  return 0;
}
