#include<iostream>
using namespace std;
class Stack{
private:
    int top;
    int capacity;
    string *arr;
public:
    Stack(int n){
        top=-1;
        capacity=n;
        arr=(string *)malloc(capacity*sizeof(string));
    }
    bool isempty()
    {
        if(top==-1)
        {
            cout<<"ig"<<endl;
            return true;
        }
        else return false;
    }
    string push(Stack *s,string a)
    {

        s->top++;
        //cout<<s->top;
        s->arr[s->top]=a;
        cout<<"Successfully pushed"<<endl;
        return arr[s->top];

    }
    string pop(Stack *s)
    {
        if(isempty())
        {
            return "Ignored";
        }
        else{
        string b=s->arr[s->top];
        s->top--;
        return b;
        }
    }
    string printtop()
    {
        if(top==-1)
        {
            return "IGNORED";
        }
        else{
            string a=arr[top];
            return a;
        }
    }
    int gettop()
    {
        return top;
    }
    void print()
    {
        for(int i=top;i>=0;i--)
        {
            cout<<arr[i]<<endl;
        }
    }
};

int main()
{
    int n;
    cin>>n;
    Stack b(10),f(10);
    string r="http://w...content-available-to-author-only...j.com/";
    b.push(&b,r);

    for(int i=0;i<100;i++)
    {
        string command, url;
        cin>>command;
        if(command=="VISIT")
        {
            cin>>url;
            if(f.isempty()){
               string p=b.push(&b,url);
            }
            else{
                string a=f.pop(&f);
                b.push(&b,a);
                string p=b.push(&b,url);
                int j=f.gettop();
                for(int i=j;i>=0;i--)
                {
                    string q=f.pop(&f);
                }
                cout<<j<<endl;
                //cout<<p<<endl;
            }

        }
        else if(command=="BACK"){
            string a=b.pop(&b);
            string c=f.push(&f,a);
            cout<<b.printtop()<<endl;
            //cout<<"*****BACKWARD STACK******"<<endl;
            //b.print();
        }else if(command=="FORWARD"){
            string a=f.pop(&f);
            string d=b.push(&b,a);
            string c=f.printtop();
            cout<<c<<endl;
            //cout<<"*****FORWARD STACK******"<<endl;
            //f.print();
        }else if(command=="QUIT"){
            break;
        }
    }
    cout<<"Completed"<<endl;
}
