// Arup Guha
// 7/14/2014
// Solution to 2006 UCF HS Contest Problem: Browser Test

import java.util.*;
import java.io.*;

public class browser {

	// Make this a lot bigger so we don't worry about array out of bounds.
	final public static int MAX = 200;

	public static void main(String[] args) throws Exception {

		// Bunch of initialization stuff.
		Scanner stdin = new Scanner(new File("browser.in"));
		String cmd = stdin.next();
		int loop = 1;
		boolean printHeader = true;
		String[] buffer = null;
		int curIndex = -1;

		// Go through each session.
		while (!cmd.equals("END")) {

			// Only needed sometimes.
			if (printHeader) {
				System.out.println("Browser Session #"+loop+":");
				printHeader = false;
			}

			// Get everything started.
			if (cmd.equals("START")) {
				buffer = new String[MAX];
				Arrays.fill(buffer, null);
				curIndex = -1;
			}

			// Load this one next.
			else if (cmd.equals("URL")) {
				curIndex++;
				buffer[curIndex] = stdin.next();
				System.out.println(buffer[curIndex]);

				// Tricky - URL empties forward list.
				buffer[curIndex+1] = null;
			}

			// Go back if we can.
			else if (cmd.equals("BACK")) {
				if (curIndex > 0) {
					curIndex--;
					System.out.println(buffer[curIndex]);
				}
			}

			// Or forward.
			else if (cmd.equals("FORWARD")) {
				if (buffer[curIndex+1] != null) {
					curIndex++;
					System.out.println(buffer[curIndex]);
				}
			}

			// Load again...
			else if (cmd.equals("RELOAD")) {
				if (curIndex >= 0)
					System.out.println(buffer[curIndex]);
			}

			// Get next command.
			cmd = stdin.next();

			// Finished a set, move on.
			if (cmd.equals("END")) {
				System.out.println();
				loop++;
				cmd = stdin.next();
				printHeader = true;
			}

		}

		stdin.close();
	}
}