import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
int p=Integer.parseInt(in.nextLine().trim());
String inputPath=in.nextLine().trim();
if(inputPath.length()==1)
{
inputPath="";
}
StringBuilder[] result=new StringBuilder[p];
for(int i=0;i
{
String path=in.nextLine().trim();
if(path.length()==0)
{
if(inputPath.length()==0)
{
result[i] = new StringBuilder("/");
}
else
result[i]=new StringBuilder(inputPath);
continue;
}
path=path.replaceAll("/{2,}","/");
if(path.length()==1&&path.charAt(0)==‘/‘)
{
result[i]=new StringBuilder("/");
continue;
}
if (path.charAt(0)!=‘/‘)
{
path=inputPath+"/"+path;
}
if(path.charAt(path.length()-1)==‘/‘)
{
path=path.substring(0,path.length()-1);
}
String temp="";
int t=0;
String[] path1=path.substring(1).split("/");
for(int j=path1.length-1;j>=0;j--)
{
if(path1[j].equals("."))
{
continue;
}
else if(path1[j].equals(".."))
{
t++;
}
else if(t>0)
{
t--;
}
else
{
temp="/"+path1[j]+temp;
}
}
result[i]= new StringBuilder(temp);
}
in.close();
for (int i=0;i
{
System.out.println(result[i].toString());
}
}
}