import sys input = sys.stdin.readline from collections import deque N,M=map(int,input().split()) LRXY=[list(map(int,input().split())) for i in range(N)] A=list(map(int,input().split())) ANS=[0]*(10**5+1) LIST=[[] for i in range(10**5+1)] for l,r,x,y in LRXY: a=l//x*x+y-x while a