for i in range(5):
    s1="".join(input().split()).upper()
    s2="".join(input().split()).upper()

    import re
    s1=re.sub('[^A-Z]','',s1)
    s2=re.sub('[^A-Z]','',s2)

    
    """
    import random  #测试代码
    a=list("abcdefghijklmnopqrstuvwxyz")  #测试代码
    s1=""  #测试代码
    for j in range(200):  #测试代码
        s1+=random.sample(a,1)[0]  #测试代码

    s2=""  #测试代码
    for j in range(200):  #测试代码
        s2+=random.sample(a,1)[0]  #测试代码
    import time  #测试代码
    t1=time.time()  #测试代码
    """
    
    def findint(s1,s2):
        big=1
        if len(s1) < len(s2):
            big=2
            s1,s2 = s2,s1
        maxstr = s1
        substr_maxlen = max(len(s1),len(s2))
        currentMaxStr=None
        currentMaxStrIndex=None
        for sublen in range(substr_maxlen,-1,-1):
            for i in range(substr_maxlen-sublen+1):
                if maxstr[i:i+sublen] in s2:
                    if currentMaxStr==None:
                        currentMaxStr=maxstr[i:i+sublen]
                        currentMaxStrIndex=(i,i+sublen)
                    else:
                        if len(maxstr[i:i+sublen])==len(currentMaxStr) and maxstr[i:i+sublen]