/* solution to knockout tournament by bob roos */ import java.io.*; import java.util.*; public class BE { public static int n,N,k; public static int a[] = new int [32769]; public static int p[] = new int [32769]; public static BufferedReader in; public static void process(int i) { int pos = N+i-1; int sum = N; int pow = 1; int count = 0; int temp = i; while (pos/2 > 0) { if (a[pos/2] != temp) { count++; temp = a[pos/2]; } if (a[pos/2] == i) sum = sum - pow; pow = 2*pow; pos = pos/2; } System.out.println("Player " + i + " can be ranked as high as " + (count + 1) + " or as low as " + sum + "."); } public static void main(String args[]) throws Exception { int i,temp; StringTokenizer tok; in = new BufferedReader(new InputStreamReader(System.in)); boolean first = true; while(true) { String line = in.readLine(); tok = new StringTokenizer(line); n = Integer.parseInt(tok.nextToken().trim()); if (n <= 0) break; if (!first) System.out.println(); first = false; N = 1 << n; temp= N/2; line = in.readLine(); tok = new StringTokenizer(line); while (temp > 0) { for (i = temp; i <= 2*temp-1; i++) a[i] = Integer.parseInt(tok.nextToken().trim()); temp = temp/2; } line = in.readLine(); tok = new StringTokenizer(line); k = Integer.parseInt(tok.nextToken().trim()); for (i = 0; i < k; i++) { p[i] = Integer.parseInt(tok.nextToken().trim()); process(p[i]); } } } }