using System; class Program { static void Main(string[] args) { int N, M, Q; int[] P; long[,] PB; long[,] FB; string[] input1 = Console.ReadLine().Split(); N = int.Parse(input1[0]); M = int.Parse(input1[1]); P = Array.ConvertAll(Console.ReadLine().Split(), int.Parse); for (int i = 0; i < N; i++) P[i]--; PB = new long[N, N / 64 + 1]; for (int i = 0; i < N; i++) { PB[P[i], i / 64] ^= (1L << (i % 64)); } FB = new long[N, N / 64 + 1]; for (int i = 0; i < M; i++) { string[] input2 = Console.ReadLine().Split(); int A = int.Parse(input2[0]) - 1; int B = int.Parse(input2[1]) - 1; FB[A, B / 64] ^= (1L << (B % 64)); FB[B, A / 64] ^= (1L << (A % 64)); } Q = int.Parse(Console.ReadLine()); for (int i = 0; i < Q; i++) { string[] input3 = Console.ReadLine().Split(); int X = int.Parse(input3[0]) - 1; int Y = int.Parse(input3[1]) - 1; bool f = false; if(P[X]!=P[Y]){ for (int j=0; j