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