import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Dmitry Abdrashitov
 */
public class togray_da_wrong implements Runnable {
	
	private PrintWriter out;
	private BufferedReader in;
	private StringTokenizer st;
	
	int cnt;
	int[] x;
	boolean[] good;
	
	private void solve() throws Exception {
		int n = nextInt();
		if (n < 1 || n > 16) {
			throw new Exception("Wrong input data");
		}
		int k = 1 << n;
		x = new int[k];
		for (int i = 0; i < k; i++) {
			x[i] = nextInt();
		}
		int[] y = x.clone();
		Arrays.sort(y);
		for (int i = 1; i < y.length; i++) {
			if (y[i] == y[i - 1]) {
				throw new Exception("Wrong input data");
			}
		}
		cnt = 0;
		good = new boolean[k];
		for (int i = 0; i < k; i++) {
			refresh(i);
		}
		int m = nextInt();
		if (m < 1 || m > 100000) {
			throw new Exception("Wrong input data");
		}
		for (int i = 0; i < m; i++) {
			int u = nextInt();
			int v = nextInt();
			if (u < 0  || u > k || v < 0 || v > k || u == v) {
				throw new Exception("Wrong input data");
			}
			int tmp = x[u];
			x[u] = x[v];
			x[v] = tmp;
			for (int j = -1; j <= 1; j++) {
				refresh(u + j);
				refresh(v + j);
			}
			if (cnt == k) {
				out.println("Yes");
			} else {
				out.println("No");
			}
		}
	}
	
	private void refresh(int i) {
		boolean ng = good(i);
		if (good[i] && !ng) {
			good[i] = false;
			cnt--;
		}
		if (!good[i] && ng) {
			good[i] = true;
			cnt++;
		}
	}

	private boolean good(int i) {
		boolean result = true;
		if (i - 1 >= 0) {
			result &= gray(x[i - 1], x[i]);
		}
		if (i + 1 < x.length) {
			result &= gray(x[i + 1], x[i]);
		}
		return result;
	}

	private boolean gray(int a, int b) {
		return ones(a ^ b) == 1;
	}

	private int ones(int i) {
		int result = 0;
		while (i > 0) {
			result++;
			i = i & (i - 1);
		}
		return result;
	}

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			apstenu(e);
		} finally {
			out.close();
		}
	}
	
	private void apstenu(Exception e) {
		e.printStackTrace();
		System.exit(239);
	}
	
	private int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	private String nextToken() throws Exception {
		while (!st.hasMoreTokens()) {
			String line = in.readLine();
			st = new StringTokenizer(line);
		}
		return st.nextToken();
	}
	
	private togray_da_wrong(String name) {
		try {
			out = new PrintWriter(new FileWriter(name + ".out"));
			in = new BufferedReader(new FileReader(name + ".in"));
			st = new StringTokenizer("");
		} catch (Exception e) {
			apstenu(e);
		}
	}

	public static void main(String[] args) {
		new Thread(new togray_da_wrong("togray")).start();
	}
}
