// Задача "К коду Грея"
// 8-ая Интернет-олимпиада сезона 2007-2008, базовый уровень
// Автор решения: Антон Феськов, argentony@gmail.com


import java.io.*;
import java.math.*;
import java.util.*;

public class togray_af implements Runnable {
  public static void main(String[] args) {
    new Thread(new togray_af()).start();
  }
  
  BufferedReader br;
  StringTokenizer st;
  PrintWriter out;
  boolean eof;

  public void run() {
    try {
      String FNAME = "togray";
      Locale.setDefault(Locale.US);
      br = new BufferedReader(new FileReader(FNAME + ".in"));
      out = new PrintWriter(FNAME + ".out");
      solve();
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      out.close();
    }
  }

  String nextToken() {
    while (st == null || !st.hasMoreElements()) {
      try {
        st = new StringTokenizer(br.readLine());
      } catch (Exception e) {
        eof = true;
        return "0";
      }
    }
    return st.nextToken();
  }

  int nextInt() {
    return Integer.parseInt(nextToken());
  }

  long nextLong() {
    return Long.parseLong(nextToken());
  }

  double nextDouble() {
    return Double.parseDouble(nextToken());
  }

  Random rand = new Random(this.hashCode());

  void myAssert(boolean e, String msg) {
    if (!e) {
      throw new Error(msg);
    }
  }
  
  
  
  byte foo(int a, int b) {
    if ((((a ^ b) - 1) & (a ^ b)) == 0) return 0;
    return 1;
  }
  
  
  void solve() throws IOException {
   int n = nextInt();
   myAssert(1 <= n && n <= 16, "n out of bounds Exception");
   int nn = 1 << n;
   boolean[] u = new boolean[nn];
   int[] a = new int[nn];
   for (int i = 0; i < nn; i++) {
     int t = nextInt();
     myAssert(0 <= t && t < nn, "element at position " + i + " out of bounds Exception");
     myAssert(!u[t], "element at position " + i + " duplicate entrance Exception");
     u[t] = true;
     a[i] = t;
   }
   int sum = 0;
   for (int i = 0; i < nn; i++) {
     sum += foo(a[i], a[(i + 1) % nn]);
   }
   
   int m = nextInt();
   myAssert(1 <= m && m <= 100000, "m out of bounds Exception");
   while (m-- > 0) {
     int i = nextInt();
     myAssert(0 <= i && i < nn, "i out of bounds Exception");
     int j = nextInt();
     myAssert(0 <= j && j < nn, "j out of bounds Exception");
     sum -= foo(a[i], a[(i + 1) % nn]);
     sum -= foo(a[i], a[(i + nn - 1) % nn]);
     sum -= foo(a[j], a[(j + 1) % nn]);
     sum -= foo(a[j], a[(j + nn - 1) % nn]);
     int t = a[i];
     a[i] = a[j];
     a[j] = t;
     sum += foo(a[i], a[(i + 1) % nn]);
     sum += foo(a[i], a[(i + nn - 1) % nn]);
     sum += foo(a[j], a[(j + 1) % nn]);
     sum += foo(a[j], a[(j + nn - 1) % nn]);
     if (sum == 0) {
      out.println("Yes");
    } else {
      out.println("No");
    }
   }
    
  }
}
