N,K = map(int,input().split()) A = input().split() S = "" for k in range(K): c = ":" for i in range(N): c = min(c, A[i][k]) S += c print(S)