import java.io.*;
import java.lang.*;
import java.util.*;

public class G_h {

static class Plane {
  public int x1, z1, x2, z2;
  
  Plane(String line) {
    StringTokenizer str = new StringTokenizer(line);
    x1 = Integer.parseInt(str.nextToken());
    z1 = Integer.parseInt(str.nextToken());
    x2 = Integer.parseInt(str.nextToken());
    z2 = Integer.parseInt(str.nextToken());
  }
}

static class Obj {
  int m;
  int x[], z[];

  Obj(String line) {
    StringTokenizer str = new StringTokenizer(line);
    m = Integer.parseInt(str.nextToken());
    x = new int[m];
    z = new int[m];
    for (int i = 0; i < m; i++) {
      x[i] = Integer.parseInt(str.nextToken());
      z[i] = Integer.parseInt(str.nextToken());
    }
  }
}




  public static final int MAX_N = 20;
  public static final int MAX_M = 6;
  public static final int MAX_P = 10;
  public static DataInputStream in = new DataInputStream(System.in);

  public static Obj object[];
  public static Plane plane[];
  public static int n, p;

  static int orient(Plane p, int x, int z) {
    int dx1 = p.x2 - p.x1;
    int dx2 = x - p.x2;
    int dz1 = p.z2 - p.z1;
    int dz2 = z - p.z2;
    int t1 = dz2 * dx1;
    int t2 = dz1 * dx2;
    
    if (t1 > t2) {
      return 1;
    } else {
      return -1;
    }
  }     

  static boolean in_front(Obj obj, Plane p) {
    int viewer_x, viewer_z, viewer_orient;
    int front, back, i;

    viewer_x = p.x1;
    viewer_z = p.z1 - 1;
    viewer_orient = orient(p, viewer_x, viewer_z);

    front = back = 0;
    for (i = 0; i < obj.m; i++) {
      if (orient(p, obj.x[i], obj.z[i]) == viewer_orient) {
	front++;
      } else {
	back++;
      }
    }
    
    return (front > 0);
  }

  static void split(boolean working_set[], int k) {
    boolean back[] = new boolean[MAX_N];
    boolean front[] = new boolean[MAX_N];
    int i;

    if (k == p) {
      for (i = 0; i < n; i++) {
	if (working_set[i]) {
	  System.out.print((char)('A'+i));
	}
      }
    } else {
      for (i = 0; i < n; i++) {
	back[i] = front[i] = false;
      }
      for (i = 0; i < n; i++) {
	if (working_set[i]) {
	  if (in_front(object[i], plane[k])) {
	    front[i] = true;
	  } else {
	    back[i] = true;
	  }
	}
      }

      split(back, k+1);
      split(front, k+1);
    }
			       
  }

  public static void main(String[] args) {
    String line;
    StringTokenizer str;
    boolean working_set[] = new boolean[MAX_N];
    int i, j;

    object = new Obj[MAX_N];
    plane = new Plane[MAX_P];

    try {
      line = in.readLine();
      n = Integer.parseInt(line);
      for (i = 0; i < n; i++) {
	line = in.readLine();
	object[i] = new Obj(line);
      }
      line = in.readLine();
      p = Integer.parseInt(line);
      for (i = 0; i < p; i++) {
	line = in.readLine();
	plane[i] = new Plane(line);
      }
    } catch (IOException e) {
    }

    for (i = 0; i < n; i++) {
      working_set[i] = true;
    }
    split(working_set, 0);
    System.out.println("");
  }

}
