#include <iostream>
#include <string>
#include <stack>
using namespace std;
int main(){
string input;
string url;
stack<string> past;
stack<string> future;
past.push("http://www.acm.org/");
/*
past.push("hello1");
past.push("hello2");
cout<<past.top();
past.pop();
cout<<past.top();
*/
while(cin>>input){
if(input[0]=='B'){
//cout<<"BACK"<<endl;
if(past.size()<=1){
cout<<"Ignored"<<endl;
}
else{
future.push(past.top());
past.pop();
cout<<past.top()<<endl;
}
}
else if(input[0]=='F'){
//cout<<"FORWARD"<<endl;
if(future.empty()){
cout<<"Ignored"<<endl;
}
else{
cout<<future.top()<<endl;
past.push(future.top());
future.pop();
}
}
else if(input[0]=='V'){
//cout<<"VISIT"<<endl;
cin>>url;
past.push(url);
cout<<url<<endl;
while(!future.empty()){
future.pop();
}
}
else if(input[0]=='Q'){
//cout<<"QUIT"<<endl;
}
}
return 0;