#include<iostream>
#include<string>
#include<vector>

using namespace std;

vector<string> forwardStack,backwardStack;

int main()
{
	string comm;
	string curUrl("http://www.acm.org/");

	while(comm.compare("QUIT"))
	{
		cin>>comm;
		if(comm.compare("VISIT")==0)
		{
			backwardStack.push_back(curUrl);
			cin>>curUrl;
			cout<<curUrl<<endl;
			forwardStack.clear();
		}
		if(comm.compare("BACK")==0)
		{
			if(backwardStack.empty())
				cout<<"Ignored"<<endl;
			else
			{
				forwardStack.push_back(curUrl);
				curUrl = backwardStack.back();
				backwardStack.erase(backwardStack.end()-1);
				cout<<curUrl<<endl;
			}
		}
		if(comm.compare("FORWARD")==0)
		{
			if(forwardStack.empty())
				cout<<"Ignored"<<endl;
			else
			{
				backwardStack.push_back(curUrl);
				curUrl = forwardStack.back();
				forwardStack.erase(forwardStack.end()-1);
				cout<<curUrl<<endl;
			}
		}
	}
	return 0;
}