#include <vector>
#include <map>
#include <iostream>
#define M make_pair
#define F first
#define S second
using namespace std;
typedef vector<pair<
	pair<
		pair<int,int>,
		pair<int,int>
	>,string
> >links;
int main(){
	int N,n,x1,y1,x2,y2,cur;
	string s,t;
	for(;cin>>N>>x1>>y1;){
		map<string,links>m;
		vector<string>visit;
		for(cur=-1;N;N--){
			links v;
			for(cin>>s>>n;n;n--)
				cin>>x1>>y1>>x2>>y2>>t,v.push_back(M(M(M(x1,x2),M(y1,y2)),t));
			m[s]=v;
			if(cur==-1)visit.push_back(s),cur=0;
		}
		for(cin>>N;N;N--){
			if(cin>>s,s=="show")cout<<visit[cur]<<endl;
			if(s=="back"){if(cur>0)cur--;}
			if(s=="forward"){if(cur<visit.size()-1)cur++;}
			if(s=="click"){
				cin>>x1>>y1;
				links v=m[visit[cur]];
				for(n=0;n<v.size();n++){
					if(v[n].F.F.F<=x1&&x1<=v[n].F.F.S && v[n].F.S.F<=y1&&y1<=v[n].F.S.S){
						for(;cur<visit.size()-1;)visit.erase(visit.begin()+cur+1);
						visit.push_back(v[n].S);cur++;
					}
				}
			}
		}
	}
}