#include<iostream>
#include<vector>
using namespace std;

typedef struct page{
  string name;
  int b;
  int x1[100],y1[100],x2[100],y2[100];
  string link[100];
}page;

int main(){
  int n,m;
  int w,h;
  page p[100];
  string inst;
  int x,y;
  vector<int> buf;
  int pos,next;

  while(1){
    cin >> n;
    if(!n)break;
    cin >> w >> h;

    for(int i=0;i<n;i++){
      cin >> p[i].name >> p[i].b;
      for(int j=0;j<p[i].b;j++){
	cin >> p[i].x1[j] >> p[i].y1[j];
	cin >> p[i].x2[j] >> p[i].y2[j];
	cin >> p[i].link[j];
      }
    }

    buf.clear();
    buf.push_back(0);
    pos = 0;

    cin >> m;
    for(int i=0;i<m;i++){
      cin >> inst;
      if(inst == "show")cout << p[buf[pos]].name << endl;
      else if(inst == "back"){
	if(pos)pos--;
      }else if(inst == "forward"){
	if(pos!=buf.size()-1)pos++;
      }else{
	cin >> x >> y;
	next = -1;
	for(int j=0;j<p[buf[pos]].b;j++){
	  if(p[buf[pos]].x1[j] <= x && x <= p[buf[pos]].x2[j]){
     	    if(p[buf[pos]].y1[j] <= y && y <= p[buf[pos]].y2[j]){
	      for(int k=0;k<n;k++){
		if(p[buf[pos]].link[j] == p[k].name){
		  next = k;
		  break;
		}
	      }
	      break;
	    }
	  }
	}
	if(next >= 0){
	  pos++;
	  while(pos < buf.size())buf.pop_back();
	  buf.push_back(next);
	}
      }
    }
  }
}