import java.io.*; //MUST IMPORT!!!

public class Q3
{
    //static Console c;           // The output console

    public static void main (String[] args) throws IOException //MUST!
    {
	//c = new Console ();

	BufferedReader input = new BufferedReader (new FileReader ("DATA3.txt"));
	PrintWriter output = new PrintWriter (new FileWriter ("OUT3.txt"));

	/*String tmp = "/";
	System.out.println(tmp.split("/").length);*/

	for (int i = 0 ; i < 5 ; i++)
	{
	    String wd = input.readLine (); // working directory
	    String[] wd_arr = {""};
	    
	    if (!wd.equals ("/"))
		wd_arr = wd.split ("/");

	    String[] move = input.readLine().split ("/"); // moving instructions array

	    //int num = wd.split("/").length;
	    /*
	    /one/
	      1
	    /
	    0
	    /one/two/three
	      1   2   3
	    */
	    //if (wd_arr[0].equals(""))
	    int pointer = wd_arr.length-1;
	    for (int j = 0 ; j < move.length ; j++)
	    {
		if (move [j].equals ("..") && pointer > 0)
		{
		    pointer--;
		    wd_arr = popend (wd_arr);
		}
		else if (!move [j].equals ("."))
		{
		    wd_arr = merge (wd_arr, move [j]);
		    pointer++;
		}
	    }
	    String out = "";
	    for (int j = 0 ; j < wd_arr.length ; j++)
	    {
		out = out + wd_arr [j] + "/";
	    }

	    output.println (out);
	}
	output.close ();
	input.close ();
    } // main method


    private static String[] popend (String[] arr)
    {
	String ret[] = new String [arr.length - 1];
	for (int i = 0 ; i < arr.length - 1 ; i++)
	    ret [i] = arr [i];
	return ret;
    }


    private static String[] merge (String[] arr1, String str)
    {
	String ret[] = new String [arr1.length + 1];
	for (int i = 0 ; i < arr1.length ; i++)
	    ret [i] = arr1 [i];
	ret [ret.length - 1] = str;
	return ret;
    }
} // Text1 class

