#include <bits/stdc++.h>
using namespace std;
int in() {
  int a;
  scanf("%d", &a);
  return a;
}
double din() {
  double a;
  scanf("%lf", &a);
  return a;
}
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const double eps = 1e-7;
const double pi = 3.14159265358979323;
const int INF = 999999999;
int qq(int a, int b) {
  int c = a + b;
  int res = 0;
  while (c % 10 == 0) {
    ++res;
    c /= 10;
  }
  return res;
}
bool isa(char a) {
  if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
    return true;
  else
    return false;
}
bool isprime(int a) {
  for (int i = 2; i * i <= a; ++i) {
    if (a % i == 0) return false;
  }
  return true;
}
struct Node {
  Node *l, *r, *p;
  int x, y;
  vector<Node *> a;
  vector<char> u;
  Node *use() {
    if (u.empty()) u.assign(a.size(), 0);
    for (int i = 0; i < u.size(); ++i) {
      if (!u[i]) {
        u[i] = 1;
        return a[i];
      }
    }
    return NULL;
  }
  Node() {}
  Node(int xx, int yy) {
    x = xx;
    y = yy;
    l = NULL;
    r = NULL;
    p = NULL;
  }
  Node(int xx, int yy, Node *pp) {
    x = xx;
    y = yy;
    p = pp;
    l = NULL;
    r = NULL;
  }
  void setp(Node *pp) { p = pp; }
};
class Treap {
 private:
  Node *root, *l;
  void insert(Node *&r, Node *a) {
    if (r == NULL) {
      r = a;
      return;
    }
    if (a->y < r->y) {
      split(r, a->x, a->l, a->r);
      r = a;
    } else {
      if (a->x < r->x)
        insert(r->l, a);
      else
        insert(r->r, a);
    }
  }
  void split(Node *a, int X, Node *&l, Node *&r) {
    if (a == NULL) {
      l = r = NULL;
      return;
    }
    if (a->x > X) {
      split(a->l, X, l, a->l);
      r = a;
    } else {
      split(a->r, X, a->r, r);
      l = a;
    }
  }
  void built(Node *r, Node *t) {
    while (r->y > t->y && r->p != NULL) {
      r = r->p;
    }
    if (r->p == NULL && t->y < r->y) {
      r->p = t;
      t->l = r;
      root = t;
      root->p = NULL;
      l = t;
      return;
    }
    t->l = r->r;
    r->r = t;
    t->p = r;
    t->l->p = t;
    l = t;
  }

 public:
  Treap() {
    root = NULL;
    l = NULL;
  }
  void built(pair<int, int> a) {
    Node *n = new Node(a.first, a.second);
    if (root == NULL) {
      root = n;
      l = n;
      return;
    }
    if (l->y < n->y) {
      l->r = n;
      n->p = l;
      l = n;
      return;
    }
    built(l, n);
  }
  void insert(pair<int, int> a) {
    Node *node = new Node(a.first, a.second);
    insert(root, node);
  }
  Node *getRoot() { return root; }
};
struct nod {
  nod *l, *r;
  long long sum;
};
int min(int x, int y) { return y ^ ((x ^ y) & -(x < y)); }
int max(int x, int y) { return x ^ ((x ^ y) & -(x < y)); }
int aa(int a) { return log10(a); }
string tos(int a) {
  string r = "";
  while (a > 0) {
    r += a % 10 + '0';
    a /= 10;
  }
  reverse(r.begin(), r.end());
  return r;
}
string ma(string a) {
  string r = "";
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] == '4' || a[i] == '7') r += a[i];
  }
  return r;
}
bool com(pair<double, int> a, pair<double, int> b) {
  if (fabs(a.first - b.first) <= eps)
    return a.second < b.second;
  else
    return a.first > b.first;
}
long double nextApproximation(long double x) {
  return x - (3 * x + cos(x) + 1) / (3 - sin(x));
}
bool exit() { exit(0); }
double dist(int x1, int y1, int x2, int y2) {
  return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
struct state {
  int link, len;
  map<char, int> next;
};
vector<vector<int> > gg;
map<int, int> m;
vector<char> u;
bool dfs(int v, int f) {
  u[v] = 1;
  if (v == f) return true;
  for (int i = 0; i < gg[v].size(); ++i) {
    if (!u[gg[v][i]] && dfs(gg[v][i], f)) {
      cout << m[gg[v][i]] << ' ';
      return 1;
    }
  }
  return 0;
}
map<char, int> mau;
int aa(string a, int p) {
  int res = 0;
  int po = 1;
  for (int i = a.size() - 1; i >= 0; --i, po *= p) {
    res += po * mau[a[i]];
  }
  return res;
}
vector<int> z_function(string s) {
  int n = (int)s.length();
  vector<int> z(n);
  for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
  return z;
}
bool com(pair<int, int> a, pair<int, int> b) {
  if (a.second > b.second) return 1;
  if (a.second < b.second) return 0;
  return a.first > b.first;
}
vector<vector<int> > g;
unsigned long long p = 1000000007;
unsigned long long mod = 909090909090909091ll;
long long hashu(int i) {
  unsigned long long h = 0ll;
  unsigned long long pw = 1;
  for (int k = 0; k < g[i].size(); ++k) {
    h += pw * g[i][k];
    pw *= p;
    h %= mod;
    pw %= mod;
  }
  for (int j = 0; j < g[i].size(); ++j) cout << g[i][j] << ' ';
  cout << endl;
  return h;
}
class sNode {
 public:
  int value, key, height;
  sNode *left;
  sNode *right;
  sNode *parent;
  sNode(int _key, int _value) {
    key = _key;
    value = _value;
    left = NULL;
    right = NULL;
    parent = NULL;
  }
};
class bst {
 public:
  sNode *root;
  int height;
  bst() { root = NULL; }
  void add(int _key, int _value) {
    if (root == NULL) {
      root = new sNode(_key, _value);
    } else {
      addNode(root, new sNode(_key, _value));
    }
  }
  int find(int _key) {
    sNode *res = findNode(root, _key);
    if (res != NULL)
      return res->value;
    else {
      return -1;
    }
  }

 private:
  void addNode(sNode *&cur, sNode *x, int deep = 0) {
    if (cur == NULL) {
      cur = x;
      height = max(deep, height);
      return;
    }
    if (x->key < cur->key) {
      addNode(cur->left, x, ++deep);
    }
    if (x->key > cur->key) {
      addNode(cur->right, x, ++deep);
    }
  }
  sNode *findNode(sNode *cur, int _key) {
    if (cur == NULL) {
      return NULL;
    }
    if (_key == cur->key) {
      return cur;
    }
    if (_key < cur->key) {
      findNode(cur->left, _key);
    } else {
      findNode(cur->right, _key);
    }
  }
};
vector<int> pf(string s) {
  int n = (int)s.length();
  vector<int> pi(n);
  for (int i = 1; i < n; ++i) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) ++j;
    pi[i] = j;
  }
  return pi;
}
vector<int> b;
int ffu(int a, int b) { return max(a, b); }
int getsum(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (tl == l && tr == r) return b[v];
  int tm = (tr + tl) / 2;
  return ffu(getsum(2 * v, tl, tm, l, min(tm, r)),
             getsum(2 * v + 1, tm + 1, tr, max(tm + 1, l), r)) +
         b[v];
}
void update(int v, int tl, int tr, int l, int r) {
  if (l > r) return;
  if (tr == r && tl == l) {
    b[v]++;
    return;
  }
  int tm = (tr + tl) / 2;
  update(2 * v, tl, tm, l, min(tm, r));
  update(2 * v + 1, tm + 1, tr, max(tm + 1, l), r);
}
int logbin(int a) {
  int c = 1;
  while (c < a) c <<= 1;
  return c;
}
vector<string> s(string a) {
  vector<string> res;
  string c;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] == '/')
      res.push_back(c), c.clear();
    else
      c.push_back(a[i]);
  }
  res.push_back(c);
  return res;
}
int main() {
  int n = in();
  vector<string> a;
  for (int i = 0; i < n; ++i) {
    string c;
    cin >> c;
    if (c == "pwd") {
      cout << "/";
      for (int j = 0; j < a.size(); ++j) cout << a[j] << '/';
      cout << endl;
    } else {
      cin >> c;
      if (c[0] == '/') a.clear(), c.erase(c.begin());
      vector<string> b;
      b = s(c);
      for (int j = 0; j < b.size(); ++j) {
        if (b[j].size() >= 1) {
          if (b[j] == "..")
            a.pop_back();
          else
            a.push_back(b[j]);
        }
      }
    }
  }
  return 0;
}
