from sys import stdin, stderr N, M = map(int, stdin.readline().split()) X = list(map(int, stdin.readline().split())) Y = list(map(int, stdin.readline().split())) Y.sort() ymax = max(Y) def bintan(liste, cle): d = len(liste) g = -1 while d - g > 1: moy = g + (d - g) // 2 if liste[moy] >= cle: d = moy else: g = moy return d for hito in X: i = bintan(Y, hito) if i < M: print(Y[i] - hito) else: print("infinity") #for hito in X: # i = bintan(Y, hito) # if hito >= ymax: # print("infinity") # elif i >= M: # i -= 1 # res = Y[i] - hito # print("infinity" if res <= 0 else res) # else: # print(Y[i] - hito) #