#include <bits/stdc++.h>
using namespace std;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
const int MOD = (int)1e9 + 7;
long long pow(long long base, long long exp, long long mod) {
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result *= base;
    base *= base;
    if (base > mod) base %= mod;
    if (result > mod) result %= mod;
    exp /= 2;
  }
  return result;
}
long long mult(long long A, long long B) {
  if (B == 0) return 0;
  long long u = mult(A, B / 2);
  long long res;
  if (B % 2 == 0)
    res = u + u;
  else
    res = u + u + A;
  while (res >= MOD) res -= MOD;
  return res;
}
int n, num;
vector<int> nums;
void inp() {
  for (long long i = 0; i < n; i++) {
    cin >> num;
    nums.push_back(num);
  }
}
long long _sieve_size;
bitset<10000010> bs;
vector<int> primes;
void sieve(long long upperbound) {
  _sieve_size = upperbound + 1;
  bs.set();
  bs[0] = bs[1] = 0;
  for (long long i = 2; i <= _sieve_size; i++)
    if (bs[i]) {
      for (long long j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
      primes.push_back((int)i);
    }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  string str, cd;
  vector<string> d;
  for (long long i = 0; i < n; i++) {
    cin >> str;
    if (str == "pwd") {
      for (long long i = 0; i < d.size(); i++) cout << "/" << d[i];
      cout << "/\n";
    } else {
      cin >> cd;
      cd += '/';
      if (cd[0] == '/') d.erase((d).begin(), (d).end());
      int next, last;
      next = last = 0;
      char delim = '/';
      while ((next = cd.find(delim, last)) != string::npos) {
        string ss = cd.substr(last, next - last);
        last = next + 1;
        if (ss.empty())
          continue;
        else if (ss == "..")
          d.erase(d.begin() + d.size() - 1);
        else
          d.push_back(ss);
      }
    }
  }
  return 0;
}
