import sys input = sys.stdin.readline from heapq import heappop,heappush N,M=map(int,input().split()) LRXY=[list(map(int,input().split())) for i in range(N)] A=list(map(int,input().split())) H=[] for l,r,x,y in LRXY: a=l//x*x+y-x while a