import heapq as hq
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

def main():
    n,q = nm()
    tl = []
    ins = list()
    dlt = list()
    vv = [tuple(nm()) for _ in range(n)]
    tl = [(s-x, 1, x) for s, _, x in vv]
    tl.extend([(t-x, 0, x) for _, t, x in vv])
    ww = [ni() for _ in range(q)]
    tl.extend([(t, 2) for t in ww])
    tl.sort()

    for x in tl:
        if x[1] == 1:
            hq.heappush(ins, x[2])
        elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
        else:
            print(-1 if not ins else ins[0])
    
if __name__ == "__main__":
    main() import heapq as hq heapq import sys sys stdin = sys.stdin stdin sys.stdin sys stdin ns = lambda: stdin.readline().rstrip() ns lambda: stdin.readline().rstrip() stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip ni = lambda: int(stdin.readline().rstrip()) ni lambda: int(stdin.readline().rstrip()) int(stdin.readline().rstrip()) int stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip nm = lambda: map(int, stdin.readline().split()) nm lambda: map(int, stdin.readline().split()) map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split nl = lambda: list(map(int, stdin.readline().split())) nl lambda: list(map(int, stdin.readline().split())) list(map(int, stdin.readline().split())) list map(int, stdin.readline().split()) map int stdin.readline().split() stdin.readline().split stdin.readline() stdin.readline stdin readline split def main():
    n,q = nm()
    tl = []
    ins = list()
    dlt = list()
    vv = [tuple(nm()) for _ in range(n)]
    tl = [(s-x, 1, x) for s, _, x in vv]
    tl.extend([(t-x, 0, x) for _, t, x in vv])
    ww = [ni() for _ in range(q)]
    tl.extend([(t, 2) for t in ww])
    tl.sort()

    for x in tl:
        if x[1] == 1:
            hq.heappush(ins, x[2])
        elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
        else:
            print(-1 if not ins else ins[0])
     main n,q = nm() n nm() nm q tl = [] tl [] ins = list() ins list() list dlt = list() dlt list() list tuple(nm()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) tuple(nm()) tuple nm() nm vv = [tuple(nm()) for _ in range(n)] vv [tuple(nm()) for _ in range(n)] (s-x, 1, x) for s, _, x in vv for s, _, x in vv s _ x vv for s, _, x in vv (s-x, 1, x) s-x s x 1 x tl = [(s-x, 1, x) for s, _, x in vv] tl [(s-x, 1, x) for s, _, x in vv] (t-x, 0, x) for _, t, x in vv for _, t, x in vv _ t x vv for _, t, x in vv (t-x, 0, x) t-x t x 0 x tl.extend([(t-x, 0, x) for _, t, x in vv]) tl.extend tl extend [(t-x, 0, x) for _, t, x in vv] ni() for _ in range(q) for _ in range(q) _ range(q) range q for _ in range(q) ni() ni ww = [ni() for _ in range(q)] ww [ni() for _ in range(q)] (t, 2) for t in ww for t in ww t ww for t in ww (t, 2) t 2 tl.extend([(t, 2) for t in ww]) tl.extend tl extend [(t, 2) for t in ww] tl.sort() tl.sort tl sort for x in tl:
        if x[1] == 1:
            hq.heappush(ins, x[2])
        elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
        else:
            print(-1 if not ins else ins[0])
     x tl if x[1] == 1:
            hq.heappush(ins, x[2])
        elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
        else:
            print(-1 if not ins else ins[0])
     x[1] == 1 x[1] x 1 1 hq.heappush(ins, x[2]) hq.heappush hq heappush ins x[2] x 2 elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
         x[1] == 0 x[1] x 1 0 hq.heappush(dlt, x[2]) hq.heappush hq heappush dlt x[2] x 2 while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
         dlt and ins[0] == dlt[0] dlt ins[0] == dlt[0] ins[0] ins 0 dlt[0] dlt 0 hq.heappop(ins) hq.heappop hq heappop ins hq.heappop(dlt) hq.heappop hq heappop dlt print(-1 if not ins else ins[0]) print -1 if not ins else ins[0] not ins ins -1 ins[0] ins 0 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main nl = lambda: list(map(int, stdin.readline().split())) lambda: list(map(int, stdin.readline().split())) nl def main():
    n,q = nm()
    tl = []
    ins = list()
    dlt = list()
    vv = [tuple(nm()) for _ in range(n)]
    tl = [(s-x, 1, x) for s, _, x in vv]
    tl.extend([(t-x, 0, x) for _, t, x in vv])
    ww = [ni() for _ in range(q)]
    tl.extend([(t, 2) for t in ww])
    tl.sort()

    for x in tl:
        if x[1] == 1:
            hq.heappush(ins, x[2])
        elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
        else:
            print(-1 if not ins else ins[0])
     def main():
    n,q = nm()
    tl = []
    ins = list()
    dlt = list()
    vv = [tuple(nm()) for _ in range(n)]
    tl = [(s-x, 1, x) for s, _, x in vv]
    tl.extend([(t-x, 0, x) for _, t, x in vv])
    ww = [ni() for _ in range(q)]
    tl.extend([(t, 2) for t in ww])
    tl.sort()

    for x in tl:
        if x[1] == 1:
            hq.heappush(ins, x[2])
        elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
        else:
            print(-1 if not ins else ins[0])
     main ns = lambda: stdin.readline().rstrip() lambda: stdin.readline().rstrip() ns nm = lambda: map(int, stdin.readline().split()) lambda: map(int, stdin.readline().split()) nm stdin = sys.stdin sys.stdin stdin ni = lambda: int(stdin.readline().rstrip()) lambda: int(stdin.readline().rstrip()) ni
import heapq as hq
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

def main():
    n,q = nm()
    tl = []
    ins = list()
    dlt = list()
    vv = [tuple(nm()) for _ in range(n)]
    tl = [(s-x, 1, x) for s, _, x in vv]
    tl.extend([(t-x, 0, x) for _, t, x in vv])
    ww = [ni() for _ in range(q)]
    tl.extend([(t, 2) for t in ww])
    tl.sort()

    for x in tl:
        if x[1] == 1:
            hq.heappush(ins, x[2])
        elif x[1] == 0:
            hq.heappush(dlt, x[2])
            while dlt and ins[0] == dlt[0]:
                hq.heappop(ins)
                hq.heappop(dlt)
        else:
            print(-1 if not ins else ins[0])
    
if __name__ == "__main__":
    main()