const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
class TreeNode {
constructor(curDicName, father) {
this.curDicName = curDicName;
this.father = father;
this.children = {};
}
}
class Tree {
constructor() {
this.root = new TreeNode("/", null);
this.cur = this.root;
}
mkdir(dicName) {
if (!this.cur.children[dicName])
this.cur.children[dicName] = new TreeNode(dicName + "/", this.cur);
}
cd(dicName) {
if (dicName == "..") {
if (this.cur.father) this.cur = this.cur.father;
} else {
if (this.cur.children[dicName]) this.cur = this.cur.children[dicName];
}
}
pwd() {
const arr = [];
let cur = this.cur;
while (cur) {
arr.push(cur.curDicName);
cur = cur.father;
}
return arr.reverse().join("");
}
}
void (async function () {
const tree = new Tree();
let lastPwd = "";
while (true) {
const command = await readline();
if (command == "") break;
const [cmd, ...arges] = command.split(" ");
switch (cmd) {
case "pwd": {
if (arges.length > 0) continue;
lastPwd = tree.pwd();
break;
}
case "mkdir": {
if (arges.length !== 1) continue;
const mkdirVal = arges[0];
tree.mkdir(mkdirVal);
lastPwd = "/";
break;
}
case "cd": {
if (arges.length !== 1) continue;
const cdVal = arges[0];
tree.cd(cdVal);
lastPwd = "/";
break;
}
}
}
console.log(lastPwd);
})();