#include<iostream>
#include<string>
#include<stack>
using namespace std;
string a,url;
stack<string>s1,s2;
int main(){
    s1.push("Ignored");
    while(true){
        cin>>a;
        if(a=="QUIT"){
            break;
        }
        if(a=="VISIT"){
            cin>>url;
            while(!s2.empty()){
                s2.pop();
            }
            s1.push(url);
            cout<<url<<endl;
        }
        else if(a=="BACK"){
            if(s1.size()==2){
                cout<<"http://www.acm.org/"<<endl;
                s2.push(s1.top());
                s1.pop();
            }
            else if(s1.size()==1){
                cout<<"Ignored"<<endl;
            }
            else{
                s2.push(s1.top());
                s1.pop();
                cout<<s1.top()<<endl;
            }
        }
        else if(a=="FORWARD"){
            if(s2.size()==0){
                cout<<"Ignored"<<endl;
            }
            else{
                cout<<s2.top()<<endl;
                s1.push(s2.top());
                s2.pop();
            }
        }
    }
    return 0;
}