p1-15
Source: hackerearth
Difficulty: EASY

Here is your task. You are given two strings and you have to merge/compress them in single string with minimum length such that both strings can be found (one at a time) by breaking that merged string into two parts.
NOTE:
String s2 should follow string s1.

INPUT
First line contain number of test cases T. Each test case contains two strings s1 and s2.
OUTPUT
Print merged string.
Constraints
1 ≤ T ≤ 100
1 ≤ length of strings ≤10^6

SAMPLE INPUT
2
roadshow
showman
tarun
tarunnum

SAMPLE OUTPUT
roadshowman
tarunnum


for _ in range(eval(input())):
	a,b,c=input(),input(),[]
	flag=0
	for x in range(len(a)):
		if a[x]==b[0]:
			c.append(x)
	for x in c:
		if a[x:]==b[:len(a)-x]:
			a=a+b[len(a)-x:]
			print(a)
			flag=1
			break
	if flag==0:
		print(a+b)
			
			
			
	


for _ in range(eval(input())):
	a,b,c=input(),input(),[]
	flag=0
	for x in range(len(a)):
		if a[x]==b[0]:
			c.append(x)
	for x in c:
		if a[x:]==b[:len(a)-x]:
			a=a+b[len(a)-x:]
			print(a)
			flag=1
			break
	if flag==0:
		print(a+b)
			
			
			
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t =  int(input())
for _ in range(t):
	str1= str(input())
	str2= str(input())
	i = len(str2)
	while i>0:
		if str2[:i] == str1[-i:]:
			break
		i-=1

	final = str1 +str2[i:]
	print(final)


times = int(input())

def solve(i):
	a = i[0]
	b = i[1]
	for x in range(len(a)):
		if a[x:] == b[0:((len(a))-x)]:
			return(a[0:x] + b)
	return(a+b)

l = []

for x in range(times):
	l.append([input(), input()])
	
for each in l:
	print((solve(each)))
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
from sys import stdin

T = int(stdin.readline().strip())
for case in range(T):
	s1 = stdin.readline().strip()
	s2 = stdin.readline().strip()
	l1 = len(s1)
	l2 = len(s2)
	lmin = min(l1, l2)
	for l in range(lmin, -1, -1):
		if s1[-l:]==s2[:l]:
			#print s1[-l:], s2[:l]
			break
	#print l
	print(s1+s2[l:] if l!=-1 else s1+s2)
		


from sys import stdin

T = int(stdin.readline().strip())
for case in range(T):
	s1 = stdin.readline().strip()
	s2 = stdin.readline().strip()
	l1 = len(s1)
	l2 = len(s2)
	lmin = min(l1, l2)
	i1 = l1-1
	cnt=0
	l = lmin
	while l>0:
		if s1[-l:]==s2[:l]:
			break
		l-=1
	print(s1+s2[l:])