//ツ甘板暗。ツづ?づБOJツづ個づ卍つ、ツづ?津アツ出ツつオツつスツづ個づ?つキツつイツつュツつォツづ慊つクツつ「
//2ツ嘉アツ暗δつ「ツ甘板暗。ツづ?つスツつッツづ?PPATSU


#include<iostream>
#include<map>
#include<vector>
#define F first
#define S second
using namespace std;

typedef pair<int,int> P;
typedef pair<P,P> P2;
typedef pair<P2,string> info;

int main(){
  int n,m,H,W,num,x1,x2,y1,y2;
  string s,s2,now;
  while(cin >> n && n){
    multimap<string,info> web;
    cin >> W >> H;
    for(int j=0;j<n;j++){
      cin >> s >> num;
      if(j == 0)now = s;
      for(int i=0;i<num;i++){
	cin >> x1 >> y1 >> x2 >> y2 >> s2;
	web.insert(multimap<string,info>::value_type(s,info(P2(P(x1,y1),P(x2,y2)),s2)));
      }
    }
    cin >> m;
    string op,Back,Forward;
    string *history = new string[10005];//ツ配ツ療アツ妥・ツつォツつュツつオツつスツづァツ津環づ?つス
  
    int nx,ny,Index=0,len=0;
    int pointer = 0;
    //history[Index++] = now;
    history[pointer]=now;

    //cout << "now is " << now << endl;
    Back.clear();
    Forward.clear();
    for(int i=0;i<m;i++){
      cin >> op;
      if(op == "click"){
	cin >> nx >> ny;
	for(int i=pointer+1;i<=len;i++){
	  history[i].clear();
	}

	bool found = false;
	multimap<string,info>::iterator it = web.begin();	
	while(it != web.end() ){
	  if((*it).first == now){

	    if((*it).S.F.F.F <=nx && nx <=(*it).S.F.S.F && (*it).S.F.F.S <=ny && ny <= (*it).S.F.S.S){
	      now = (*it).S.S;
	      //history[Index++] = now; 
	      history[++pointer] = now;
	      len++;
	      break;
	    }

	  }
	  it++;
	}
	//cout << now << endl;
	//cout << "--------------" << endl;
 
      }
      else if(op == "show")cout << now << endl;
      else if(op == "back"){
	//if(Index-1 >=0 ){
	  //Index--;
	  //now = history[Index-1];
	  // cout << "back to "<< now << endl;
	if(pointer-1 >=0){
	  now = history[--pointer];
	}
      }
      else if(op == "forward"){
	//if(Index+1 <= len){
	//now = history[Index];
	//Index++;
	if(!history[pointer+1].empty()){
	//if(pointer+1 < len){
	  now = history[++pointer];
	}
      }


    }
    /*
    cout << "---------"<< endl;
    for(int i=0;i<=len;i++){
      cout << history[i] << endl;
    }
    */
    delete [] history;
  }
  return 0;
}