You are given $n$ strings $a_1, a_2, \ldots, a_n$: all of them have the same length $m$. The strings consist of lowercase English letters.

Find any string $s$ of length $m$ such that each of the given $n$ strings differs from $s$ in at most one position. Formally, for each given string $a_i$, there is no more than one position $j$ such that $a_i[j] \ne s[j]$.

Note that the desired string $s$ may be equal to one of the given strings $a_i$, or it may differ from all the given strings.

For example, if you have the strings abac and zbab, then the answer to the problem might be the string abab, which differs from the first only by the last character, and from the second only by the first.


-----Input-----

The first line contains an integer $t$ ($1 \le t \le 100$) — the number of test cases. Then $t$ test cases follow.

Each test case starts with a line containing two positive integers $n$ ($1 \le n \le 10$) and $m$ ($1 \le m \le 10$) — the number of strings and their length.

Then follow $n$ strings $a_i$, one per line. Each of them has length $m$ and consists of lowercase English letters.


-----Output-----

Print $t$ answers to the test cases. Each answer (if it exists) is a string of length $m$ consisting of lowercase English letters. If there are several answers, print any of them. If the answer does not exist, print "-1" ("minus one", without quotes).


-----Example-----
Input
5
2 4
abac
zbab
2 4
aaaa
bbbb
3 3
baa
aaa
aab
2 2
ab
bb
3 1
a
b
c

Output
abab
-1
aaa
ab
z


-----Note-----

The first test case was explained in the statement.

In the second test case, the answer does not exist.

Difficulty: introductory

Starter code:

Solutions:
def isvalid(s):
    nonlocal l
    for i in l:
        count=0
        for j in range(len(i)):
            if(s[j]!=i[j]):
                count+=1
        if(count>1):
            return 0
    return 1
t=int(input())
for you in range(t):
    l=input().split()
    n=int(l[0])
    m=int(l[1])
    l=[]
    for i in range(n):
        s=input()
        l.append(s)
    poss=0
    ans=0
    for i in range(m):
        copy=[x for x in l[0]]
        for j in range(26):
            copy[i]=chr(97+j)
            if(isvalid(copy)):
                poss=1
                ans=copy
                break
        if(poss==1):
            break
    if(poss):
        for i in ans:
            print(i,end="")
        print()
    else:
        print(-1)

import sys
input = sys.stdin.readline

t=int(input())
for tests in range(t):
    n,m=list(map(int,input().split()))
    A=[input().strip() for i in range(n)]

    X=A[0]
    flag=0

    for i in range(m):
        for j in range(26):
            Y=X[:i]+chr(97+j)+X[i+1:]

            for k in range(n):
                score=0
                for l in range(m):
                    if Y[l]!=A[k][l]:
                        score+=1
                if score<=1:
                    True
                else:
                    break
            else:
                print(Y)
                flag=1
                break
        if flag:
            break
    if flag==0:
        print(-1)
                    
                

    
                
    


alph = "abcdefghijklmnopqrstuvwxyz"


t = int(input())
for _ in range(t):
    n, m = map(int, input().split())
    s = [input() for i in range(n)]
    for i in range(m):
        for char in alph:
            cand = s[0][0:i] + char + s[0][i + 1:]
            flag = False
            for j in range(n):
                cnt = 0
                for k in range(m):
                    if cand[k] != s[j][k]:
                        cnt += 1
                if cnt > 1:
                    flag = True
            if not flag:
                print(cand)
                break
        else:
            continue
        break
    else:
        print(-1)

t = int(input())
for _ in range(t):
	n, m = map(int, input().split())
	a = [input() for _ in range(n)]
	found = False
	for i in range(m):
		for c in range(26):
			sol = list(a[0])
			sol[i] = chr(c + ord('a'))
			sol = "".join(sol)
			found = True
			for j in range(n):
				d = 0
				for k in range(m):
					if sol[k] != a[j][k]: d += 1
				if d > 1:
					found = False
					break
			if found: break
		if found: break
	if found: print(sol)
	else: print(-1)


TT = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"

for loop in range(TT):

    n,m = list(map(int,input().split()))

    s = []

    for i in range(n):
        tmp = list(input())
        s.append(tmp)

    blf = False
    
    for i in range(m):

        now = []
        for x in range(m):
            now.append(s[0][x])
            
        for j in range(26):
            now[i] = alp[j]
            difnum = [0] * n

            for a in range(n):
                for b in range(m):
                    if s[a][b] != now[b]:
                        difnum[a] += 1
            
            if max(difnum) <= 1:
                print("".join(now))
                blf = True
                break
        if blf:
            break

    if not blf:
        print(-1)



def check(a, b):
  dif = 0
  for i in range(len(a)):
    if a[i] != b[i]:
      dif += 1
      if dif == 2:
        return False
  return True

for _ in range(int(input())):
  n, m = map(int, input().split())
  data = []
  for i in range(n):
    data.append(input())

  result = False
  for i in range(m):
    for j in range(0, 26):
      now = data[0][:i] + chr(ord('a') + j) + data[0][i + 1:]
      temp = True
      for k in data[1:]:
        if not check(now, k):
          temp = False
      if temp:
        print(now)
        result = True
        break
    if result:
      break
  
  if not result:
    print("-1")