import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) input = sys.stdin.readline #n = int(input()) #alist = list(map(int,input().split())) #alist = [] r,n = map(int,input().split()) #for i in range(n): a = list(map(int,input().split())) a.sort() q = int(input()) def calc(x): res = n * (x // r) x %= r return res + bisect.bisect_right(a,x) for i in range(q): l,rr = map(int,input().split()) print(calc(rr) - calc(l-1))