# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    class BIT:
        def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
            self.depth=n.bit_length()
        
        def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
        def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s
        
        def lower_bound(self,x):
            sum_=0
            pos=0
            for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
            return pos, sum_
    
    N,Q=map(int,input().split())
    S,T,X=[0]*N,[0]*N,[0]*N
    for i in range(N):
        S[i],T[i],X[i]=map(int,input().split())
    unique_X=sorted(list(set(X)))
    d={unique_X[i]:i for i,x in enumerate(unique_X)}
    l=[0]*(N*2+Q)
    for i in range(N):
        l[i*2]=((S[i]-X[i])<<40)+(1<<20)+d[X[i]]
        l[i*2+1]=((T[i]-X[i])<<40)+d[X[i]]
    for i in range(N*2,N*2+Q):
        l[i]=(int(input())<<40)+(2<<20)
    l.sort()
    mask=(1<<20)-1
    b=BIT(len(unique_X))
    for tqx in l:
        x=tqx&mask
        q=(tqx>>20)&mask
        t=(tqx>>40)&mask
        if q==0:
            b.add(x,-1)
        elif q==1:
            b.add(x,1)
        else:
            res,_=b.lower_bound(1)
            print(unique_X[res] if res<len(unique_X) else -1)
        


if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 INF=10**18 INF 10**18 10 18 MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 input=lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip YesNo=lambda b: bool([print('Yes')] if b else print('No')) YesNo lambda b: bool([print('Yes')] if b else print('No')) bool([print('Yes')] if b else print('No')) bool [print('Yes')] if b else print('No') b [print('Yes')] print('Yes') print 'Yes' print('No') print 'No' b YESNO=lambda b: bool([print('YES')] if b else print('NO')) YESNO lambda b: bool([print('YES')] if b else print('NO')) bool([print('YES')] if b else print('NO')) bool [print('YES')] if b else print('NO') b [print('YES')] print('YES') print 'YES' print('NO') print 'NO' b int1=lambda x:int(x)-1 int1 lambda x:int(x)-1 int(x)-1 int(x) int x 1 x def main():
    class BIT:
        def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
            self.depth=n.bit_length()
        
        def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
        def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s
        
        def lower_bound(self,x):
            sum_=0
            pos=0
            for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
            return pos, sum_
    
    N,Q=map(int,input().split())
    S,T,X=[0]*N,[0]*N,[0]*N
    for i in range(N):
        S[i],T[i],X[i]=map(int,input().split())
    unique_X=sorted(list(set(X)))
    d={unique_X[i]:i for i,x in enumerate(unique_X)}
    l=[0]*(N*2+Q)
    for i in range(N):
        l[i*2]=((S[i]-X[i])<<40)+(1<<20)+d[X[i]]
        l[i*2+1]=((T[i]-X[i])<<40)+d[X[i]]
    for i in range(N*2,N*2+Q):
        l[i]=(int(input())<<40)+(2<<20)
    l.sort()
    mask=(1<<20)-1
    b=BIT(len(unique_X))
    for tqx in l:
        x=tqx&mask
        q=(tqx>>20)&mask
        t=(tqx>>40)&mask
        if q==0:
            b.add(x,-1)
        elif q==1:
            b.add(x,1)
        else:
            res,_=b.lower_bound(1)
            print(unique_X[res] if res<len(unique_X) else -1)
         main class BIT:
        def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
            self.depth=n.bit_length()
        
        def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
        def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s
        
        def lower_bound(self,x):
            sum_=0
            pos=0
            for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
            return pos, sum_
    
     BIT def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
            self.depth=n.bit_length()
        
         __init__ self.num=n self.num self num n self.dat=[0]*(self.num+1) self.dat self dat [0]*(self.num+1) [0] 0 self.num+1 self.num self num 1 self.depth=n.bit_length() self.depth self depth n.bit_length() n.bit_length n bit_length self self n n def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
         add i+=1 i 1 while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
         i<=self.num i self.num self num self.dat[i]+=x self.dat[i] self.dat self dat i x i+=i&-i i i&-i i -i i self self i i x x def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s
        
         sum i+=1 i 1 s=0 s 0 while i>0:
                s+=self.dat[i]
                i-=i&-i
             i>0 i 0 s+=self.dat[i] s self.dat[i] self.dat self dat i i-=i&-i i i&-i i -i i return s s self self i i def lower_bound(self,x):
            sum_=0
            pos=0
            for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
            return pos, sum_
    
     lower_bound sum_=0 sum_ 0 pos=0 pos 0 for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
             i range(self.depth,-1,-1) range self.depth self depth -1 -1 k=pos+(1<<i) k pos+(1<<i) pos 1<<i 1 i if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
             k<=self.num and sum_+self.dat[k]<x k<=self.num k self.num self num sum_+self.dat[k]<x sum_+self.dat[k] sum_ self.dat[k] self.dat self dat k x sum_+=self.dat[k] sum_ self.dat[k] self.dat self dat k pos+=1<<i pos 1<<i 1 i return pos, sum_ return pos, sum_ pos sum_ self self x x N,Q=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split Q S,T,X=[0]*N,[0]*N,[0]*N S [0]*N [0] 0 N T [0]*N [0] 0 N X [0]*N [0] 0 N for i in range(N):
        S[i],T[i],X[i]=map(int,input().split())
     i range(N) range N S[i],T[i],X[i]=map(int,input().split()) S[i] S i map(int,input().split()) map int input().split() ().split () input split T[i] T i X[i] X i unique_X=sorted(list(set(X))) unique_X sorted(list(set(X))) sorted list(set(X)) list set(X) set X unique_X[i]:i for i,x in enumerate(unique_X) for i,x in enumerate(unique_X) i x enumerate(unique_X) enumerate unique_X for i,x in enumerate(unique_X) unique_X[i] unique_X i i d={unique_X[i]:i for i,x in enumerate(unique_X)} d {unique_X[i]:i for i,x in enumerate(unique_X)} l=[0]*(N*2+Q) l [0]*(N*2+Q) [0] 0 N*2+Q N*2 N 2 Q for i in range(N):
        l[i*2]=((S[i]-X[i])<<40)+(1<<20)+d[X[i]]
        l[i*2+1]=((T[i]-X[i])<<40)+d[X[i]]
     i range(N) range N l[i*2]=((S[i]-X[i])<<40)+(1<<20)+d[X[i]] l[i*2] l i*2 i 2 ((S[i]-X[i])<<40)+(1<<20)+d[X[i]] ((S[i]-X[i])<<40)+(1<<20) (S[i]-X[i])<<40 S[i]-X[i] S[i] S i X[i] X i 40 1<<20 1 20 d[X[i]] d X[i] X i l[i*2+1]=((T[i]-X[i])<<40)+d[X[i]] l[i*2+1] l i*2+1 i*2 i 2 1 ((T[i]-X[i])<<40)+d[X[i]] (T[i]-X[i])<<40 T[i]-X[i] T[i] T i X[i] X i 40 d[X[i]] d X[i] X i for i in range(N*2,N*2+Q):
        l[i]=(int(input())<<40)+(2<<20)
     i range(N*2,N*2+Q) range N*2 N 2 N*2+Q N*2 N 2 Q l[i]=(int(input())<<40)+(2<<20) l[i] l i (int(input())<<40)+(2<<20) int(input())<<40 int(input()) int input() input 40 2<<20 2 20 l.sort() l.sort l sort mask=(1<<20)-1 mask (1<<20)-1 1<<20 1 20 1 b=BIT(len(unique_X)) b BIT(len(unique_X)) BIT len(unique_X) len unique_X for tqx in l:
        x=tqx&mask
        q=(tqx>>20)&mask
        t=(tqx>>40)&mask
        if q==0:
            b.add(x,-1)
        elif q==1:
            b.add(x,1)
        else:
            res,_=b.lower_bound(1)
            print(unique_X[res] if res<len(unique_X) else -1)
         tqx l x=tqx&mask x tqx&mask tqx mask q=(tqx>>20)&mask q (tqx>>20)&mask tqx>>20 tqx 20 mask t=(tqx>>40)&mask t (tqx>>40)&mask tqx>>40 tqx 40 mask if q==0:
            b.add(x,-1)
        elif q==1:
            b.add(x,1)
        else:
            res,_=b.lower_bound(1)
            print(unique_X[res] if res<len(unique_X) else -1)
         q==0 q 0 b.add(x,-1) b.add b add x -1 elif q==1:
            b.add(x,1)
         q==1 q 1 b.add(x,1) b.add b add x 1 res,_=b.lower_bound(1) res b.lower_bound(1) b.lower_bound b lower_bound 1 _ print(unique_X[res] if res<len(unique_X) else -1) print unique_X[res] if res<len(unique_X) else -1 res<len(unique_X) res len(unique_X) len unique_X unique_X[res] unique_X res -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main YesNo=lambda b: bool([print('Yes')] if b else print('No')) lambda b: bool([print('Yes')] if b else print('No')) YesNo def main():
    class BIT:
        def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
            self.depth=n.bit_length()
        
        def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
        def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s
        
        def lower_bound(self,x):
            sum_=0
            pos=0
            for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
            return pos, sum_
    
    N,Q=map(int,input().split())
    S,T,X=[0]*N,[0]*N,[0]*N
    for i in range(N):
        S[i],T[i],X[i]=map(int,input().split())
    unique_X=sorted(list(set(X)))
    d={unique_X[i]:i for i,x in enumerate(unique_X)}
    l=[0]*(N*2+Q)
    for i in range(N):
        l[i*2]=((S[i]-X[i])<<40)+(1<<20)+d[X[i]]
        l[i*2+1]=((T[i]-X[i])<<40)+d[X[i]]
    for i in range(N*2,N*2+Q):
        l[i]=(int(input())<<40)+(2<<20)
    l.sort()
    mask=(1<<20)-1
    b=BIT(len(unique_X))
    for tqx in l:
        x=tqx&mask
        q=(tqx>>20)&mask
        t=(tqx>>40)&mask
        if q==0:
            b.add(x,-1)
        elif q==1:
            b.add(x,1)
        else:
            res,_=b.lower_bound(1)
            print(unique_X[res] if res<len(unique_X) else -1)
         def main():
    class BIT:
        def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
            self.depth=n.bit_length()
        
        def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
        def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s
        
        def lower_bound(self,x):
            sum_=0
            pos=0
            for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
            return pos, sum_
    
    N,Q=map(int,input().split())
    S,T,X=[0]*N,[0]*N,[0]*N
    for i in range(N):
        S[i],T[i],X[i]=map(int,input().split())
    unique_X=sorted(list(set(X)))
    d={unique_X[i]:i for i,x in enumerate(unique_X)}
    l=[0]*(N*2+Q)
    for i in range(N):
        l[i*2]=((S[i]-X[i])<<40)+(1<<20)+d[X[i]]
        l[i*2+1]=((T[i]-X[i])<<40)+d[X[i]]
    for i in range(N*2,N*2+Q):
        l[i]=(int(input())<<40)+(2<<20)
    l.sort()
    mask=(1<<20)-1
    b=BIT(len(unique_X))
    for tqx in l:
        x=tqx&mask
        q=(tqx>>20)&mask
        t=(tqx>>40)&mask
        if q==0:
            b.add(x,-1)
        elif q==1:
            b.add(x,1)
        else:
            res,_=b.lower_bound(1)
            print(unique_X[res] if res<len(unique_X) else -1)
         main YESNO=lambda b: bool([print('YES')] if b else print('NO')) lambda b: bool([print('YES')] if b else print('NO')) YESNO INF=10**18 10**18 INF input=lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input int1=lambda x:int(x)-1 lambda x:int(x)-1 int1 MOD=10**9+7 10**9+7 MOD
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    class BIT:
        def __init__(self,n):
            self.num=n
            self.dat=[0]*(self.num+1)
            self.depth=n.bit_length()
        
        def add(self,i,x):
            i+=1
            while i<=self.num:
                self.dat[i]+=x
                i+=i&-i
        
        def sum(self,i):
            i+=1
            s=0
            while i>0:
                s+=self.dat[i]
                i-=i&-i
            return s
        
        def lower_bound(self,x):
            sum_=0
            pos=0
            for i in range(self.depth,-1,-1):
                k=pos+(1<<i)
                if k<=self.num and sum_+self.dat[k]<x:
                    sum_+=self.dat[k]
                    pos+=1<<i
            return pos, sum_
    
    N,Q=map(int,input().split())
    S,T,X=[0]*N,[0]*N,[0]*N
    for i in range(N):
        S[i],T[i],X[i]=map(int,input().split())
    unique_X=sorted(list(set(X)))
    d={unique_X[i]:i for i,x in enumerate(unique_X)}
    l=[0]*(N*2+Q)
    for i in range(N):
        l[i*2]=((S[i]-X[i])<<40)+(1<<20)+d[X[i]]
        l[i*2+1]=((T[i]-X[i])<<40)+d[X[i]]
    for i in range(N*2,N*2+Q):
        l[i]=(int(input())<<40)+(2<<20)
    l.sort()
    mask=(1<<20)-1
    b=BIT(len(unique_X))
    for tqx in l:
        x=tqx&mask
        q=(tqx>>20)&mask
        t=(tqx>>40)&mask
        if q==0:
            b.add(x,-1)
        elif q==1:
            b.add(x,1)
        else:
            res,_=b.lower_bound(1)
            print(unique_X[res] if res<len(unique_X) else -1)
        


if __name__ == '__main__':
    main()
