N,M=map(int,input().split()) L=list() R=list() D=list() for i in range(N): A,B,C=map(int,input().split()) if i==0: s={A,C} else: s&={A,C} L.append(B) R.append([A,B,C]) D.append([max(A,C),i]) if A==C: print("NO") exit() L.sort() L.reverse() D.sort() thi=0 ans=0 usiro=N-1 s=list(s) if len(s)==1: if s[0] in L: print("NO") exit() if len(s)==2: if s[0] in L: print("NO") exit() if s[1] in L: print("NO") exit() for i in range(N): a,b=D[i] if L[thi]>a: ans+=L[thi] else: if L[usiro]=M: print("KADOMATSU!") else: print("NO")