import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes") no = lambda :print("no");No = lambda :print("No") ####################################################################### N, M = na() assert 2 <= N <= 10**4 assert 0 <= M <= 10**4 for _ in range(M): a, b = na() assert 1 <= a <= N assert 1 <= b <= N c = na() assert len(c) == N for i in range(N): assert 1 <= c[i] <= 10 w = na() assert len(w) == 10 for i in range(10): assert 1 <= w[i] <= 10**9 Q = ni() assert 1 <= Q <= 10**4 for _ in range(Q): x, y = na() assert 1 <= x < y <= N