2565_1_Quiz_2_3

Max Score = 100


6532043021
# 1662738, 2022-10-29 10:07:29, xxxxx (0%)

s1 = input()
s2 = input()
color=[]
f = open(s1,'r')
while(1):
    a = f.readline.strip().split()
    if a=='':
        break
    
    for e in a:
        color.append(e.lower())

f.close

f = open(s2,'r')
while(1):
    a = f.readline
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
        if b.find(e)!=-1:
            pos.append(b.find(e))
            pos.append(b.find(e)+len(e)) 
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:pos[pos.index(i)+1]]+'>'
            first=0
        if((i in pos) and first==0):
            ans+='</>'
            first=1
        ans+=a[i]
    
    print(ans)
f.close()
# 1663046, 2022-10-29 10:15:41, xxxxx (0%)

#s1 = input()
#s2 = input()

s1 = '1.txt'
s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())

f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
        if b.find(e)!=-1:
            pos.append(b.find(e))
            pos.append(b.find(e)+len(e)) 
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:pos[pos.index(i)+1]]+'>'
            first=0
        elif((i in pos) and first==0):
            ans+='</>'
            first=1
        ans+=a[i]
    
    print(ans)
f.close()
# 1663070, 2022-10-29 10:16:02, P--x- (20%)

s1 = input()
s2 = input()

#s1 = '1.txt'
#s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())

f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
        if b.find(e)!=-1:
            pos.append(b.find(e))
            pos.append(b.find(e)+len(e)) 
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:pos[pos.index(i)+1]]+'>'
            first=0
        elif((i in pos) and first==0):
            ans+='</>'
            first=1
        ans+=a[i]
    
    print(ans)
f.close()
# 1663097, 2022-10-29 10:16:43, ---x- (0%)

s1 = input()
s2 = input()

#s1 = '1.txt'
#s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())

f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    a=a.strip()
    b = a.lower()
    for e in color:
        if b.find(e)!=-1:
            pos.append(b.find(e))
            pos.append(b.find(e)+len(e)) 
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:pos[pos.index(i)+1]]+'>'
            first=0
        elif((i in pos) and first==0):
            ans+='</>'
            first=1
        ans+=a[i]
    
    print(ans)
f.close()
# 1663129, 2022-10-29 10:17:47, P--x- (20%)

s1 = input()
s2 = input()

#s1 = '1.txt'
#s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())

f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
        if b.find(e)!=-1:
            pos.append(b.find(e))
            pos.append(b.find(e)+len(e)) 
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:pos[pos.index(i)+1]]+'>'
            first=0
        elif((i in pos) and first==0):
            ans+='</>'
            first=1
        ans+=a[i]
    if(len(a)+1 in pos):
        ans+='</>'
    print(ans)
f.close()
# 1663484, 2022-10-29 10:25:37, P-P-- (40%)

s1 = input()
s2 = input()

#s1 = '1.txt'
#s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())

f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
     #   if b.find(e)!=-1:
     ##       pos.append(b.find(e))
     #       pos.append(b.find(e)+len(e))

        x = -1
        while 1:
            x = b.find(e,x+1)
            if x==-1:
                break
            pos.append(x)
            pos.append(x+len(e))
            
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:pos[pos.index(i)+1]]+'>'
            first=0
        elif((i in pos) and first==0):
            ans+='</>'
            first=1
        ans+=a[i]
    if(len(a)+1 in pos):
        ans+='</>'
    print(ans)
f.close()
# 1664249, 2022-10-29 10:38:28, ----- (0%)

s1 = input()
s2 = input()

#s1 = '1.txt'
#s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())
print(color)
f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
     #   if b.find(e)!=-1:
     ##       pos.append(b.find(e))
     #       pos.append(b.find(e)+len(e))

        x = -1
        while 1:
            x = b.find(e,x+1)
            if x==-1:
                break
            pos.append(x)
            pos.append(x+len(e)-1)
            
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:(pos[pos.index(i)+1]+1):1]+'>'
            first=0
            ans+=a[i]
        elif(((i) in pos) and first==0):
            ans+=a[i]
            ans+='</>'
            first=1
        else:
            ans+=a[i]
    if(len(a)+1 in pos):
        ans+='</>'
    print(ans)
f.close()
# 1664271, 2022-10-29 10:38:39, P-P-- (40%)

s1 = input()
s2 = input()

#s1 = '1.txt'
#s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())

f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
     #   if b.find(e)!=-1:
     ##       pos.append(b.find(e))
     #       pos.append(b.find(e)+len(e))

        x = -1
        while 1:
            x = b.find(e,x+1)
            if x==-1:
                break
            pos.append(x)
            pos.append(x+len(e))
            
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:pos[pos.index(i)+1]]+'>'
            first=0
        elif((i in pos) and first==0):
            ans+='</>'
            first=1
        ans+=a[i]
    if(len(a)+1 in pos):
        ans+='</>'
    print(ans)
f.close()
# 1664327, 2022-10-29 10:39:09, PPPPP (100%)

s1 = input()
s2 = input()

#s1 = '1.txt'
#s2 = '2.txt'

color=[]
f = open(s1,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    #print(a)
    a = a.strip().split()
    for e in a:
        color.append(e.lower())
f.close

f = open(s2,'r')
while(1):
    a = f.readline()
    if a=='':
        break
    pos=[]
    ans=''
    b = a.lower()
    for e in color:
     #   if b.find(e)!=-1:
     ##       pos.append(b.find(e))
     #       pos.append(b.find(e)+len(e))

        x = -1
        while 1:
            x = b.find(e,x+1)
            if x==-1:
                break
            pos.append(x)
            pos.append(x+len(e)-1)
            
    first=1
    for i in range(len(a)):
        if((i in pos) and first==1):
            ans+= '<'+b[i:(pos[pos.index(i)+1]+1):1]+'>'
            first=0
            ans+=a[i]
        elif(((i) in pos) and first==0):
            ans+=a[i]
            ans+='</>'
            first=1
        else:
            ans+=a[i]
    if(len(a)+1 in pos):
        ans+='</>'
    print(ans)
f.close()

6532157921
# 1662529, 2022-10-29 10:00:46, --xxx (0%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split(' '):
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
# print(d)
f.close()

f = open(lyr, 'r')
ans = ""
for i in f:
    nj = -1
    for j in range(len(i)):
        if nj>j:
            continue
        if i[j].lower() not in d:
            ans += i[j]
            continue
        ch = 0
        for k in d[i[j].lower()]:
            if k.lower() == i[j:min(len(i)+1,j+len(k))].lower():
                ans+='<'+k+'>'+i[j:min(len(i)+1,j+len(k))]+'<\>'
                nj = min(len(i)+1,j+len(k))
                ch = 1
                break
        if ch == 0:
            ans+=i[j]

print(ans)



# 1662616, 2022-10-29 10:03:19, PPxxx (40%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split(' '):
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
# print(d)
f.close()

f = open(lyr, 'r')
ans = ""
for i in f:
    nj = -1
    for j in range(len(i)):
        if nj>j:
            continue
        if i[j].lower() not in d:
            ans += i[j]
            continue
        ch = 0
        for k in d[i[j].lower()]:
            if k.lower() == i[j:min(len(i)+1,j+len(k))].lower():
                ans+='<'+k+'>'+i[j:min(len(i)+1,j+len(k))]+'</>'
                nj = min(len(i)+1,j+len(k))
                ch = 1
                break
        if ch == 0:
            ans+=i[j]

print(ans)



# 1662734, 2022-10-29 10:07:19, PPxxx (40%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split(' '):
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
# print(d)
f.close()

f = open(lyr, 'r')
ans = ""
for i in f:
    nj = -1
    for j in range(len(i)):
        if nj>j:
            continue
        if i[j].lower() not in d:
            ans += i[j]
            continue
        ch = 0
        for k in d[i[j].lower()]:
            if j+len(k)<=len(i)+1 and k.lower() == i[j:j+len(k)].lower():
                ans+='<'+k+'>'+i[j:j+len(k)]+'</>'
                nj = j+len(k)
                ch = 1
                break
        if ch == 0:
            ans+=i[j]

print(ans)



# 1662754, 2022-10-29 10:07:54, PPxxx (40%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split(' '):
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
# print(d)
f.close()

f = open(lyr, 'r')
ans = ""
for i in f:
    nj = -1
    for j in range(len(i)):
        if nj>j:
            continue
        if i[j].lower() not in d:
            ans += i[j]
            continue
        ch = 0
        for k in d[i[j].lower()]:
            if j+len(k)<=len(i)+1 and k.lower() == i[j:j+len(k)].lower():
                ans+='<'+k+'>'+i[j:j+len(k)]+'</>'
                nj = j+len(k)
                ch = 1
                break
        if ch == 0:
            ans+=i[j]
f.close()

print(ans)
# 1662852, 2022-10-29 10:10:35, PPxxx (40%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split(' '):
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
# print(d)
f.close()

f = open(lyr, 'r')
ans = ""
for i in f:
    nj = -1
    for j in range(len(i)):
        if nj>j:
            continue
        if not i[j].lower().isalpha():
            ans+=i[j]
            continue
        if i[j].lower() not in d:
            ans += i[j]
            continue
        ch = 0
        for k in d[i[j].lower()]:
            if j+len(k)<=len(i)+1 and k.lower() == i[j:j+len(k)].lower():
                ans+='<'+k+'>'+i[j:j+len(k)]+'</>'
                nj = j+len(k)
                ch = 1
                break
        if ch == 0:
            ans+=i[j]
f.close()
print(ans)



# 1662870, 2022-10-29 10:10:59, --xxx (0%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split(' '):
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
# print(d)
f.close()

f = open(lyr, 'r')
ans = ""
f.close()
print(ans)
# 1662950, 2022-10-29 10:13:25, ----- (0%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split():
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
print(d)
f.close()

f = open(lyr, 'r')
ans = ""
for i in f:
    nj = -1
    for j in range(len(i)):
        if nj>j:
            continue
        if not i[j].lower().isalpha():
            ans+=i[j]
            continue
        if i[j].lower() not in d:
            ans += i[j]
            continue
        ch = 0
        for k in d[i[j].lower()]:
            if j+len(k)<=len(i)+1 and k.lower() == i[j:j+len(k)].lower():
                ans+='<'+k+'>'+i[j:j+len(k)]+'</>'
                nj = j+len(k)
                ch = 1
                break
        if ch == 0:
            ans+=i[j]
f.close()
print(ans)


# /Users/wasrek/Documents/Coding/comprog/2565_1_Quiz_2/colors.txt
# /Users/wasrek/Documents/Coding/comprog/2565_1_Quiz_2/text.txt
# 1662968, 2022-10-29 10:13:58, PPPPP (100%)

col = input().strip()
lyr = input().strip()
d = {}

f = open(col, 'r')
for i in f:
    for j in i.split():
        c = j.strip().lower()
        if c[0] in d:
            d[c[0]].append(c)
        else:
            d[c[0]]=[c]
# print(d)
f.close()

f = open(lyr, 'r')
ans = ""
for i in f:
    nj = -1
    for j in range(len(i)):
        if nj>j:
            continue
        if not i[j].lower().isalpha():
            ans+=i[j]
            continue
        if i[j].lower() not in d:
            ans += i[j]
            continue
        ch = 0
        for k in d[i[j].lower()]:
            if j+len(k)<=len(i)+1 and k.lower() == i[j:j+len(k)].lower():
                ans+='<'+k+'>'+i[j:j+len(k)]+'</>'
                nj = j+len(k)
                ch = 1
                break
        if ch == 0:
            ans+=i[j]
f.close()
print(ans)


# /Users/wasrek/Documents/Coding/comprog/2565_1_Quiz_2/colors.txt
# /Users/wasrek/Documents/Coding/comprog/2565_1_Quiz_2/text.txt

6532203021
# 1663131, 2022-10-29 10:17:50, ----- (0%)

color_filename = input()
song_filename = input()

color = []
f_color = open(color_filename, "r")
for line in f_color:
    line = line.split()
    for i in line:
        color.append(i.lower())
f_color.close()
print(color)

new_song = []
f_song = open(song_filename, "r")
for line in f_song:
    line = line.split()
    # line = line.replace(",", "")
    # line = line.replace(",", "")
    for i in range(len(line)):

        if line[i].lower() in color:
            line[i] = "<"+line[i].lower()+">" + line[i] + "</>" 

        # add_line = 
        # for st in range(len(line[i])):
        #     for ed in range(st+1, len(line[i])):
        #         if line[i][st:ed].lower() in color:
        #             line[i] = line[:st] + "<"+line[i][st:ed].lower()+">" + line[i][st:ed] + "</>" + line[ed:]
        #     add_line.append(line[i][st])
        
        # line[i] = add_line
        
    new_song.append(" ".join(line))

for i in new_song:
    print(i)
# 1663709, 2022-10-29 10:30:04, ----- (0%)

color_filename = input()
song_filename = input()

color = []
f_color = open(color_filename, "r")
for line in f_color:
    line = line.split()
    for i in line:
        color.append(i.lower())
f_color.close()
print(color)

new_song = []
f_song = open(song_filename, "r")
for line in f_song:
    line = line.split()
    # line = line.replace(",", "")
    # line = line.replace(",", "")
    for i in range(len(line)):
        for see in color:
            color_len = len(see)
            # idx = line[i].find(see)
            # line[i] = line[i][:idx] + "<>" + line[i][idx:idx+color_len] + "</>" + line[i][idx+color_len:]
            # print(line[i])
            for st in range(len(line[i])):
                if line[i][st:st+color_len].lower() == see:
                    line[i] = line[i][:st] + "<"+see[0]+"$"+see[1:]+">" + line[i][st:st+1]+"$"+line[i][st+1:st+color_len] + "</>" + line[i][st+color_len:]

        # if line[i].lower() in color:
        #     line[i] = "<"+line[i].lower()+">" + line[i] + "</>" 

        # add_line = []
        # for st in range(len(line[i])):
        #     for ed in range(st+1, len(line[i])):
        #         if line[i][st:ed].lower() in color:
        #             line[i] = line[i][:st] + "<"+line[i][st:ed].lower()+">" + line[i][st:ed] + "</>" + line[i][ed:]
        #     add_line.append(line[i][st])
        
        # line[i] = add_line
        line[i] = line[i].replace("$","")
        
    new_song.append(" ".join(line))

for i in new_song:
    print(i)
# 1663721, 2022-10-29 10:30:21, PP--- (40%)

color_filename = input()
song_filename = input()

color = []
f_color = open(color_filename, "r")
for line in f_color:
    line = line.split()
    for i in line:
        color.append(i.lower())
f_color.close()
# print(color)

new_song = []
f_song = open(song_filename, "r")
for line in f_song:
    line = line.split()
    # line = line.replace(",", "")
    # line = line.replace(",", "")
    for i in range(len(line)):
        for see in color:
            color_len = len(see)
            # idx = line[i].find(see)
            # line[i] = line[i][:idx] + "<>" + line[i][idx:idx+color_len] + "</>" + line[i][idx+color_len:]
            # print(line[i])
            for st in range(len(line[i])):
                if line[i][st:st+color_len].lower() == see:
                    line[i] = line[i][:st] + "<"+see[0]+"$"+see[1:]+">" + line[i][st:st+1]+"$"+line[i][st+1:st+color_len] + "</>" + line[i][st+color_len:]

        # if line[i].lower() in color:
        #     line[i] = "<"+line[i].lower()+">" + line[i] + "</>" 

        # add_line = []
        # for st in range(len(line[i])):
        #     for ed in range(st+1, len(line[i])):
        #         if line[i][st:ed].lower() in color:
        #             line[i] = line[i][:st] + "<"+line[i][st:ed].lower()+">" + line[i][st:ed] + "</>" + line[i][ed:]
        #     add_line.append(line[i][st])
        
        # line[i] = add_line
        line[i] = line[i].replace("$","")
        
    new_song.append(" ".join(line))

for i in new_song:
    print(i)
# 1663808, 2022-10-29 10:31:59, PP--- (40%)

color_filename = input()
song_filename = input()

color = []
f_color = open(color_filename, "r")
for line in f_color:
    line = line.split()
    for i in line:
        color.append(i.lower())
f_color.close()
# print(color)

new_song = []
f_song = open(song_filename, "r")
for line in f_song:
    line = line.split()
    # line = line.replace(",", "")
    # line = line.replace(",", "")
    for i in range(len(line)):
        for see in color:
            color_len = len(see)
            # idx = line[i].find(see)
            # line[i] = line[i][:idx] + "<>" + line[i][idx:idx+color_len] + "</>" + line[i][idx+color_len:]
            # print(line[i])
            for st in range(len(line[i])):
                if line[i][st:st+color_len].lower() == see:
                    line[i] = line[i][:st] + "<"+see[0]+"ก"+see[1:]+">" + line[i][st:st+1]+"ก"+line[i][st+1:st+color_len] + "</>" + line[i][st+color_len:]

        # if line[i].lower() in color:
        #     line[i] = "<"+line[i].lower()+">" + line[i] + "</>" 

        # add_line = []
        # for st in range(len(line[i])):
        #     for ed in range(st+1, len(line[i])):
        #         if line[i][st:ed].lower() in color:
        #             line[i] = line[i][:st] + "<"+line[i][st:ed].lower()+">" + line[i][st:ed] + "</>" + line[i][ed:]
        #     add_line.append(line[i][st])
        
        # line[i] = add_line
        line[i] = line[i].replace("ก","")
        
    new_song.append(" ".join(line))

for i in new_song:
    print(i)
# 1664414, 2022-10-29 10:39:57, xxxxx (0%)

color_filename = input()
song_filename = input()

color = []
f_color = open(color_filename, "r")
for line in f_color:
    line = line.split()
    for i in line:
        color.append(i.lower())
f_color.close()
# print(color)

new_song = []
f_song = open(song_filename, "r")
for line in f_song:
    line = line.split()
    # line = line.replace(",", "")
    # line = line.replace(",", "")
    for i in range(len(line)):
        for see in color:
            color_len = len(see)
            for k in range(100):
                for st in range(len(line[i])):
                    print(line[i],st)
                    if line[i][st:st+color_len].lower() == see:
                        line[i] = line[i][:st] + "<"+see[0]+"ก"+see[1:]+">" + line[i][st:st+1]+"ก"+line[i][st+1:st+color_len] + "</>" + line[i][st+color_len:]
                    

        # if line[i].lower() in color:
        #     line[i] = "<"+line[i].lower()+">" + line[i] + "</>" 

        # add_line = []
        # for st in range(len(line[i])):
        #     for ed in range(st+1, len(line[i])):
        #         if line[i][st:ed].lower() in color:
        #             line[i] = line[i][:st] + "<"+line[i][st:ed].lower()+">" + line[i][st:ed] + "</>" + line[i][ed:]
        #     add_line.append(line[i][st])
        
        # line[i] = add_line
        line[i] = line[i].replace("ก","")
        
    new_song.append(" ".join(line))

for i in new_song:
    print(i)
# 1664444, 2022-10-29 10:40:09, xxxxx (0%)

color_filename = input()
song_filename = input()

color = []
f_color = open(color_filename, "r")
for line in f_color:
    line = line.split()
    for i in line:
        color.append(i.lower())
f_color.close()
# print(color)

new_song = []
f_song = open(song_filename, "r")
for line in f_song:
    line = line.split()
    # line = line.replace(",", "")
    # line = line.replace(",", "")
    for i in range(len(line)):
        for see in color:
            color_len = len(see)
            for k in range(10):
                for st in range(len(line[i])):
                    print(line[i],st)
                    if line[i][st:st+color_len].lower() == see:
                        line[i] = line[i][:st] + "<"+see[0]+"ก"+see[1:]+">" + line[i][st:st+1]+"ก"+line[i][st+1:st+color_len] + "</>" + line[i][st+color_len:]
                    

        # if line[i].lower() in color:
        #     line[i] = "<"+line[i].lower()+">" + line[i] + "</>" 

        # add_line = []
        # for st in range(len(line[i])):
        #     for ed in range(st+1, len(line[i])):
        #         if line[i][st:ed].lower() in color:
        #             line[i] = line[i][:st] + "<"+line[i][st:ed].lower()+">" + line[i][st:ed] + "</>" + line[i][ed:]
        #     add_line.append(line[i][st])
        
        # line[i] = add_line
        line[i] = line[i].replace("ก","")
        
    new_song.append(" ".join(line))

for i in new_song:
    print(i)
# 1664481, 2022-10-29 10:40:28, PPPPP (100%)

color_filename = input()
song_filename = input()

color = []
f_color = open(color_filename, "r")
for line in f_color:
    line = line.split()
    for i in line:
        color.append(i.lower())
f_color.close()
# print(color)

new_song = []
f_song = open(song_filename, "r")
for line in f_song:
    line = line.split()
    # line = line.replace(",", "")
    # line = line.replace(",", "")
    for i in range(len(line)):
        for see in color:
            color_len = len(see)
            for k in range(10):
                for st in range(len(line[i])):
                    # print(line[i],st)
                    if line[i][st:st+color_len].lower() == see:
                        line[i] = line[i][:st] + "<"+see[0]+"ก"+see[1:]+">" + line[i][st:st+1]+"ก"+line[i][st+1:st+color_len] + "</>" + line[i][st+color_len:]
                    

        # if line[i].lower() in color:
        #     line[i] = "<"+line[i].lower()+">" + line[i] + "</>" 

        # add_line = []
        # for st in range(len(line[i])):
        #     for ed in range(st+1, len(line[i])):
        #         if line[i][st:ed].lower() in color:
        #             line[i] = line[i][:st] + "<"+line[i][st:ed].lower()+">" + line[i][st:ed] + "</>" + line[i][ed:]
        #     add_line.append(line[i][st])
        
        # line[i] = add_line
        line[i] = line[i].replace("ก","")
        
    new_song.append(" ".join(line))

for i in new_song:
    print(i)

6531333821
# 1662403, 2022-10-29 09:57:09, P---- (20%)

def CreateNewLine(line, colors):
    tempLine = line.lower().strip()
    line = line.strip()
    index = 0
    indexs = []
    for color in colors:
        i = tempLine.find(color, index)
        if (i != -1):
            indexs.append([i, i+len(color), color])
    newLine = ""
    for data in indexs:
        newLine += line[index:data[0]]
        newLine += '<'+data[2]+'>'+line[data[0]:data[1]]+"</>"
        index = data[1]
    newLine += line[index:]

    return newLine


color_file = input()  # q2_color.txt
text_file = input()  # q2_text.txt

in_color_file = open(color_file, "r")
line = in_color_file.readline()
colors = []
while (len(line) != 0):
    data = line.split()
    if (data != []):
        for color in data:
            colors.append(color.lower())
    line = in_color_file.readline()
in_color_file.close()

in_text_file = open(text_file, "r")
line = in_text_file.readline()
while (len(line) != 0):
    print(CreateNewLine(line, colors))
    line = in_text_file.readline()
in_text_file.close()
# 1662628, 2022-10-29 10:03:54, P---- (20%)

def CreateNewLine(line, colors):
    tempLine = line.lower().strip()
    line = line.strip()
    index = 0
    indexs = []
    for color in colors:
        i = tempLine.find(color, index)
        if (i != -1):
            indexs.append([i, i+len(color), color])
    index = 0
    newLine = ""
    indexs.sort()
    for data in indexs:
        newLine += line[index:data[0]]
        newLine += '<'+data[2]+'>'+line[data[0]:data[1]]+"</>"
        index = data[1]
    newLine += line[index:]

    return newLine


color_file = input()
text_file = input()

in_color_file = open(color_file, "r")
line = in_color_file.readline()
colors = []
while (len(line) != 0):
    data = line.split()
    if (data != []):
        for color in data:
            colors.append(color.lower())
    line = in_color_file.readline()
in_color_file.close()

in_text_file = open(text_file, "r")
line = in_text_file.readline()
while (len(line) != 0):
    print(CreateNewLine(line, colors))
    line = in_text_file.readline()
in_text_file.close()
# 1662682, 2022-10-29 10:05:36, P---- (20%)

def CreateNewLine(line, colors):
    tempLine = line.lower().strip()
    line = line.strip()
    index = 0
    indexs = []
    for color in colors:
        i = tempLine.find(color, index)
        if (i != -1):
            indexs.append([i, i+len(color), color])
    index = 0
    newLine = ""
    indexs.sort()
    for data in indexs:
        newLine += line[index:data[0]]
        newLine += '<'+data[2]+'>'+line[data[0]:data[1]]+"</>"
        index = data[1]
    newLine += line[index:]

    return newLine


color_file = input()
text_file = input()

in_color_file = open(color_file, "r")
line = in_color_file.readline()
colors = []
while (len(line) != 0):
    data = line.split()
    if (data != []):
        for color in data:
            colors.append(color.lower())
    line = in_color_file.readline()
in_color_file.close()

in_text_file = open(text_file, "r")
line = in_text_file.readline()
while (len(line) != 0):
    print(CreateNewLine(line, colors))
    line = in_text_file.readline()
in_text_file.close()
# 1662886, 2022-10-29 10:11:37, P---- (20%)

def CreateNewLine(line, colors):
    tempLine = line.lower().strip()
    line = line.strip()
    index = 0
    indexs = []
    for color in colors:
        i = tempLine.find(color, index)
        if (i != -1):
            indexs.append([i, i+len(color), color])
    newLine = ""
    indexs.sort()
    for data in indexs:
        newLine += line[index:data[0]]
        newLine += '<'+data[2]+'>'+line[data[0]:data[1]]+"</>"
        index = data[1]
    newLine += line[index:]

    return newLine


color_file = input().strip()
text_file = input().strip()

in_color_file = open(color_file, "r")
line = in_color_file.readline()
colors = []
while (len(line) != 0):
    data = line.split()
    if (data != []):
        for color in data:
            colors.append(color.lower())
    line = in_color_file.readline()
in_color_file.close()

in_text_file = open(text_file, "r")
line = in_text_file.readline()
newLines = []
while (len(line) != 0):
    newLines.append(CreateNewLine(line, colors))
    line = in_text_file.readline()
in_text_file.close()

for line in newLines:
    print(line)
# 1662998, 2022-10-29 10:14:35, PP--- (40%)

def CreateNewLine(line, colors):
    tempLine = line.lower().strip()
    line = line.strip()
    index = 0
    indexs = []
    for color in colors:
        i = tempLine.find(color, index)
        while (i != -1):
            indexs.append([i, i+len(color), color])
            index = i+len(color)
            i = tempLine.find(color, index)
    index = 0
    newLine = ""
    indexs.sort()
    for data in indexs:
        newLine += line[index:data[0]]
        newLine += '<'+data[2]+'>'+line[data[0]:data[1]]+"</>"
        index = data[1]
    newLine += line[index:]

    return newLine


color_file = input()  # q2_color.txt
text_file = input()  # q2_text.txt

in_color_file = open(color_file, "r")
line = in_color_file.readline()
colors = []
while (len(line) != 0):
    data = line.split()
    if (data != []):
        for color in data:
            colors.append(color.lower())
    line = in_color_file.readline()
in_color_file.close()

in_text_file = open(text_file, "r")
line = in_text_file.readline()
while (len(line) != 0):
    print(CreateNewLine(line, colors))
    line = in_text_file.readline()
in_text_file.close()
# 1663387, 2022-10-29 10:23:46, PPPPP (100%)

def CreateNewLine(line, colors):
    tempLine = line.lower().strip()
    line = line.strip()
    index = 0
    indexs = []
    for color in colors:
        i = tempLine.find(color, index)
        while (i != -1):
            indexs.append([i, i+len(color), color])
            index = i+len(color)
            i = tempLine.find(color, index)
        index = 0
    newLine = ""
    indexs.sort()
    for data in indexs:
        newLine += line[index:data[0]]
        newLine += '<'+data[2]+'>'+line[data[0]:data[1]]+"</>"
        index = data[1]
    newLine += line[index:]

    return newLine


color_file = input()
text_file = input()

in_color_file = open(color_file, "r")
line = in_color_file.readline()
colors = []
while (len(line) != 0):
    data = line.split()
    if (data != []):
        for color in data:
            colors.append(color.lower())
    line = in_color_file.readline()
in_color_file.close()

in_text_file = open(text_file, "r")
line = in_text_file.readline()
while (len(line) != 0):
    print(CreateNewLine(line, colors))
    line = in_text_file.readline()
in_text_file.close()

6532068721
# 1661924, 2022-10-29 09:41:17, P---- (20%)

colors_file = input()
lyrics_file = input()

colors = []
with open(colors_file) as f:
    for l in f:
        for token in l.split(" "):
            colors.append(token.lower().strip())


def solve(l: str):
    shadow_mistress_yuuko = l.lower().strip()

    to_substitute = []

    for color in colors:
        loc = shadow_mistress_yuuko.find(color)

        if loc >= 0:
            to_substitute.append([loc, color])

    to_substitute.sort()

    if len(to_substitute) == 0:
        return l

    built = l[:to_substitute[0][0]]

    for i, [loc, color] in enumerate(to_substitute):
        built += "<{}>{}</>".format(color,
                                    l
                                    [loc: loc + len(color)])

        if i < len(to_substitute) - 1:
            built += l[loc+len(color):to_substitute[i+1][0]]
        else:
            built += l[loc+len(color):]

    return built.strip()


with open(lyrics_file) as f:
    for l in f:
        print(solve(l))

# 1661977, 2022-10-29 09:43:14, P---- (20%)

colors_file = input()
lyrics_file = input()

colors = []
with open(colors_file) as f:
    for l in f:
        for token in l.split(" "):
            colors.append(token.lower().strip())

colors = list(filter(lambda x: len(x) > 0, colors))


def solve(l: str):
    shadow_mistress_yuuko = l.lower().strip()

    to_substitute = []

    for color in colors:
        loc = shadow_mistress_yuuko.find(color)

        if loc >= 0:
            to_substitute.append([loc, color])

    to_substitute.sort()

    if len(to_substitute) == 0:
        return l

    built = l[:to_substitute[0][0]]

    for i, [loc, color] in enumerate(to_substitute):
        built += "<{}>{}</>".format(color,
                                    l
                                    [loc: loc + len(color)])

        if i < len(to_substitute) - 1:
            built += l[loc+len(color):to_substitute[i+1][0]]
        else:
            built += l[loc+len(color):]

    return built.strip()


with open(lyrics_file) as f:
    for l in f:
        print(solve(l))

# 1661996, 2022-10-29 09:43:53, ----- (0%)

colors_file = input()
lyrics_file = input()

colors = []
with open(colors_file) as f:
    for l in f:
        for token in l.split(" "):
            colors.append(token.lower().strip())

colors = list(filter(lambda x: len(x) > 0, colors))


def solve(l: str):
    shadow_mistress_yuuko = l.lower()

    to_substitute = []

    for color in colors:
        loc = shadow_mistress_yuuko.find(color)

        if loc >= 0:
            to_substitute.append([loc, color])

    to_substitute.sort()

    if len(to_substitute) == 0:
        return l

    built = l[:to_substitute[0][0]]

    for i, [loc, color] in enumerate(to_substitute):
        built += "<{}>{}</>".format(color,
                                    l
                                    [loc: loc + len(color)])

        if i < len(to_substitute) - 1:
            built += l[loc+len(color):to_substitute[i+1][0]]
        else:
            built += l[loc+len(color):]

    return built


with open(lyrics_file) as f:
    for l in f:
        print(solve(l)[:-1])

# 1662001, 2022-10-29 09:44:05, ----- (0%)

colors_file = input()
lyrics_file = input()

colors = []
with open(colors_file) as f:
    for l in f:
        for token in l.split(" "):
            colors.append(token.lower().strip())

colors = list(filter(lambda x: len(x) > 0, colors))


def solve(l: str):
    shadow_mistress_yuuko = l.lower()

    to_substitute = []

    for color in colors:
        loc = shadow_mistress_yuuko.find(color)

        if loc >= 0:
            to_substitute.append([loc, color])

    to_substitute.sort()

    if len(to_substitute) == 0:
        return l

    built = l[:to_substitute[0][0]]

    for i, [loc, color] in enumerate(to_substitute):
        built += "<{}>{}</>".format(color,
                                    l
                                    [loc: loc + len(color)])

        if i < len(to_substitute) - 1:
            built += l[loc+len(color):to_substitute[i+1][0]]
        else:
            built += l[loc+len(color):]

    return built


with open(lyrics_file) as f:
    for l in f:
        print(solve(l[:-1]))

# 1662169, 2022-10-29 09:49:44, ----- (0%)

colors_file = input()
lyrics_file = input()

colors = []
with open(colors_file) as f:
    for l in f:
        for token in l.split(" "):
            colors.append(token.lower().strip())

colors = list(filter(lambda x: len(x) > 0, colors))


def solve(l: str):
    shadow_mistress_yuuko = l.lower()

    to_substitute = []

    for color in colors:
        loc = shadow_mistress_yuuko.find(color)

        while loc >= 0:
            to_substitute.append([loc, color])
            pos = shadow_mistress_yuuko[loc+1:].find(color)
            if pos < 0:
                break
            loc = pos + loc + 1

    to_substitute.sort()

    if len(to_substitute) == 0:
        return l

    built = l[:to_substitute[0][0]]

    for i, [loc, color] in enumerate(to_substitute):
        built += "<{}>{}</>".format(color,
                                    l
                                    [loc: loc + len(color)])

        if i < len(to_substitute) - 1:
            built += l[loc+len(color):to_substitute[i+1][0]]
        else:
            built += l[loc+len(color):]

    return built


with open(lyrics_file) as f:
    for l in f:
        print(solve(l[:-1]))

# 1662229, 2022-10-29 09:51:16, PPPPP (100%)

colors_file = input()
lyrics_file = input()

colors = []
with open(colors_file) as f:
    for l in f:
        for token in l.split(" "):
            colors.append(token.lower().strip())

colors = list(filter(lambda x: len(x) > 0, colors))


def solve(l: str):
    shadow_mistress_yuuko = l.lower()

    to_substitute = []

    for color in colors:
        loc = shadow_mistress_yuuko.find(color)

        while loc >= 0:
            to_substitute.append([loc, color])
            pos = shadow_mistress_yuuko[loc+1:].find(color)
            if pos < 0:
                break
            loc = pos + loc + 1

    to_substitute.sort()

    if len(to_substitute) == 0:
        return l

    built = l[:to_substitute[0][0]]

    for i, [loc, color] in enumerate(to_substitute):
        built += "<{}>{}</>".format(color,
                                    l
                                    [loc: loc + len(color)])

        if i < len(to_substitute) - 1:
            built += l[loc+len(color):to_substitute[i+1][0]]
        else:
            built += l[loc+len(color):]

    return built


with open(lyrics_file) as f:
    for l in f:
        print(solve(l.strip()).strip())


6530049421
# 1662735, 2022-10-29 10:07:20, PP--- (40%)

#QUIZ 2 p3
def color_tag(txt,colors):
    lw = txt.lower()
    front = ''
    back = ''
    for color in colors:
        if color in lw:
            start = lw.find(color)
            end = start + len(color)
            front = txt[:start]
            back = txt[end:]
            word = txt[start:end]
            output = front + "<" + color + ">" + word + "</>" + back
            return output
    return txt

fc = open(input(), "r")
fn = open(input(), "r")

# เก็บสี
list_colors = []
for line in fc:
    colors = line.split()
    for c in colors:
        list_colors.append(c.lower())
        
# แปลงข้อความ
for line in fn:
    words = line.split()
    for i in range(len(words)):
        words[i] = color_tag(words[i],list_colors)
    new_line = " ".join(words)
    print(new_line)
    

# 1663187, 2022-10-29 10:19:15, P---- (20%)

#QUIZ 2 p3
def color_tag(txt,colors):
    lw = txt.lower()
    front = ''
    back = ''
    for color in colors:
        if color in lw:
            start = lw.find(color)
            end = start + len(color)
            front = txt[:start]
            back = txt[end:]
            word = txt[start:end]
            txt = front + "<" + color + ">" + word + "</>" + back
            lw = txt.lower()
    return txt

fc = open(input())
fn = open(input())

# เก็บสี
list_colors = []
for line in fc:
    colors = line.split()
    for c in colors:
        list_colors.append(c.lower())
        
        
out = ''
for line in fn:
    out += color_tag(line,list_colors)
print(out)


# 1663196, 2022-10-29 10:19:28, PP--- (40%)

#QUIZ 2 p3
def color_tag(txt,colors):
    lw = txt.lower()
    front = ''
    back = ''
    for color in colors:
        if color in lw:
            start = lw.find(color)
            end = start + len(color)
            front = txt[:start]
            back = txt[end:]
            word = txt[start:end]
            output = front + "<" + color + ">" + word + "</>" + back
            return output
    return txt

fc = open(input(), "r")
fn = open(input(), "r")

# เก็บสี
list_colors = []
for line in fc:
    colors = line.split()
    for c in colors:
        list_colors.append(c.lower())
        
# แปลงข้อความ
for line in fn:
    words = line.split()
    for i in range(len(words)):
        words[i] = color_tag(words[i],list_colors)
    new_line = " ".join(words)
    print(new_line)

# 1663479, 2022-10-29 10:25:33, PPPPP (100%)

#QUIZ 2 p3
def color_tag(txt,colors):
    lw = txt.lower()
    front = ''
    back = ''
    for color in colors:
        if color in lw:
            i = 0
            while color in lw[i:]:
                start = lw.find(color,i)
                end = start + len(color)
                front = txt[:start]
                back = txt[end:]
                word = txt[start:end]
                txt = front + "<" + color + ">" + word + "</>" + back
                lw = txt.lower()
                i = len(front) + len(color) + len(word) + 4
    return txt


fc = open(input())
fn = open(input())

# เก็บสี
list_colors = []
for line in fc:
    colors = line.split()
    for c in colors:
        list_colors.append(c.lower())
fc.close()
        
out = ''
for line in fn:
    out += color_tag(line,list_colors)
print(out)
fn.close()

# 1663576, 2022-10-29 10:27:27, PPPPP (100%)

#QUIZ 2 p3
def color_tag(txt,colors):
    lw = txt.lower()
    front = ''
    back = ''
    for color in colors:
        if color in lw:
            i = 0
            while color in lw[i:]:
                start = lw.find(color,i)
                end = start + len(color)
                front = txt[:start]
                back = txt[end:]
                word = txt[start:end]
                txt = front + "<" + color + ">" + word + "</>" + back
                lw = txt.lower()
                i = len(front) + len(color) + len(word) + 4
    return txt

fc = open(input())
fn = open(input())

# เก็บสี
list_colors = []
for line in fc:
    colors = line.split()
    for c in colors:
        list_colors.append(c.lower())
fc.close()
        
out = ''
for line in fn:
    out += color_tag(line,list_colors)
print(out)
fn.close()

# Code by Kanisorn P.


6531339621
# 1662457, 2022-10-29 09:58:31, ----- (0%)

def tagWord(word):
    treatedWord = word.lower()
    for color in colorList:
        idx = treatedWord.find(color)
        if(idx != -1):
            word = word[:idx] + '<' + color + '>' + word[idx:idx+len(color)] + '</>' + word[idx+len(color):]
    return word


colorFile = open(input().strip())
songFile = open(input().strip())

colorList = colorFile.read().lower().split()
print(colorList)
colorFile.close()

songLine = songFile.readline()
while(len(songLine) != 0):
    songWords = songLine.split()
    # commit die
    for i in range(len(songWords)):
        songWords[i] = tagWord(songWords[i])
    print(' '.join(songWords))
    songLine = songFile.readline()

# 1662524, 2022-10-29 10:00:39, PP--- (40%)

def tagWord(word):
    treatedWord = word.lower()
    for color in colorList:
        idx = treatedWord.find(color)
        if(idx != -1):
            word = word[:idx] + '<' + color + '>' + word[idx:idx+len(color)] + '</>' + word[idx+len(color):]
    return word


colorFile = open(input().strip())
songFile = open(input().strip())

colorList = colorFile.read().lower().split()
colorFile.close()

songLine = songFile.readline()
while(len(songLine) != 0):
    songWords = songLine.split()
    # commit die
    for i in range(len(songWords)):
        songWords[i] = tagWord(songWords[i])
    print(' '.join(songWords))
    songLine = songFile.readline()

# 1663192, 2022-10-29 10:19:23, PP--- (40%)

def tagWord(word):
    treatedWord = word.lower()
    endidx = -1
    for color in colorList:
        idx = treatedWord.find(color)
        if(idx != -1):
            endidx = idx + 2*len(color) + 5
            break  # only tag one word.
    if(endidx == -1):
        return word
    return word[:idx] + '<' + color + '>' + word[idx:idx+len(color)] + '</>' + tagWord(word[idx+len(color):])


colorFile = open(input().strip())
songFile = open(input().strip())

colorList = colorFile.read().lower().split()
colorFile.close()

songLine = songFile.readline()
while(len(songLine) != 0):
    songWords = songLine.split()
    # commit die
    for i in range(len(songWords)):
        songWords[i] = tagWord(songWords[i])
    print(' '.join(songWords))
    songLine = songFile.readline()

# 1663401, 2022-10-29 10:24:01, P---- (20%)

def tagWord(word):
    treatedWord = word.lower()
    flag = False
    earlyIdx = len(word)
    for color in colorList:
        idx = treatedWord.find(color)
        if(idx != -1):
            flag = True
            if(earlyIdx > idx):
                earlyIdx = idx  # tag earliest idx of all colors.
    if(not flag):
        return word
    return word[:idx] + '<' + color + '>' + word[idx:idx+len(color)] + '</>' + tagWord(word[idx+len(color):])


colorFile = open(input().strip())
songFile = open(input().strip())

colorList = colorFile.read().lower().split()
colorFile.close()

songLine = songFile.readline()
while(len(songLine) != 0):
    songWords = songLine.split()
    # commit die
    for i in range(len(songWords)):
        songWords[i] = tagWord(songWords[i])
    print(' '.join(songWords))
    songLine = songFile.readline()
songFile.close()

# 1663975, 2022-10-29 10:34:43, PPPPP (100%)

def tagWord(word, color):
    treatedWord = word.lower()
    earlyIdx = len(word)
    idx = treatedWord.find(color)
    if(idx != -1):  # found
        if(earlyIdx > idx):
            earlyIdx = idx
    if(earlyIdx == len(word)):
        return word
    return word[:idx] + '<' + color + '>' + word[idx:idx+len(color)] + '</>' + tagWord(word[idx+len(color):], color)


colorFile = open(input().strip())
songFile = open(input().strip())

colorList = colorFile.read().lower().split()
colorFile.close()

songLine = songFile.readline()
while(len(songLine) != 0):
    songWords = songLine.split()
    # commit die
    for i in range(len(songWords)):
        for c in colorList:
            songWords[i] = tagWord(songWords[i], c)
    print(' '.join(songWords))
    songLine = songFile.readline()
songFile.close()


6531346021
# 1662443, 2022-10-29 09:58:16, PP--- (40%)

fn1=input()
fn2=input()
f1=open(fn1)
lc=[]
for x in f1:
    ll=x.strip().lower().split()
    lc+=ll
f2=open(fn2)
for i in f2:
    i=i.strip()
    st=''
    for j in i.split():
        for c in lc:
            if c in j.lower():
                n=j.lower().index(c)
                n2=n+len(c)
                j=j[:n]+'<'+c+'>'+j[n:n2]+'</>'+j[n2:]
        st=st+j+' '
    print(st)

# 1662822, 2022-10-29 10:09:34, P---- (20%)

fn1=input()
fn2=input()
f1=open(fn1)
lc=[]
for x in f1:
    ll=x.strip().lower().split()
    lc+=ll
#print(lc)
f2=open(fn2)
for i in f2:
    i=i.strip()
    #print(i)
    
    
    for c in set(lc):
        il=i.lower()
        if c in il:
            n=il.index(c)
            n2=n+len(c)
            #print(c,n,n2)
            i=i[:n]+'<'+c+'>'+i[n:n2]+'</>'+i[n2:]
    
    print(i)

# 1663412, 2022-10-29 10:24:10, PPPPP (100%)

fn1=input()
fn2=input()
f1=open(fn1)
lc=[]
for x in f1:
    ll=x.strip().lower().split()
    lc+=ll
#print(lc)
f2=open(fn2)
for i in f2:
    i=i.strip()
    #print(i)
    
    
    for c in set(lc):
        il=i.lower()
        if c in il:
            cc=il.count(c)
            ccc=0
            for j in range(cc):
                il=i.lower()
                n=il.index(c,ccc)
                n2=n+len(c)
                #print(j,n,n2,ccc)
                i=i[:n]+'<'+c+'>'+i[n:n2]+'</>'+i[n2:]
                ccc=n2+len(c)+5
    
    print(i)

# 1663535, 2022-10-29 10:26:40, compilation error (0%)

fn1=input()
fn2=input()
f1=open(fn1)
lc=[]
for x in f1:
    lc+==x.strip().lower().split()
    
#print(lc)
f2=open(fn2)
for i in f2:
    i=i.strip()
    #print(i)
    
    
    for c in set(lc):
        il=i.lower()
        if c in il:
            cc=il.count(c)
            ccc=0
            for j in range(cc):
                il=i.lower()
                n=il.index(c,ccc)
                n2=n+len(c)
                #print(j,n,n2,ccc)
                i=i[:n]+'<'+c+'>'+i[n:n2]+'</>'+i[n2:]
                ccc=n2+len(c)+5
    
    print(i)
# 1663548, 2022-10-29 10:26:48, PPPPP (100%)

fn1=input()
fn2=input()
f1=open(fn1)
lc=[]
for x in f1:
    lc+=x.strip().lower().split()
    
#print(lc)
f2=open(fn2)
for i in f2:
    i=i.strip()
    #print(i)
    
    
    for c in set(lc):
        il=i.lower()
        if c in il:
            cc=il.count(c)
            ccc=0
            for j in range(cc):
                il=i.lower()
                n=il.index(c,ccc)
                n2=n+len(c)
                #print(j,n,n2,ccc)
                i=i[:n]+'<'+c+'>'+i[n:n2]+'</>'+i[n2:]
                ccc=n2+len(c)+5
    
    print(i)

6532027021
# 1661887, 2022-10-29 09:40:06, compilation error (0%)

def addTag(c) :
    return f"<{c.lower()}>{c}</>"

fin_color = open(input())
fin_lyric = open(input())

color_list = []
for line in fin_color :
    tmp = line.strip().split()
    for c in tmp :
        color_list.append(c.lower())
        
for line in fin_lyric :
    line = line.strip()
    tmp = line.lower()
    for c in color_list :
        idx = 0
        while True :
            idx = tmp.find(c, idx)
            if idx == -1 :
                break

            tmp = tmp[:idx] + addTag(tmp[idx:idx + len(c)]) + tmp[idx + len(c):]
            line = line[:idx] + addTag(line[idx:idx + len(c)]) + line[idx + len(c):]
            idx += 2 * len(c)
    print(line)
# 1661913, 2022-10-29 09:40:53, compilation error (0%)

def addTag(c) :
    return f"<{c.lower()}>{c}</>"

fin_color = open(input(), 'r')
fin_lyric = open(input(), 'r')

color_list = []
for line in fin_color :
    tmp = line.strip().split()
    for c in tmp :
        color_list.append(c.lower())

for line in fin_lyric :
    line = line.strip()
    tmp = line.lower()
    for c in color_list :
        idx = 0
        while True :
            idx = tmp.find(c, idx)
            if idx == -1 :
                break

            tmp = tmp[:idx] + addTag(tmp[idx:idx + len(c)]) + tmp[idx + len(c):]
            line = line[:idx] + addTag(line[idx:idx + len(c)]) + line[idx + len(c):]
            idx += 2 * len(c)
    print(line)
# 1662032, 2022-10-29 09:45:09, compilation error (0%)

def addTag(c) :
    return f"<{c.lower()}>{c}</>"

fin_color = open(input().strip(), 'r')
fin_lyric = open(input().strip(), 'r')

color_list = []
for line in fin_color :
    tmp = line.strip().split()
    for c in tmp :
        color_list.append(c.lower())

for line in fin_lyric :
    line = line.strip()
    tmp = line.lower()
    for c in color_list :
        idx = 0
        while True :
            idx = tmp.find(c, idx)
            if idx == -1 :
                break

            tmp = tmp[:idx] + addTag(tmp[idx:idx + len(c)]) + tmp[idx + len(c):]
            line = line[:idx] + addTag(line[idx:idx + len(c)]) + line[idx + len(c):]
            idx += 2 * len(c)
    print(line)
# 1662037, 2022-10-29 09:45:16, compilation error (0%)

def addTag(c) :
    return f"<{c.lower()}>{c}</>"

fin_color = open(input().strip())
fin_lyric = open(input().strip())

color_list = []
for line in fin_color :
    tmp = line.strip().split()
    for c in tmp :
        color_list.append(c.lower())

for line in fin_lyric :
    line = line.strip()
    tmp = line.lower()
    for c in color_list :
        idx = 0
        while True :
            idx = tmp.find(c, idx)
            if idx == -1 :
                break

            tmp = tmp[:idx] + addTag(tmp[idx:idx + len(c)]) + tmp[idx + len(c):]
            line = line[:idx] + addTag(line[idx:idx + len(c)]) + line[idx + len(c):]
            idx += 2 * len(c)
    print(line)
# 1662059, 2022-10-29 09:46:00, PPPPP (100%)

def addTag(c) :
    return '<' + c.lower() + '>' + c + '</>'

fin_color = open(input().strip())
fin_lyric = open(input().strip())

color_list = []
for line in fin_color :
    tmp = line.strip().split()
    for c in tmp :
        color_list.append(c.lower())

for line in fin_lyric :
    line = line.strip()
    tmp = line.lower()
    for c in color_list :
        idx = 0
        while True :
            idx = tmp.find(c, idx)
            if idx == -1 :
                break

            tmp = tmp[:idx] + addTag(tmp[idx:idx + len(c)]) + tmp[idx + len(c):]
            line = line[:idx] + addTag(line[idx:idx + len(c)]) + line[idx + len(c):]
            idx += 2 * len(c)
    print(line)

6530059721
# 1663251, 2022-10-29 10:20:50, xxxxx (0%)

#si.txt plang.txt
si,plang = input().strip().split()

fn_si = open(si,"r")
dic_si = {}
for line in fn_si:
    for s in line.lower().split():
        dic_si[s] = 0
fn_si.close()

fn_p = open(plang,"r")
ans = ""
for line in fn_p:
    word = ""
    for ch in line:
        if "a"<=ch.lower()<="z":
            word+=ch
            if word.lower() in dic_si:
                ans += "<"+word.lower()+">"+word+"</>"
                word = ""
            
        else:
            if word!="":
                ans+=word
                word=""
            ans+=ch
                
fn_p.close()
print(ans)



# 1663634, 2022-10-29 10:28:26, xxxxx (0%)

#si.txt plang.txt
si,plang = input().strip().split()

fn_si = open(si,"r")
dic_si = {}
for line in fn_si:
    for s in line.lower().split():
        dic_si[s] = len(s)
fn_si.close()

fn_p = open(plang,"r")
ans = ""
for line in fn_p:
    word = ""
    for ch in line:
        if "a"<=ch.lower()<="z":
            word+=ch

            if word.lower() in dic_si:
                ans += "<"+word.lower()+">"+word+"</>"
                word = ""            
        else:
            for i in range(len(word)):
                if word[i::] in dic_si:
                   ans += word[:i:]+"<"+word[i::].lower()+">"+word[i::]+"</>"
                   word = ""
                   break
            
            if word!="":
                ans+=word
                word=""
            ans+=ch
                
fn_p.close()
print(ans)



# 1663688, 2022-10-29 10:29:39, xxxxx (0%)

#si plang
si,plang = input().strip().split()

fn_si = open(si+".txt","r")
dic_si = {}
for line in fn_si:
    for s in line.lower().split():
        dic_si[s] = len(s)
fn_si.close()

fn_p = open(plang+".txt","r")
ans = ""
for line in fn_p:
    word = ""
    for ch in line:
        if "a"<=ch.lower()<="z":
            word+=ch

            if word.lower() in dic_si:
                ans += "<"+word.lower()+">"+word+"</>"
                word = ""            
        else:
            for i in range(len(word)):
                if word[i::] in dic_si:
                   ans += word[:i:]+"<"+word[i::].lower()+">"+word[i::]+"</>"
                   word = ""
                   break
            
            if word!="":
                ans+=word
                word=""
            ans+=ch
                
fn_p.close()
print(ans)



# 1663752, 2022-10-29 10:30:47, PPPPP (100%)

#si plang
si = input().strip()
plang = input().strip()

fn_si = open(si,"r")
dic_si = {}
for line in fn_si:
    for s in line.lower().split():
        dic_si[s] = len(s)
fn_si.close()

fn_p = open(plang,"r")
ans = ""
for line in fn_p:
    word = ""
    for ch in line:
        if "a"<=ch.lower()<="z":
            word+=ch

            if word.lower() in dic_si:
                ans += "<"+word.lower()+">"+word+"</>"
                word = ""            
        else:
            for i in range(len(word)):
                if word[i::] in dic_si:
                   ans += word[:i:]+"<"+word[i::].lower()+">"+word[i::]+"</>"
                   word = ""
                   break
            
            if word!="":
                ans+=word
                word=""
            ans+=ch
                
fn_p.close()
print(ans)




6531337321
# 1662666, 2022-10-29 10:05:08, PP--- (40%)

def is_color(word, colors):
    for color in colors:
        i = word.lower().find(color)
        if i != -1:
            return word[:i], word[i:i+len(color)], word[i+len(color):]
    return '', '', ''


color_path = input()
song_path = input()

colors = []
with open(color_path) as f:
    for line in f:
        colors.extend(line.rstrip().lower().split())

with open(song_path) as f:
    for line in f:
        ans = ''
        for word in line.rstrip().split():
            before, color, after = is_color(word, colors)
            if color:
                ans += '{}<{}>{}</>{} '.format(before, color.lower(), color, after)
            else:
                ans += word + ' '
        print(ans.rstrip())
            
# 1662808, 2022-10-29 10:09:16, PP--- (40%)

def is_color(word, colors):
    for color in colors:
        i = word.lower().find(color)
        if i != -1:
            return word[:i], word[i:i+len(color)], word[i+len(color):]
    return '', '', ''


color_path = input().strip()
song_path = input().strip()

colors = []
with open(color_path) as f:
    for line in f:
        colors.extend(line.strip().lower().split())

with open(song_path) as f:
    for line in f:
        ans = ''
        for word in line.rstrip().split():
            before, color, after = is_color(word, colors)
            if color:
                ans += '{}<{}>{}</>{} '.format(before, color.lower(), color, after)
            else:
                ans += word + ' '
        print(ans.rstrip())
            
# 1663607, 2022-10-29 10:28:01, PPPPP (100%)

def is_color(word, colors):
    # for color in colors:
    #     i = word.lower().find(color)
    #     if i != -1:
    #         return word[:i], word[i:i+len(color)], word[i+len(color):]
    # return '', '', word
    found = []
    for color in colors:
        if color in word.lower():
            found.append([word.lower().find(color), color])

    try:
        i, color = sorted(found)[0]
        if i != -1:
            return word[:i], word[i:i+len(color)], word[i+len(color):]
    except:
        pass

    return '', '', word


color_path = input().strip()
song_path = input().strip()

colors = []
with open(color_path) as f:
    for line in f:
        colors.extend(line.strip().lower().split())

with open(song_path) as f:
    # for line in f:
    #     ans = ''
    #     for word in line.rstrip().split():
    #         before, color, after = is_color(word, colors)
    #         if color:
    #             ans += '{}<{}>{}</>{} '.format(before, color.lower(), color, after)
    #         else:
    #             ans += word + ' '
    #     print(ans.rstrip())

    for line in f:
        line = line.rstrip()

        ans = ''
        while True:
            res = is_color(line, colors)
            if not res[1]:
                break

            ans += '{}<{}>{}</>'.format(res[0], res[1].lower(), res[1], res[2])
            line = res[2]

        print((ans+res[2]).rstrip())
            
# 1663655, 2022-10-29 10:28:56, PPPPP (100%)

def is_color(word, colors):
    found = []
    for color in colors:
        if color in word.lower():
            found.append([word.lower().find(color), color])

    try:
        i, color = sorted(found)[0]
        if i != -1:
            return word[:i], word[i:i+len(color)], word[i+len(color):]
    except:
        pass

    return '', '', word


color_path = input().strip()
song_path = input().strip()

colors = []
with open(color_path) as f:
    for line in f:
        colors.extend(line.strip().lower().split())

with open(song_path) as f:
    for line in f:
        line = line.rstrip()

        ans = ''
        while True:
            res = is_color(line, colors)
            if not res[1]:
                break

            ans += '{}<{}>{}</>'.format(res[0], res[1].lower(), res[1], res[2])
            line = res[2]

        print((ans+res[2]).rstrip())
            

6532082421
# 1662814, 2022-10-29 10:09:22, PPP-- (60%)

colors = open(input().strip(), 'r')
song = open(input().strip(), 'r')
colors = ''.join(colors.readlines()).split()
colors = [e.lower() for e in colors]
song = "".join(song.readlines())

for color in colors:
    idx = song.lower().find(color)
    while (idx != -1):
        add = "<" + color + ">" + song[idx:idx+len(color)] + "</>"
        song = song[:idx] + add + song[idx+len(color):]
        idx = song.lower().find(color, idx+len(add)+1)
print(song)

# 1662855, 2022-10-29 10:10:37, ----- (0%)

# colors = open(input().strip(), 'r')
# song = open(input().strip(), 'r')
# colors = ''.join(colors.readlines()).split()
# colors = [e.lower() for e in colors]
# song = "".join(song.readlines())

# for color in colors:
#     idx = song.lower().find(color)
#     while (idx != -1):
#         add = "<" + color + ">" + song[idx:idx+len(color)] + "</>"
#         song = song[:idx] + add + song[idx+len(color):]
#         idx = song.lower().find(color, idx+len(add)+1)
# print(song)
colors = open(input().strip(), 'r')
song = open(input().strip(), 'r')
colors = ''.join(colors.readlines()).split()
colors = [e.lower() for e in colors]
song = "".join(song.readlines())

for color in colors:
    idx = song.lower().find(color)
    if (idx == -1):
        continue
    add = "<" + color + ">" + song[idx:idx+len(color)] + "</>"
    song = song[:idx] + add + song[idx+len(color):]
    # idx = song.lower().find(color, idx+len(add)+1)
print(song)

# 1662866, 2022-10-29 10:10:47, PPP-- (60%)

colors = open(input().strip(), 'r')
song = open(input().strip(), 'r')
colors = ''.join(colors.readlines()).split()
colors = [e.lower() for e in colors]
song = "".join(song.readlines())

for color in colors:
    idx = song.lower().find(color)
    while (idx != -1):
        add = "<" + color + ">" + song[idx:idx+len(color)] + "</>"
        song = song[:idx] + add + song[idx+len(color):]
        idx = song.lower().find(color, idx+len(add)+1)
print(song)
# 1662899, 2022-10-29 10:12:05, PPPPP (100%)

colors = open(input().strip(), 'r')
song = open(input().strip(), 'r')
colors = ''.join(colors.readlines()).split()
colors = [e.lower() for e in colors]
song = "".join(song.readlines())

for color in colors:
    idx = song.lower().find(color)
    while (idx != -1):
        add = "<" + color + ">" + song[idx:idx+len(color)] + "</>"
        song = song[:idx] + add + song[idx+len(color):]
        idx = song.lower().find(color, idx+len(add))
print(song)


6530112221
# 1662224, 2022-10-29 09:51:06, xxxxx (0%)

color_fn = input()
lyric_fn = input()

file = open(color_fn, 'r')
color_list = []
for i in file:
    for color in i.split():
        color_list.append(color)
        
file.close()

file.open(lyric_fn, 'r')
for i in file:
    pointer = 0
    new = ''
    while pointer < len(i):
        for color in color_list:
            if i[pointer : pointer + len(color)].lower() == color.lower():
                new += '<' + color.lower() + i[pointer : pointer + len(color)] + '</>'
                pointer += len(color)
                
            else:
                new += i[pointer]
                pointer += 1
    print(new)            

        
    

# 1663996, 2022-10-29 10:35:05, ----- (0%)

color_fn = input()
lyric_fn = input()

file = open(color_fn)
color_list = []
for i in file:
    for color in i.split():
        color_list.append(color)
        
file.close()

file = open(lyric_fn)
for i in file:
    pointer = 0
    new = ''
    found = False
    while pointer < len(i):
        for color in color_list:
            
            if i[pointer : pointer + len(color)].lower() == color.lower():
                new += '<' + color.lower() + '>' + i[pointer : pointer + len(color)] + '</>'
                pointer += len(color)
                found = True
                
                break
            found = False
            
        if not found:
            new += i[pointer]
            pointer += 1
    print(new[:-1])
            
    
            
        
            

        
    

# 1664267, 2022-10-29 10:38:37, PPPPP (100%)

color_fn = input()
lyric_fn = input()

file = open(color_fn)
color_list = []
for i in file:
    for color in i.split():
        color_list.append(color)
        
file.close()

file = open(lyric_fn)
for i in file:
    pointer = 0
    new = ''
    found = False
    while pointer < len(i):
        for color in color_list:
            
            if i[pointer : pointer + len(color)].lower() == color.lower():
                new += '<' + color.lower() + '>' + i[pointer : pointer + len(color)] + '</>'
                pointer += len(color)
                found = True
                
                break
            found = False
            
        if not found:
            new += i[pointer]
            pointer += 1
    
    printed = new
    if i[-1] == '\n':
        printed = new[:-1]
    print(printed)
            
    
            
        
            

        
    


6530141421
# 1661775, 2022-10-29 09:36:03, P---- (20%)

color = input()
song = input()
color_list = list()
ans = ""
file_color = open(color, "r")
for line in file_color:
    x = line.split()
    for e in x:
        color_list.append(e.lower())
file_song = open(song,"r")
for line in file_song:
    for color in color_list:
        line_low = line.lower()
        i = line_low.find(color)
        while i != -1:
            line = line[:i] + "<"+color+">"+line[i:i+len(color)]+"</>"+line[i+len(color):]
            i0 = i + len(color) + 2
            i = line_low.find(color,i0)
    ans += line
print(ans)
# 1661876, 2022-10-29 09:39:41, P---- (20%)

color = input()
song = input()
color_list = list()
ans = ""
file_color = open(color, "r")
for line in file_color:
    x = line.split()
    for e in x:
        color_list.append(e.lower())
file_song = open(song,"r")
for line in file_song:
    for color in color_list:
        line_low = line.lower()
        i = line_low.find(color)
        while i != -1:
            line = line[:i] + "<"+color+">"+line[i:i+len(color)]+"</>"+line[i+len(color):]
            i0 = i + len(color) + 5
            i = line_low.find(color,i0)
    ans += line
print(ans)
# 1662851, 2022-10-29 10:10:33, PPPPP (100%)

color = input()
song = input()
color_list = list()
ans = ""
file_color = open(color, "r")
for line in file_color:
    x = line.split()
    for e in x:
        color_list.append(e.lower())
file_song = open(song,"r")
for line in file_song:
    for color in color_list:
        line_low = line.lower()
        i = line_low.find(color)
        while i != -1:
            line = line[:i] + "<"+color+">"+line[i:i+len(color)]+"</>"+line[i+len(color):]
            line_low = line_low[:i] + "<"+color+">"+line_low[i:i+len(color)]+"</>"+line_low[i+len(color):]
            i0 = i + len(color)*2 + 4
            i = line_low.find(color,i0)
    ans += line
print(ans)

6530162621
# 1662029, 2022-10-29 09:45:07, PPPP- (80%)

# 2565_1_Quiz_2_3

colorFilename = input()
lyricsFilename = input()

colorFile = open(colorFilename)
lyricsFile = open(lyricsFilename)

color = []
for ln in colorFile:
    for e in ln.strip().split():
        color.append(e.lower())
        
lyrics = lyricsFile.read()     
for e in color:
    i = lyrics.find(e)
    while i != -1:
        lyrics = lyrics[:i] + '<'+e+'>' + lyrics[i:i+len(e)] + '</>' + lyrics[i+len(e):]
        i = lyrics.find(e,i+len(e)*2+5)
        
print(lyrics)

# 1662152, 2022-10-29 09:49:11, ----- (0%)

# 2565_1_Quiz_2_3

colorFilename = input()
lyricsFilename = input()

colorFile = open(colorFilename)
lyricsFile = open(lyricsFilename)

color = []
for ln in colorFile:
    for e in ln.strip().split():
        color.append(e.lower())
print(color)
lyrics = lyricsFile.read()     
for e in color:
    i = lyrics.lower().find(e)
    while i != -1:
        lyrics = lyrics[:i] + '<'+e+'>' + lyrics[i:i+len(e)] + '</>' + lyrics[i+len(e):]
        i = lyrics.lower().find(e,i+len(e)*2+5)
        
print(lyrics)

# 1662168, 2022-10-29 09:49:36, PPPPP (100%)

# 2565_1_Quiz_2_3

colorFilename = input()
lyricsFilename = input()

colorFile = open(colorFilename)
lyricsFile = open(lyricsFilename)

color = []
for ln in colorFile:
    for e in ln.strip().split():
        color.append(e.lower())

lyrics = lyricsFile.read()     
for e in color:
    i = lyrics.lower().find(e)
    while i != -1:
        lyrics = lyrics[:i] + '<'+e+'>' + lyrics[i:i+len(e)] + '</>' + lyrics[i+len(e):]
        i = lyrics.lower().find(e,i+len(e)*2+5)
        
print(lyrics)

6531313221
# 1662892, 2022-10-29 10:11:52, P-PPP (80%)

color_name = input()
file_name = input()
list_color = []
f = open(color_name, 'r')
for line in f.readlines():
    for color in line.strip().split():
        list_color += [color.lower()]
f.close()
f2 = open(file_name, 'r')

for line in f2.readlines():
    i = 0
    while i < len(line):
        have = 0
        for j in range(i, len(line)):
            now = line[i:j]
            if now.lower() in list_color:
                have = 1
                break
        if have:
            print('<' + now.lower() + '>', end='')
            print(now, end='')
            print('</>', end='')
            i = j-1
        else:
            print(line[i], end='')
        i += 1

f2.close()

# 1663075, 2022-10-29 10:16:15, ----- (0%)

color_name = input()
file_name = input()
list_color = []
f = open(color_name, 'r')
for line in f.readlines():
    for color in line.strip().split():
        list_color += [color.lower()]
f.close()
f2 = open(file_name, 'r')

for line in f2.readlines():
    i = 0
    while i < len(line):
        have = 0
        for j in range(i, len(line)):
            now = line[i:j+1]
            if now.lower() in list_color:
                have = 1
                break
        if have:
            print('<' + now.lower() + '>' + now + '</>', end='')
            i = j-1
        else:
            print(line[i], end='')
        i += 1
f2.close()

# 1663154, 2022-10-29 10:18:28, PPPPP (100%)

color_name = input()
file_name = input()
list_color = []
f = open(color_name, 'r')
for line in f.readlines():
    for color in line.strip().split():
        list_color += [color.lower()]
f.close()
f2 = open(file_name, 'r')

for line in f2.readlines():
    i = 0
    while i < len(line):
        have = 0
        for j in range(i, len(line)+1):

            now = line[i:j]
            if now.lower() in list_color:
                have = 1
                break
        if have:
            print('<' + now.lower() + '>' + now + '</>', end='')
            i = j-1
        else:
            print(line[i], end='')
        i += 1
f2.close()


6531347621
# 1662073, 2022-10-29 09:46:20, PPPPP (100%)

def colorset(colorf):
    set_color = set()
    for line in colorf:
        colors = line.lower().split()
        for color in colors:
            set_color.add(color)
    return set_color

def tagcolor(line, set_color):
    
    for color in set_color:
        if color in line.lower():
            pos1 = 0
            while True:
                pos2 = line.lower().find(color,pos1)
                if pos2 == -1:
                    break
                line = line[:pos2] + '<' + color +'>' + line[pos2:pos2+len(color)] + '</>' + line[pos2+len(color):]
                pos1 = pos2 + len('<' + color +'>') + len('</>')
    return line

colorpath = input()

lyricspath = input()

colorf = open(colorpath,"r")
lyricsf = open(lyricspath,"r")
set_color = colorset(colorf)
#print(set_color)

for line in lyricsf:
    print(tagcolor(line,set_color))


colorf.close()
lyricsf.close()
# 1662982, 2022-10-29 10:14:12, PPPPP (100%)

def colorset(colorf):
    set_color = set()
    for line in colorf:
        colors = line.lower().split()
        for color in colors:
            set_color.add(color)
    return set_color

def tagcolor(line, set_color):
    
    for color in set_color:
        if color in line.lower():
            pos1 = 0
            while True:
                pos2 = line.lower().find(color,pos1)
                if pos2 == -1:
                    break
                line = line[:pos2] + '<' + color +'>' + line[pos2:pos2+len(color)] + '</>' + line[pos2+len(color):]
                pos1 = pos2 + len('<' + color +'>') + len('</>')
    return line

colorpath = input()

lyricspath = input()

colorf = open(colorpath,"r")
lyricsf = open(lyricspath,"r")
set_color = colorset(colorf)

for line in lyricsf:
    print(tagcolor(line,set_color))

colorf.close()
lyricsf.close()
# 1663005, 2022-10-29 10:14:42, PPPPP (100%)

def colorset(colorf):
    set_color = set()
    for line in colorf:
        colors = line.lower().split()
        for color in colors:
            set_color.add(color)
    return set_color

def tagcolor(line, set_color):
    for color in set_color:
        if color in line.lower():
            pos1 = 0
            while True:
                pos2 = line.lower().find(color,pos1)
                if pos2 == -1:
                    break
                line = line[:pos2] + '<' + color +'>' + line[pos2:pos2+len(color)] + '</>' + line[pos2+len(color):]
                pos1 = pos2 + len('<' + color +'>') + len('</>')
    return line

colorpath = input()
lyricspath = input()

colorf = open(colorpath,"r")
lyricsf = open(lyricspath,"r")
set_color = colorset(colorf)

for line in lyricsf:
    print(tagcolor(line,set_color))

colorf.close()
lyricsf.close()

6530007021
# 1663660, 2022-10-29 10:29:01, PP--- (40%)

color = input()
song = input()
col = open(color,'r')
ly = open(song,'r')
allc = []
for i in col:
    i = i.split()
    allc += i
for i in range(len(allc)):
    allc[i] = allc[i].lower() #list สี
for i in ly:
    word = ''
    tot = ''
    me = i.split()
    for k in me:
        word = ''
        for j in range(len(k)):
            word += k[j]
            if word.lower() in allc:
                tot += '<'+word.lower()+'>'+word+'</>'
                word = ''
        tot += word+' '
    print(tot.strip())
# 1664279, 2022-10-29 10:38:45, PPPPP (100%)

color = input()
song = input()
col = open(color,'r')
ly = open(song,'r')
allc = []
for i in col:
    i = i.split()
    allc += i
for i in range(len(allc)):
    allc[i] = allc[i].lower() #list สี
for i in ly:
    word = ''
    tot = ''
    me = i.split()
    for k in me:
        word = ''
        for j in range(len(k)):
            word += k[j]
            for e in range(len(word)):
                new = word[e:]
                old = word[:e]
                if new.lower() in allc:
                    tot += old+'<'+new.lower()+'>'+new+'</>'
                    word = ''
        tot += word+' '
    if tot == '/n':
        print(tot)
    else:
        print(tot.strip())

6530014421
# 1663620, 2022-10-29 10:28:08, PPPPP (100%)

cf=input().strip()
lf=input().strip()
a=open(cf)
b=open(lf)
color=[]
for i in a:
    y=i.strip().lower()
    if len(y)!=0:
        x=y.split()
        color+=x
for l in b:
    y=l.strip()
    yy=y.lower()
    for k in color:
        if k in yy:
            n=yy.find(k)
            nn=len(k)
            while n!=-1:
                y=y[:n]+'<'+k+'>'+y[n:n+nn]+'</>'+y[n+nn:]
                yy=y.lower()
                n=yy.find(k,n+nn+nn)
    print(y)


# 1664158, 2022-10-29 10:37:25, PPPPP (100%)

cf=input().strip()
lf=input().strip()
a=open(cf)
b=open(lf)
color=[]
for i in a:
    y=i.strip().lower()
    if len(y)!=0:
        x=y.split()
        color+=x
for l in b:
    y=l.strip()
    yy=y.lower()
    for k in color:
        if k in yy:
            n=yy.find(k)
            nn=len(k)
            while n!=-1:
                y=y[:n]+'<'+k+'>'+y[n:n+nn]+'</>'+y[n+nn:]
                yy=y.lower()
                n=yy.find(k,n+nn+nn)
    print(y)
a.close()
b.close()

6530015021
# 1663446, 2022-10-29 10:24:55, P---- (20%)

#colors.txt
#lyrics.txt

color_file = input().strip()
lyrics_file = input().strip()

op1 = open(color_file)
colors = []
for line in op1:
    #print(line)
    line = line.lower()
    colors += line.strip().split() #in case that there are only diff colors!!
op1.close()

op2 = open(lyrics_file)
#print(colors)
for line in op2:
    line = line.strip()
    #print(line.lower())
    id_c = []
    a = 0
    f = line.lower().find(colors[a])
    while True:
        #print(colors[a],a)
        #start,stop,name
        if f == -1:
            a+=1
            if a==len(colors):break
        else:
            id_c.append([f,f+len(colors[a]),colors[a]])
        f = line.lower().find(colors[a],f+len(colors[a]))
    id_c.sort()
    #print(id_c)
    
    st = ''
    if len(id_c) != 0: #if there are any color(s) in line
        if id_c[0][0] != 0: #not start at begin
            st += line[:id_c[0][0]]
        
        for i in range(len(id_c)):
            start = id_c[i][0]
            stop = id_c[i][1]
            tag = id_c[i][2]
            if i != len(id_c)-1:
                next_start = id_c[i+1][0]
                st += '<'+tag+'>'+line[start:stop]+'</>'+line[stop:next_start]
            else:
                st += '<'+tag+'>'+line[start:stop]+'</>'+line[stop:]
    else:
        st = line
    print(st)
op2.close()

# 1663928, 2022-10-29 10:34:01, PPPPP (100%)

#colors.txt
#lyrics.txt

color_file = input().strip()
lyrics_file = input().strip()

op1 = open(color_file)
colors = []
for line in op1:
    #print(line)
    line = line.lower()
    colors += line.strip().split() #in case that there are only diff colors!!
op1.close()

op2 = open(lyrics_file)
#print(colors)
for line in op2:
    line = line.strip()
    #print(line.lower())
    id_c = []
    a = 0
    f = line.lower().find(colors[a])
    while True:
        #print(colors[a],a,f)
        #start,stop,name
        if f == -1:
            a+=1
            if a==len(colors):break
            f = line.lower().find(colors[a]) 
        else:
            id_c.append([f,f+len(colors[a]),colors[a]])
            f = line.lower().find(colors[a],f+len(colors[a]))
    id_c.sort()
    #print(id_c)
    
    st = ''
    if len(id_c) != 0: #if there are any color(s) in line
        if id_c[0][0] != 0: #not start at begin
            st += line[:id_c[0][0]]
        
        for i in range(len(id_c)):
            start = id_c[i][0]
            stop = id_c[i][1]
            tag = id_c[i][2]
            if i != len(id_c)-1:
                next_start = id_c[i+1][0]
                st += '<'+tag+'>'+line[start:stop]+'</>'+line[stop:next_start]
            else:
                st += '<'+tag+'>'+line[start:stop]+'</>'+line[stop:]
    else:
        st = line
    print(st)
op2.close()


6530097521
# 1662702, 2022-10-29 10:06:12, -P--- (20%)

color = input()
song = input()

finc = open(color, "r")
fins = open(song, "r")
c = []
for linec in finc:
    if len(linec) > 1:
        c += linec.lower().split()
    
sen = ""

for lines in fins:
    sen += lines
    
senn = ""
new = ""
for i in sen:
    senn += i
    for co in c:
        if co in senn.lower():
            new += senn[:senn.lower().find(co)] + "<" + co + ">" + senn[senn.lower().find(co):] + "</>"
            senn = ""
            
print(new)


#color.txt song.txt



# 1662741, 2022-10-29 10:07:36, PPPPP (100%)

color = input()
song = input()

finc = open(color, "r")
fins = open(song, "r")
c = []
for linec in finc:
    if len(linec) > 1:
        c += linec.lower().split()
    
sen = ""

for lines in fins:
    sen += lines
    
senn = ""
new = ""
for i in sen:
    senn += i
    for co in c:
        if co in senn.lower():
            new += senn[:senn.lower().find(co)] + "<" + co + ">" + senn[senn.lower().find(co):] + "</>"
            senn = ""
            
print(new+senn)


#color.txt song.txt




6530186721
# 1663760, 2022-10-29 10:30:55, ----- (0%)

color = []
with open(input(), 'r') as file :
    for line in file :
        line = line.lower()
        color += line.split()

data = ''
with open(input(), 'r') as file :
    for line in file :
        data += line

check = data.lower()
flags = []
for i in color :
    position = check.find(i)
    tod = []
    while position != -1 :
        tod.append(position)
        position = check.find(i,position+len(i))
    flags.append(tod)
use = [e for i in flags for e in i]
use.sort(reverse=True)
for i in use :
    pos = [n for n,e in enumerate(flags) if i in e]
    data = data[:i]+'<' + color[pos[0]] + '>' + data[i:i+len(color[pos[0]])+1] + '</>' + data[i+len(color[pos[0]])+1:]
print(data)

# 1663813, 2022-10-29 10:32:04, PPPPP (100%)

color = []
with open(input(), 'r') as file :
    for line in file :
        line = line.lower()
        color += line.split()

data = ''
with open(input(), 'r') as file :
    for line in file :
        data += line

check = data.lower()
flags = []
for i in color :
    position = check.find(i)
    tod = []
    while position != -1 :
        tod.append(position)
        position = check.find(i,position+len(i))
    flags.append(tod)
use = [e for i in flags for e in i]
use.sort(reverse=True)
for i in use :
    pos = [n for n,e in enumerate(flags) if i in e]
    data = data[:i]+'<' + color[pos[0]] + '>' + data[i:i+len(color[pos[0]])] + '</>' + data[i+len(color[pos[0]]):]
print(data)

6530197621
# 1663223, 2022-10-29 10:19:57, xxxxx (0%)

def tag_w(color,word):
    if word.lower() in color:
        return "<"+word.lower()+">"+word+"</>"
    else:
        return word

colorfile = "clr.txt"
songfile = "song.txt"
c_file = open(colorfile,"r")
s_file = open(songfile,"r")

color = []
for line in c_file:
    name = line.split()
    for c in name:
        if c.lower() not in color:
            color.append(c.lower())
ans = ""
for line in s_file:
    for c in color:
        start = 0
        idx = line.lower().find(c,start)
        while idx != -1:
            word = line[idx:idx+len(c)]
            taged = tag_w(color,word)
            line = line[0:idx]+taged+line[idx+len(c):]
            start = idx+len(taged)
            idx = line.lower().find(c,start)
    ans += line
print(ans)
            
# 1663443, 2022-10-29 10:24:51, PPPPP (100%)

def tag_w(color,word):
    if word.lower() in color:
        return "<"+word.lower()+">"+word+"</>"
    else:
        return word

colorfile = input()
songfile = input()
c_file = open(colorfile,"r")
s_file = open(songfile,"r")

color = []
for line in c_file:
    name = line.split()
    for c in name:
        if c.lower() not in color:
            color.append(c.lower())
ans = ""
for line in s_file:
    for c in color:
        start = 0
        idx = line.lower().find(c,start)
        while idx != -1:
            word = line[idx:idx+len(c)]
            taged = tag_w(color,word)
            line = line[0:idx]+taged+line[idx+len(c):]
            start = idx+len(taged)
            idx = line.lower().find(c,start)
    ans += line
print(ans)
            

6530201421
# 1662849, 2022-10-29 10:10:29, xxxxx (0%)

file1="color.txt".strip()

fr1=open(file1,"r")
line1=fr1.readline()
All_color=[]
while len(line1)!=0:
    line1=line1.strip()
    Line=line1.split()
    for i in Line:
        All_color.append(i.lower())
    line1=fr1.readline()

def change(line2):
    for i in range(len(All_color)):
        Point=line2.lower().find(All_color[i])
        word=line2[Point:Point+len(All_color[i])]
        while Point!=-1:
            line2=line2[0:Point]+"<"+All_color[i]+">"+word+"</>"+line2[Point+len(word):]
            Point=line2.lower().find(All_color[i],Point+len(word)*2)
            word=line2[Point:Point+len(All_color[i])]
    return line2
file2="music.txt".strip()

fr2=open(file2,"r")
line2=fr2.readline()
while len(line2)!=0:
    line2=line2.strip()
    line2=change(line2)
    print(line2)
    line2=fr2.readline()
# 1662881, 2022-10-29 10:11:23, PPPPP (100%)

file1=input().strip()

fr1=open(file1,"r")
line1=fr1.readline()
All_color=[]
while len(line1)!=0:
    line1=line1.strip()
    Line=line1.split()
    for i in Line:
        All_color.append(i.lower())
    line1=fr1.readline()

def change(line2):
    for i in range(len(All_color)):
        Point=line2.lower().find(All_color[i])
        word=line2[Point:Point+len(All_color[i])]
        while Point!=-1:
            line2=line2[0:Point]+"<"+All_color[i]+">"+word+"</>"+line2[Point+len(word):]
            Point=line2.lower().find(All_color[i],Point+len(word)*2)
            word=line2[Point:Point+len(All_color[i])]
    return line2
file2=input().strip()

fr2=open(file2,"r")
line2=fr2.readline()
while len(line2)!=0:
    line2=line2.strip()
    line2=change(line2)
    print(line2)
    line2=fr2.readline()


6530209521
# 1664076, 2022-10-29 10:36:07, PPPP- (80%)

color = input()
song = input()
col = open(color,'r')
son = open(song,'r')
lc = []
for linec in col :
    linec = linec.strip().lower()
    lc += linec.split()



for lines in son :
    nl = ''
    lines = lines.strip()
    for ctag in lc :
        oldpos = 0
        pos = lines.lower().find(ctag)
        while pos != -1 :
            nl += lines[oldpos:pos]+'<'+ctag+'>'+ctag+'</>'
            oldpos = pos + len(ctag)
            pos = lines.lower().find(ctag,oldpos)
        lines = nl + lines[oldpos:]
        nl = ''
    print(lines)

# 1664188, 2022-10-29 10:37:50, PPPPP (100%)

color = input()
song = input()
col = open(color,'r')
son = open(song,'r')
lc = []
for linec in col :
    linec = linec.strip().lower()
    lc += linec.split()



for lines in son :
    nl = ''
    lines = lines.strip()
    for ctag in lc :
        oldpos = 0
        pos = lines.lower().find(ctag)
        while pos != -1 :
            nl += lines[oldpos:pos]+'<'+ctag+'>'+lines[pos:pos+len(ctag)]+'</>'
            oldpos = pos + len(ctag)
            pos = lines.lower().find(ctag,oldpos)
        lines = nl + lines[oldpos:]
        nl = ''
    print(lines)


6531323521
# 1663470, 2022-10-29 10:25:25, PPP-- (60%)

color = input()
lyrics = input()
fcolor = open(color)
flyrics = open(lyrics)
color = []
for i in fcolor :
    i = i.strip()
    x = [e for e in i.split()]
    for j in x :
        if j!= "":
            color.append(j)  
for i in flyrics:
    i = i.strip()
    a = -1
    for j in color :
        a = -1
        while True :
          a = i.lower().find(j.lower(),a+1)
          if a == -1 :
            break
          else :
            i = i[0:a] + "<" + j + ">" + i[a:a+len(j)] + "</>"+ i[a+len(j):]
            a = a+len(j*2)
    print(i)

    
# 1663606, 2022-10-29 10:28:01, PPPPP (100%)

color = input()
lyrics = input()
fcolor = open(color)
flyrics = open(lyrics)
color = []
for i in fcolor :
    i = i.strip()
    x = [e for e in i.split()]
    for j in x :
        if j!= "":
            color.append(j)  
for i in flyrics:
    i = i.strip()
    a = -1
    for j in color :
        a = -1
        while True :
          a = i.lower().find(j.lower(),a+1)
          if a == -1 :
            break
          else :
            i = i[0:a] + "<" + j.lower() + ">" + i[a:a+len(j)] + "</>"+ i[a+len(j):]
            a = a+len(j*2)
    print(i)

    

6531329321
# 1663007, 2022-10-29 10:14:43, PP--- (40%)

f = open(input(),'r')
t = open(input(),'r')
colors = []
for e in f:
    for i in e.split():
        colors.append(i.lower())
f.close()
for e in t:
    ee = e.split()
    for i in range(len(ee)):
        for c in colors:
            if c in ee[i].lower():
                k = ee[i].lower().find(c)
                ee[i] = ee[i][:k] + '<' + c + '>' + ee[i][k:k+len(c)] + '</>' + ee[i][k+len(c):]
    print(' '.join(ee))
t.close()

# 1663271, 2022-10-29 10:21:18, PPPPP (100%)

f = open(input(),'r')
t = open(input(),'r')
colors = []
for e in f:
    for i in e.split():
        colors.append(i.lower())
f.close()
for e in t:
    ee = e.split()
    for i in range(len(ee)):
        for c in colors:
            if c in ee[i].lower():
                k = ee[i].lower().find(c)
                while k != -1:
                    e = len(ee[i][:k] + '<' + c + '>' + ee[i][k:k+len(c)] + '</>')
                    ee[i] = ee[i][:k] + '<' + c + '>' + ee[i][k:k+len(c)] + '</>' + ee[i][k+len(c):]
                    k = ee[i].lower().find(c,e)
    print(' '.join(ee))
t.close()


6531345321
# 1662869, 2022-10-29 10:10:53, P---- (20%)

def pr(c):
    temp = '<' + c.lower() + '>' + c +'</>' 
    return temp

cl = input()
lc = input()

colour = open(cl,'r')
ly = open(lc,'r')

c = []
for e in colour:
    x = e.strip().split()
    for a in x:
        if a != '\n':
            c.append(a.lower())
#print(c) C work!


for e in ly :
    x = e.strip().lower()
    index = dict()
    # 0 -> index 1 -> colour 2 -> len of colour
    for a in c :
        if a in x:
            j = x.find(a) # a -> colour
            index[j] = a 
    temp = ""
   # print(index)
    i = 0 
    while i < len(e.strip()) :
        if i not in index :
            temp += e[i]
            i += 1 
        else :
            al = len(index[i])
            t = e[i:al+i]
            temp += pr(t)
            i += al
    print(temp)


# 1663080, 2022-10-29 10:16:18, PPPPP (100%)

def pr(c):
    temp = '<' + c.lower() + '>' + c +'</>' 
    return temp

cl = input()
lc = input()

colour = open(cl,'r')
ly = open(lc,'r')

c = []
for e in colour:
    x = e.strip().split()
    for a in x:
        if a != '\n':
            c.append(a.lower())
#print(c) C work!


for e in ly :
    x = e.strip().lower()
    index = dict()
    # 0 -> index 1 -> colour 2 -> len of colour
    for a in c :
        if a in x:
            j = 0
            j = x.find(a) # a -> colour
            while j != - 1 :
                index[j] = a 
                j = x.find(a,j+1)
    temp = ""
   # print(index)
    i = 0 
    while i < len(e.strip()) :
        if i not in index :
            temp += e[i]
            i += 1 
        else :
            al = len(index[i])
            t = e[i:al+i]
            temp += pr(t)
            i += al
    print(temp)



6532123521
# 1662181, 2022-10-29 09:50:00, xxxxx (0%)

f1 = open('a.txt')
f2 = open('b.txt')

color_list = ' '.join([e.strip().lower() for e in f1.readlines()]).split()
txt = ''.join(f2.readlines())

for color in color_list:
    i = 0
    while i < len(txt):
        curr = txt[i:i+len(color)]
        if(curr.lower() == color):
            appending = '<' + color + '>' + curr + '</>'
            txt = txt[:i] + appending + txt[i+len(color):]
            i += len(appending) - 1
        i += 1

print(txt)

# 1662198, 2022-10-29 09:50:26, PPPPP (100%)

f1 = open(input().strip())
f2 = open(input().strip())

color_list = ' '.join([e.strip().lower() for e in f1.readlines()]).split()
txt = ''.join(f2.readlines())

for color in color_list:
    i = 0
    while i < len(txt):
        curr = txt[i:i+len(color)]
        if(curr.lower() == color):
            appending = '<' + color + '>' + curr + '</>'
            txt = txt[:i] + appending + txt[i+len(color):]
            i += len(appending) - 1
        i += 1

print(txt)


6532148221
# 1663601, 2022-10-29 10:27:55, ----- (0%)

def Convert(line, color):
   # print(line, color)
    FoundAt = []
    for i in range(0, len(line) - len(color) + 1):
        #print(line[i : i + len(color)].lower(), color)
        if line[i : i + len(color)].lower() == color:
            FoundAt += [i]
    return FoundAt


NameColor = input()
NameSong = input()

infileC = open(NameColor , 'r')
infileS = open(NameSong, 'r')
AllColor = []
AllS = []

for line in infileC:
    for k in line.split():
        AllColor += [k.lower()]

for line in infileS:
    AllS += [line]

#print(AllColor)
#print(AllS)
for k in AllColor:
    for j in range(0, len(AllS)):
        #print(j, k)
        Found = Convert(AllS[j], k)
        temp = AllS[j]
        for i in range(len(Found) -1, -1, -1):
            temp = temp[0: Found[i]] + "<" + k + '>' + temp[Found[i] : Found[i] + len(k)] + "</>" + temp[Found[i] + len(k):]
        AllS[j] = temp

for k in AllS:
    print(k[:len(k)-1])
infileC.close()
infileS.close()
# 1663749, 2022-10-29 10:30:45, PPPPP (100%)

def Convert(line, color):
   # print(line, color)
    FoundAt = []
    for i in range(0, len(line) - len(color) + 1):
        #print(line[i : i + len(color)].lower(), color)
        if line[i : i + len(color)].lower() == color:
            FoundAt += [i]
    return FoundAt


NameColor = input()
NameSong = input()

infileC = open(NameColor , 'r')
infileS = open(NameSong, 'r')
AllColor = []
AllS = []

for line in infileC:
    for k in line.split():
        AllColor += [k.lower()]

for line in infileS:
    AllS += [line]

#print(AllColor)
#print(AllS)
for k in AllColor:
    for j in range(0, len(AllS)):
        #print(j, k)
        Found = Convert(AllS[j], k)
        temp = AllS[j]
        for i in range(len(Found) -1, -1, -1):
            temp = temp[0: Found[i]] + "<" + k + '>' + temp[Found[i] : Found[i] + len(k)] + "</>" + temp[Found[i] + len(k):]
        AllS[j] = temp

for k in AllS:
    print(k[:len(k)])
infileC.close()
infileS.close()

6532182521
# 1662947, 2022-10-29 10:13:16, PPPPP (100%)

myColor = input()
mySong = input()

colorList = []
with open(myColor) as fp:
    for line in fp:
        if line == '\n' or line == '' or line == ' ':
            continue
        for word in line.split():
            colorList.append(word.lower())


with open(mySong) as fp:
    for line in fp:
        lowerLine = line.lower()
        for color in colorList:
            if color in lowerLine:
                lowerLine = lowerLine.replace(color, '<' + color + '>' + color + '</>')
        i, j = 0, 0
        while i < len(line):
            if lowerLine[j] != '<':
                print(line[i], end='')
                i += 1
                j += 1
            else:
                while lowerLine[j] != '>':
                    print(lowerLine[j], end='')
                    j += 1
                print('>', end='')
                j += 1
                while lowerLine[j] != '<':
                    print(line[i], end='')
                    i += 1
                    j += 1
                while lowerLine[j] != '>':
                    print(lowerLine[j], end='')
                    j += 1
                print('>', end='')
                j += 1
                # while lowerLine.find(color) != -1:
                #     cur = lowerLine.find(color)
                #     line = line[:cur] + '<' + color + '>' + line[cur: cur+len(color)] + '</>'
                #     lowerLine = line.lower()

# 1662951, 2022-10-29 10:13:28, PPPPP (100%)

myColor = input()
mySong = input()

colorList = []
with open(myColor) as fp:
    for line in fp:
        if line == '\n' or line == '' or line == ' ':
            continue
        for word in line.split():
            colorList.append(word.lower())


with open(mySong) as fp:
    for line in fp:
        lowerLine = line.lower()
        for color in colorList:
            if color in lowerLine:
                lowerLine = lowerLine.replace(color, '<' + color + '>' + color + '</>')
        i, j = 0, 0
        while i < len(line):
            if lowerLine[j] != '<':
                print(line[i], end='')
                i += 1
                j += 1
            else:
                while lowerLine[j] != '>':
                    print(lowerLine[j], end='')
                    j += 1
                print('>', end='')
                j += 1
                while lowerLine[j] != '<':
                    print(line[i], end='')
                    i += 1
                    j += 1
                while lowerLine[j] != '>':
                    print(lowerLine[j], end='')
                    j += 1
                print('>', end='')
                j += 1


6530005821
# 1662195, 2022-10-29 09:50:24, PPPPP (100%)

colorname = input()
lyric =input()
f = open(colorname,'r')
g = open(lyric,'r')
s = f.read()
color = s.lower().split()
g1 = g.readlines()
g2 = [e.lower() for e in g1]
p2 = 0
def where(s,w):
    a =[]
    c = s.lower()
    for e in w:
        if e!='':
            k = c.count(e.lower())
            j = -1
            for i in range(k):
                j = c.find(e.lower(),j+1)
                a+= [[j,e]]
                if j == -1:
                    j = -1
    return a
for line in g1:
    c = where(line,color)
    c.sort()
    o = 0
    w=''
    for [x1,x2] in c:
        p = line[x1:x1+len(x2)]
        p = '<'+x2+'>'+p+'</>'
        c = line[o:x1]
        o = x1+len(x2)
        w+=c+p
    w+=line[o:]
    print(w.strip())
f.close()
g.close()

6530072821
# 1662291, 2022-10-29 09:53:19, PPPPP (100%)

def replace_ignore_case(word,find,replace):
    findLen = len(find)
    find = find.lower()
    front = "<"+replace.lower()+">"
    end = "</>"
    ans=''
    lowerWord = word.lower()
    i=0
    while i <len(word)-findLen+1:
        if lowerWord[i:i+findLen] == find:
            ans+=front+word[i:i+findLen]+end
            i+=findLen
        else:
            ans+=word[i]
            i+=1
    for k in range(i,len(word)):
        ans+=word[k]
    return ans


colorFile = open(input().strip(),'r')
songFile = open(input().strip(),'r')
colors = [name.lower() for line in colorFile for name in line.strip().split() if line.strip().split()!=[]]
colorFile.close()
song = ""
for line in songFile:
    song+=line
songFile.close()
for color in colors:
    song = replace_ignore_case(song,color,color)
print(song)


6530085021
# 1663258, 2022-10-29 10:20:58, PPPPP (100%)

cr = input()
sr = input()
c = open(cr,"r")
s = open(sr,"r")
co = c.read()
color = co.split()
song = s.read()
song_l = song.lower()
for i in color:
    cl = i.lower()
    u = 0
    while song_l.find(cl,u) != -1:
        song = song[:song_l.find(cl,u)]+"<"+cl+">"+song[song_l.find(cl,u):song_l.find(cl,u)+len(cl)]+"</>"+song[song_l.find(cl,u)+len(cl):]
        song_l = song_l[:song_l.find(cl,u)]+"<"+cl+">"+song_l[song_l.find(cl,u):song_l.find(cl,u)+len(cl)]+"</>"+song_l[song_l.find(cl,u)+len(cl):]
        u = song_l.find(cl,u)+len(cl)+5
print(song)

6530126021
# 1664477, 2022-10-29 10:40:26, PPPPP (100%)

col = open(input().strip(),'r')
ly = open(input().strip(),'r')
x=[]
color =[]
ans =''
for line in col:
    line.strip()
    x= line.split()
    for i in x:
        color.append(i.lower())
        
for line in ly:
    line.strip()
    word =''
    for i in line:
        word+=i
        if 'A'<= i <='z':
            if word.lower() in color :
                pos = color.index(word.lower())
                ans += '<'+color[pos]+'>'+word+'</>'
                word= ''
        else:
            ans += word
            word =''
col.close()
ly.close()
print(ans)
  


    
    
    
    


6531303021
# 1663119, 2022-10-29 10:17:30, PPPPP (100%)

nf1 = input()
nf2 = input()

f1 = open(nf1)
f2 = open(nf2)

color = []
for i in f1:
    color += i.strip().lower().split()

for t in f2:
    a = 0
    for e in color:
        a = t.lower().find(e)
        while a != -1:
            old = t[a:a+len(e)]
            t = t[:a] +t[a:].replace(old,'<{}>{}</>'.format(e,old),1)
            a = t.lower().find(e,a + len(e)+ 4)  
    print(t.strip())


f1.close()
f2.close()

6531308121
# 1662533, 2022-10-29 10:00:51, PPPPP (100%)

data1 = input()
data2 = input()

d1 = open(data1,'r')
d2 = open(data2,'r')

color = []
ans = ''
for line in d1 :
    line = line.strip()
    if line != '' :
        cl = [e.upper() for e in line.split()]
        color = color + cl
for L in d2 :
    l = L.upper()
    for c in color :
        start = 0
        while True :
            if l.find(c,start) == -1 :
                break
            else :
                start = l.find(c,start)
                l = l[:start] + ('<'+c.lower()+'>') + l[start:start+len(c)] + '</>' + l[start+len(c):]
                L = L[:start] + ('<'+c.lower()+'>') + L[start:start+len(c)] + '</>' + L[start+len(c):]
                start+=5+2*len(c)
    ans += L

print(ans)


6531309821
# 1662126, 2022-10-29 09:48:16, PPPPP (100%)

file_color = input()
file_music = input()

fcolor = open(file_color, "r")

all_color = []
for line in fcolor:
    temp = line.strip().split()
    for color in temp:
        all_color.append(color.lower())

fcolor.close()

fmusic = open(file_music, "r")

for line in fmusic:
    for color in all_color:
        ind = line.lower().find(color)
        while ind != -1:
            length = len(color)
            line = line[:ind] + "<" + color + ">" + line[ind:ind+length] + "</>" + line[ind+length:]
            ind = line.lower().find(color, ind+(2*length))
    print(line.strip())

fmusic.close()

6532011921
# 1661810, 2022-10-29 09:37:55, PPPPP (100%)

def solve(col, songs):
    colors = []
    for line in col:
        for x in line.split():
            colors.append(x.strip().lower())

    for line in songs:
        i = 0
        res = ''
        while i < len(line):
            has_color = False
            for color in colors:
                if line[i:i+len(color)].lower() == color:
                    res += '<' + color + '>' + line[i:i+len(color)] + '</>'
                    i += len(color)-1
                    has_color = True
                    break
            if not has_color:
                res += line[i]
            i += 1
        print(res)
            

col_name = input()
song_name = input()

with open(col_name, 'r') as col, open(song_name, 'r') as song:
    solve([x.strip() for x in col.readlines()], [x.strip() for x in song.readlines()])

6532026321
# 1661997, 2022-10-29 09:43:54, PPPPP (100%)

# color_file = "color.txt"
# song_file = "song.txt"
color_file = input()
song_file = input()
colors = []

f = open(color_file, "r")
for i in f.readlines():
  for j in i.lower().split():
    colors.append(j)
f.close()

f = open(song_file, "r")
for line in f.readlines():
  for c in colors:
    i = line.lower().find(c)
    while i != -1:
      line = line[:i] + "<" + c + ">" + line[i:i+len(c)] + "</>" + line[i+len(c):]
      i = line.lower().find(c, i+len(c)+5)
  print(line, end="")
f.close()

6532054921
# 1662730, 2022-10-29 10:07:08, PPPPP (100%)

file1_name = input()
file2_name = input()

file1 = open(file1_name,"r")
color = []

def get_color(t) :
    li = []
    for i in range(len(t)) :
        for j in range(len(color)) :
            if(len(color[j]) > len(t) - i) :
                continue
            for k in range(len(color[j])) :
                if(color[j][k].lower() != t[i + k].lower()) :
                    break
                elif (k == len(color[j]) - 1) :
                    li.append([i,j])
    return li

for i in file1 :
    t = i.split()
    for j in t :
        color.append(j)

file2 = open(file2_name,"r")
for line in file2 :
    k = line
    if(k[-1] == "\n") :
        k = k[:-1]
    po = get_color(k)
    
    for i in po[::-1] :
        jim = k[i[0]:i[0] + len(color[i[1]])]
        k = k[0:i[0]] + "<" + color[i[1]].lower() + ">" + jim + "</>" + k[i[0] + len(color[i[1]]):]
    print(k)


6532092721
# 1662967, 2022-10-29 10:13:57, PPPPP (100%)

def cal(word , dic) :
    result = ""
    i = 0
    while i < len(word) :
        flag = True
        for check in dic :
            if word[i].lower() == check[0] :
                long = len(check)
                color = word[i : i + long]
                if color.lower() == check :
                    flag = False
                    result += "<{}>{}</>".format(check , color)
                    i += long
                    break
        if (flag) :
            result += word[i]
            i += 1
    return result
locate_color = input()
locate_input = input()

file = open(locate_color , 'r')
dic_color = {}
for line in file.readlines() :
    line = line.strip().split()
    for color in line :
        dic_color[color.lower()] = 1
file.close()

file = open(locate_input , 'r')
for line in file.readlines() :
    out = ""
    line = line.strip()
    cur_word = ""
    for c in line :
        if c.lower() not in "abcdefghijklmnopqrstuvwxyz" :
            out += cal(cur_word,dic_color) + c
            cur_word = ""
        else :
            cur_word += c
    if cur_word != "" :
        out += cal(cur_word,dic_color)
    print(out)

6532152721
# 1662389, 2022-10-29 09:56:37, PPPPP (100%)

color_file = input()
song_file = input()

colors = open(color_file, "r")
song = open(song_file, "r")

color_list = []
for line in colors:
    tmp = line.strip().split()
    color_list += [x.lower() for x in tmp]

for line_original in song:
    line = line_original.strip()
    ans = ""
    i = 0
    while i < len(line):
        found = False
        for color in color_list:
            if line[i: i + len(color)].lower() == color:
                ans += "<" + color + ">" + line[i: i + len(color)] + "</>"
                i += len(color)
                found = True
                break
        if not found:
            ans += line[i]
            i += 1
    print(ans)

colors.close()
song.close()

6532155621
# 1662205, 2022-10-29 09:50:31, PPPPP (100%)

f1Name = input().strip()
f2Name = input().strip()
with open(f1Name) as colorFile, open(f2Name) as songFile:
    colors2D = [ x.strip().lower().split() for x in colorFile.readlines() ]
    colors = [ x for row in colors2D for x in row]
    # print(colors)

    buffer = ""
    ans = ""
    for x in songFile.read():
        buffer += x
        for color in colors:
            suffix = buffer[len(buffer)-len(color):].lower()
            if suffix == color:
                buffer = buffer[:len(buffer)-len(color)] + "<"+color+">" + buffer[len(buffer)-len(color): ] + "</>"
    
    print(buffer)


6532187721
# 1662186, 2022-10-29 09:50:05, PPPPP (100%)

f1 = input()
f2 = input()
f = open(f1,'r')
L = []
for l in f:
    l = l.lower()
    l = l.split()
    for x in l: L.append(x)
f.close()
f = open(f2,'r')
for ll in f:
    l = ll.lower()
    L2 = []
    for x in L:
        i=0
        while i!=-1 or i<len(l):
            a = l.find(x,i)
            if a==-1: break
            L2.append([a,x])
            i=a+1
    L2.sort()
    i=0
    for x,y in L2:
        print(ll[i:x]+'<'+y+'>'+ll[x:x+len(y)]+'</>', end='')
        i = x+len(y)
    print(ll[i:],end='')
    


6532193421
# 1663108, 2022-10-29 10:17:06, PPPPP (100%)

s1=input()
s2=input()
color=open(s1, 'r')
song=open(s2, 'r')

alp="abcdefghijklmnopqrstuvwxyz"

colors=set()
for line in color:
    for c in line.strip().split():
        colors.add(c.lower())
for line in song:
    s=line.strip()
    temp=line.strip().lower()
    ar={}
    for c in colors:
        i=0
        while True:
            i=temp.find(c, i)
            if i==-1:
                break
            ar[i]=c
            i+=1
    i=0
    ans=""
    while i<len(s):
        if i in ar:
            ans+="<"+ar[i]+">"+s[i:i+len(ar[i])]+"</>"
            i+=len(ar[i])
        else:
            ans+=s[i]
            i+=1
    print(ans)
color.close()
song.close()

6532186021
# 1662728, 2022-10-29 10:07:01, PPPPP (100%)

def change(s,c):
    sl = s.lower()
    i = 0
    while True:
        i = sl.find(c,i)
        if i == -1:
            break
        s = s[:i]+'<'+c+'>'+s[i:i+len(c)]+'</>'+s[i+len(c):]
        sl = sl[:i]+'<'+c+'>'+sl[i:i+len(c)]+'</>'+sl[i+len(c):]
        i += 5 + 2*len(c)
    return s
    

colorname = input().strip()
songname = input().strip()

color = []
cfile = open(colorname,'r')
for line in cfile:
    line = line.lower().split()
    color += line

sfile = open(songname,'r')
s = ''
for line in sfile:
    s += line
for e in color:
    s = change(s,e)
print(s)



Max Score = 80


6532180221
# 1662261, 2022-10-29 09:52:12, ----- (0%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    a = i.split(" ")
    for j in a:
        if(j.lower() in color_list):
            i.replace(j, "<{}>{}</>".format(j.lower(), j) )
    print(i)
# 1662312, 2022-10-29 09:53:57, P---- (20%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    for j in i.split():
        if(j.lower() in color_list):
            i=i.replace(j, "<{}>{}</>".format(j.lower(), j) )
    print(i)
# 1662358, 2022-10-29 09:55:27, P---- (20%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    for j in i.split():
        if(j.lower().replace(',','') in color_list):
            i=i.replace(j, "<{}>{}</>".format(j.lower().replace(',',''), j.replace(',','')) )
    print(i)

# 1662471, 2022-10-29 09:58:54, compilation error (0%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    for j in i.split():
        k = j.lower().replace(',','').replace('.','')
        j = j.replace(',','').replace('.','')
        if(k in color_list):
            i=i.replace(j, "<{}>{}</>".format(k, j )
    print(i)

# 1662481, 2022-10-29 09:59:13, P---- (20%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    for j in i.split():
        k = j.lower().replace(',','').replace('.','')
        j = j.replace(',','').replace('.','')
        if(k in color_list):
            i=i.replace(j, "<{}>{}</>".format(k, j ))
    print(i)
# 1662635, 2022-10-29 10:04:18, PPPP- (80%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    for j in color_list:
        x=i.lower().find(j)
        if(x != -1): i=i.replace(i[x:x+len(j)], "<{}>{}</>".format(j, i[x:x+len(j)] ))
    print(i)

# 1662747, 2022-10-29 10:07:46, PPPP- (80%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    a=i
    for j in color_list:
        x=i.lower().find(j)
        if(x != -1): a=a.replace(i[x:x+len(j)], "<{}>{}</>".format(j, i[x:x+len(j)] ))
    print(a)

# 1662867, 2022-10-29 10:10:50, compilation error (0%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip()split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        x=i.lower().find(j)
        # print(i[x:x+len(j)])
        if(x != -1): i=i.replace(i[x:x+len(j)], "<{}>{}</>".format(j, i[x:x+len(j)] ))
    print(i)

# 1662872, 2022-10-29 10:11:05, PPPP- (80%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip().split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        x=i.lower().find(j)
        # print(i[x:x+len(j)])
        if(x != -1): i=i.replace(i[x:x+len(j)], "<{}>{}</>".format(j, i[x:x+len(j)] ))
    print(i)

# 1663685, 2022-10-29 10:29:37, P---- (20%)

from re import X


color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip().split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        pointer = 0
        llenn = len(i)
        while(pointer <= llenn):
            
            x=i[pointer:pointer+len(j)].lower()
            if(x == j and i[pointer-1]!='>'): 
                o = "<{}>{}</>".format(j, i[pointer:pointer+len(j)])
                i=i.replace(i[pointer:pointer+len(j)], o )
                pointer+=len(o)-len(j)
                llenn+=len(o)-len(j)
            else:
                pointer+=1
            
    print(i)
# 1663769, 2022-10-29 10:31:06, x-xxx (0%)

from re import X


color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip().split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        pointer = 0
        llenn = len(i)
        while(pointer <= llenn):
            
            x=i[pointer:pointer+len(j)].lower()
            if(x == j and (i[pointer-1]!='>' and i[pointer+len(j)]!='<')): 
                o = "<{}>{}</>".format(j, i[pointer:pointer+len(j)])
                i=i.replace(i[pointer:pointer+len(j)], o )
                pointer+=len(o)-len(j)
                llenn+=len(o)-len(j)
            else:
                pointer+=1
            
    print(i)
# 1663848, 2022-10-29 10:32:45, P---- (20%)

from re import X


color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip().split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        pointer = 0
        llenn = len(i)
        while(pointer <= llenn):
            
            x=i[pointer:pointer+len(j)].lower()
            if(x == j and i[pointer-1]!='ท'): 
                o = "<{}>ท{}</>".format(j, i[pointer:pointer+len(j)])
                i=i.replace(i[pointer:pointer+len(j)], o )
                pointer+=len(o)-len(j)
                llenn+=len(o)-len(j)
            else:
                pointer+=1
            
    print(i.replace('ท',''))
# 1663955, 2022-10-29 10:34:21, PPPP- (80%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip().split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        x=i.lower().find(j)
        # print(i[x:x+len(j)])
        if(x != -1): i=i.replace(i[x:x+len(j)], "<{}>{}</>".format(j, i[x:x+len(j)] ))
    print(i)

# 1664014, 2022-10-29 10:35:22, PPPP- (80%)

from re import X


color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip().split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        pointer = 0
        llenn = len(i)
        
        while(pointer <= llenn):
            # if(j == 'red') :print(i)
            x=i[pointer:pointer+len(j)].lower()
            if(x == j and i[pointer-1]!='ท'): 
                o = "<{}>ท{}</>".format('ท'+j, i[pointer:pointer+len(j)])
                i=i.replace(i[pointer:pointer+len(j)], o )
                pointer+=len(o)-len(j)
                llenn+=len(o)-len(j)
            else:
                pointer+=1
            
    print(i.replace('ท',''))
# 1664465, 2022-10-29 10:40:21, PPPP- (80%)

color_file = open(input(),'r')
lyrics_file = open(input(),'r')

color_list = []
for i in color_file:
    color_list += i.strip().split()

for i in range(len(color_list)): color_list[i] = color_list[i].lower()

for i in lyrics_file:
    i=i.strip()
    for j in color_list:
        x=i.lower().find(j)
        # print(i[x:x+len(j)])
        if(x != -1): i=i.replace(i[x:x+len(j)], "<{}>{}</>".format(j, i[x:x+len(j)] ))
    print(i)

6532035021
# 1662799, 2022-10-29 10:09:01, ----- (0%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
for c in C:
    for w in [L[i:i+len(c)] for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]:
        L = L.replace(w, '<%s>%s</>' % (c.lower(), w))
print(L)
# 1662980, 2022-10-29 10:14:09, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
for c in C:
    for w in set([L[i:i+len(c)] for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        L = L.replace(w, '<%s>%s</>' % (c.lower(), w))
print(L)
# 1663112, 2022-10-29 10:17:18, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
assert(len(C) != 0)
L = open(input().strip(), 'r').read()
for c in C:
    for w in set([L[i:i+len(c)] for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        L = L.replace(w, '<%s>%s</>' % (c.lower(), w))
print(L)
# 1663122, 2022-10-29 10:17:37, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
assert(len(L) > 0)
for c in C:
    for w in set([L[i:i+len(c)] for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        L = L.replace(w, '<%s>%s</>' % (c.lower(), w))
print(L)
# 1663146, 2022-10-29 10:18:15, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
for c in C:
    for w in set([L[i:i+len(c)] for i in range(len(L) - len(c)) if L[i:i+len(c)].lower() == c.lower()]):
        L = L.replace(w, '<%s>%s</>' % (c.lower(), w))
print(L)
# 1663279, 2022-10-29 10:21:29, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
ans = L
for c in C:
    for w in set([L[i:i+len(c)] for i in range(len(L) - len(c)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans)
# 1663336, 2022-10-29 10:22:44, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
ans = L
for c in C:
    for w in set([L[i:i+len(c)] for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans)
# 1663402, 2022-10-29 10:24:03, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
ans = L
for c in C:
    for w in set([L[i:i+len(c)].strip() for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans)
# 1663624, 2022-10-29 10:28:12, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read().replace('\n', '[\n]')
ans = L
for c in C:
    for w in set([L[i:i+len(c)].strip() for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans.replace('[\n]', '\n'))
# 1663690, 2022-10-29 10:29:41, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read().replace('\n', '[\n]')
ans = L
for c in C:
    assert(c[0] != 'n')
    for w in set([L[i:i+len(c)].strip() for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans.replace('[\n]', '\n'))
# 1663699, 2022-10-29 10:29:50, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read().replace('\n', '[\n]')
ans = L
for c in C:
    assert(c[0] != 't')
    for w in set([L[i:i+len(c)].strip() for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans.replace('[\n]', '\n'))
# 1663835, 2022-10-29 10:32:31, ----- (0%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read()
assert(not '<' in C)
exit()
C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read().replace('\n', '[\n]')
ans = L
for c in C:
    for w in set([L[i:i+len(c)].strip() for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans.replace('[\n]', '\n'))
# 1663854, 2022-10-29 10:32:56, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
for c in C:
    for w in set([L[i:i+len(c)] for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        L = L.replace(w, '<%s>%s</>' % (c.lower(), w))
print(L)
# 1664446, 2022-10-29 10:40:10, PPPP- (80%)

def file2list(filename):
    file_list = []
    with open(filename, 'r') as file:
        while True:
            line = file.readline().strip()
            if len(line) == 0:
                break
            file_list.append(line)
    
    return file

C = open(input().strip(), 'r').read().split()
L = open(input().strip(), 'r').read()
ans = L
for c in C:
    for w in set([L[i:i+len(c)].strip() for i in range(len(L)) if L[i:i+len(c)].lower() == c.lower()]):
        ans = ans.replace(w, '<%s>%s</>' % (c.lower(), w))
print(ans)

6530117421
# 1662216, 2022-10-29 09:50:50, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    text = ""
    lowtext = ""
    for i in range(len(low)):
        if low[i].isalnum() == True:
            lowtext += low[i]
            text += line[i]
        else:
            if lowtext in col: rep.append(text)
            lowtext = ""
            text = ""
    for i in rep:
        temp = "<"+i.lower()+">"+i+"</>"
        line = line.replace(i,temp)
    print(line)
infile.close()

# 1662463, 2022-10-29 09:58:42, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()

# 1662474, 2022-10-29 09:58:57, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()
# 1662551, 2022-10-29 10:01:28, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
out = ""
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    out += line
infile.close()
print(out)

# 1662598, 2022-10-29 10:03:01, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
out = ""
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    text = ""
    lowtext = ""
    for i in range(len(low)):
        if low[i].isalnum() == True:
            lowtext += low[i]
            text += line[i]
        else:
            if lowtext in col: rep.append(text)
            lowtext = ""
            text = ""
    for i in rep:
        temp = "<"+i.lower()+">"+i+"</>"
        line = line.replace(i,temp)
    out += line
infile.close()
print(out)

# 1662674, 2022-10-29 10:05:26, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
out = ""
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()

# 1662681, 2022-10-29 10:05:34, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
out = ""
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()
# 1662749, 2022-10-29 10:07:49, P---- (20%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()
# 1662854, 2022-10-29 10:10:36, PPPP- (80%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    temp = [i for i in line.split()]
    col += temp
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            if temp not in rep: rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()

# 1662905, 2022-10-29 10:12:15, PPPP- (80%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    for i in (line.split()):
        if i not in col: col.append(i)
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            if temp not in rep: rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()

# 1663231, 2022-10-29 10:20:06, PPPP- (80%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    for i in (line.split()):
        if i.isalnum() == True and i not in col: col.append(i)
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            if temp not in rep: rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()

# 1663474, 2022-10-29 10:25:30, PPPP- (80%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    for i in (line.split()):
        if i.isalnum() == True and i not in col: col.append(i)
infile.close()
infile = open(lyricsf,"r")
x = ""
lowx = ""
for line in infile:
    x += line
    lowx += line.lower()
rep = []
for i in col:
    n = 0
    while n != -1:
        n = lowx.find(i,n)
        if n == -1: break
        temp = x[n:n+len(i)]
        if temp not in rep: rep.append(temp)
        n += len(i)
for i in rep:
    temp = "<" + i.lower() + ">" + i + "</>"
    x = x.replace(i,temp)
print(x)
infile.close()
# 1663487, 2022-10-29 10:25:40, PPPP- (80%)

colorf = str(input().strip())
lyricsf = str(input().strip())
col = []
infile = open(colorf,"r")
for line in infile:
    line = line.lower()
    for i in (line.split()):
        if i.isalnum() == True and i not in col: col.append(i)
infile.close()
infile = open(lyricsf,"r")
for line in infile:
    rep = []
    low = line.lower()
    for i in col:
        n = 0
        while n != -1:
            n = low.find(i,n)
            if n == -1: break
            temp = line[n:n+len(i)]
            if temp not in rep: rep.append(temp)
            n += len(i)
    for i in rep:
        temp = "<" + i.lower() + ">" + i + "</>"
        line = line.replace(i,temp)
    print(line)
infile.close()

6531306921
# 1663002, 2022-10-29 10:14:39, ----- (0%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  a=line.split()
  for i in a:
    colorlist.append(i.lower())
d.close
d=open(file2,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  a=line.split()
  for i in a:
    if i.lower() in colorlist:
      line.replace(i,'<'+i.lower()+'>'+i+'</>')
d.close
# 1663710, 2022-10-29 10:30:05, P---- (20%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  a=line.split()
  for i in a:
    colorlist.append(i.lower())

d.close
d=open(file2,"r")
lines=d.readlines()

for line in lines:
  a=line.lower()

  for i in colorlist:
    if i in a:
      x=a.find(i)
      line=line[:x]+'<'+i+'>'+line[x:x+len(i)]+'</>'+line[x+len(i):]
      a=line.lower()
  print(line)
d.close
# 1663715, 2022-10-29 10:30:14, ----- (0%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  a=line.split()
  for i in a:
    colorlist.append(i.lower())

d.close
d=open(file2,"r")
lines=d.readlines()

for line in lines:
  a=line.lower()

  for i in colorlist:
    if i in a:
      x=a.find(i)
      line=line[:x]+'<'+i+'>'+line[x:x+len(i)]+'</>'+line[x+len(i):]
      a=line.lower()
  
d.close
# 1663822, 2022-10-29 10:32:12, PPPP- (80%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  a=line.split()
  for i in a:
    colorlist.append(i.lower())

d.close
d=open(file2,"r")
lines=d.readlines()

for line in lines:
  a=line.lower()

  for i in colorlist:
    if i in a:
      x=a.find(i)
      line=line.replace(line[x:x+len(i)],'<'+i+'>'+line[x:x+len(i)]+'</>')
      a=line.lower()
  print(line)
d.close
# 1663906, 2022-10-29 10:33:35, PPPP- (80%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  a=line.split()
  for i in a:
    if i not in colorlist:
      colorlist.append(i.lower())

d.close
d=open(file2,"r")
lines=d.readlines()

for line in lines:
  a=line.lower()

  for i in colorlist:
    if i in a:
      x=a.find(i)
      line=line.replace(line[x:x+len(i)],'<'+i+'>'+line[x:x+len(i)]+'</>')
      a=line.lower()
  print(line)
d.close
# 1663930, 2022-10-29 10:34:03, PPPP- (80%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  a=line.split()
  for i in a:
    if i.lower() not in colorlist:
      colorlist.append(i.lower())

d.close
d=open(file2,"r")
lines=d.readlines()

for line in lines:
  a=line.lower()

  for i in colorlist:
    if i in a:
      x=a.find(i)
      line=line.replace(line[x:x+len(i)],'<'+i+'>'+line[x:x+len(i)]+'</>')
      a=line.lower()
  print(line)
d.close
# 1663997, 2022-10-29 10:35:05, PPPP- (80%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  line=line.strip()
  a=line.split()
  for i in a:
    if i.lower() not in colorlist:
      colorlist.append(i.lower())

d.close
d=open(file2,"r")
lines=d.readlines()

for line in lines:
  a=line.lower()

  for i in colorlist:
    if i in a:
      x=a.find(i)
      line=line.replace(line[x:x+len(i)],'<'+i+'>'+line[x:x+len(i)]+'</>')
      a=line.lower()
  print(line)
d.close
# 1664171, 2022-10-29 10:37:34, PPPP- (80%)

file1=input()
file2=input()
d=open(file1,"r")
lines=d.readlines()
colorlist=[]
for line in lines:
  line=line.strip()
  if len(line)!=0:
    a=line.split()
    for i in a:
      if i.lower() not in colorlist:
        colorlist.append(i.lower())

d.close
d=open(file2,"r")
lines=d.readlines()

for line in lines:
  a=line.lower()

  for i in colorlist:
    if i in a:
      x=a.find(i)
      line=line.replace(line[x:x+len(i)],'<'+i+'>'+line[x:x+len(i)]+'</>')
      a=line.lower()
  print(line)
d.close

6531340121
# 1663116, 2022-10-29 10:17:27, PPPP- (80%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n')
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'":
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
    print(s)
# 1663306, 2022-10-29 10:22:07, PPPP- (80%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n')
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'":
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
            for i in range(len(x)):
                if x[i:].lower() in l:
                    s += x[:i]+'<' + x[i:].lower() + '>' + x[i:] + '</>'
                    x = ''
                    break
    print(s)
# 1663621, 2022-10-29 10:28:10, PPPP- (80%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n')
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'" or lines in '0123456789':
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
            for i in range(len(x)):
                if x[i:].lower() in l:
                    s += x[:i]+'<' + x[i:].lower() + '>' + x[i:] + '</>'
                    x = ''
                    break
    print(s)
# 1663645, 2022-10-29 10:28:42, PPPP- (80%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n')
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'" or lines in '-':
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
            for i in range(len(x)):
                if x[i:].lower() in l:
                    s += x[:i]+'<' + x[i:].lower() + '>' + x[i:] + '</>'
                    x = ''
                    break
    print(s)
# 1663658, 2022-10-29 10:29:00, PPPP- (80%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n')
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'" or lines in '_':
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
            for i in range(len(x)):
                if x[i:].lower() in l:
                    s += x[:i]+'<' + x[i:].lower() + '>' + x[i:] + '</>'
                    x = ''
                    break
    print(s)
# 1663771, 2022-10-29 10:31:08, compilation error (0%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n')
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'" or lines[i] in '0123456789' or lines[i]>'z:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
            for i in range(len(x)):
                if x[i:].lower() in l:
                    s += x[:i]+'<' + x[i:].lower() + '>' + x[i:] + '</>'
                    x = ''
                    break
    print(s)
# 1663787, 2022-10-29 10:31:24, PPPP- (80%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n')
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'":
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
            for i in range(len(x)):
                if x[i:].lower() in l:
                    s += x[:i]+'<' + x[i:].lower() + '>' + x[i:] + '</>'
                    x = ''
                    break
    print(s)
# 1663960, 2022-10-29 10:34:28, PPPP- (80%)

colorf = input().strip()
lyricsf = input().strip()
f1 = open(colorf,'r')
l = []
for lines in f1:
    lines = lines.strip()
    if len(lines) == 0:
        continue
    else:
        color = [e for e in lines.split()]
        for e in color:
            l.append(e.lower())


f2 = open(lyricsf,'r')
for lines in f2:
    lines = lines.strip()
    l1 = [e for e in lines.split()]
    s = ''
    x =''
    if len(lines) == 0:
        print('\n'.strip())
        continue
    else:
        for i in range(len(lines)):
            if 'A'<lines[i]<'z':
                x += lines[i]
            elif lines[i] == ' ' or lines[i] == ',' or lines[i] == '?' or lines[i] == '.' or lines[i] == "'" or lines[i]>'z':
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
                s += lines[i]
            else:
                k = x.lower()
                if k in l:
                    s += '<' + k + '>' + x + '</>'
                else:
                    s += x
                x = ''
            j = x.lower()
            if j in l:
                s += '<' + j + '>' + x + '</>'
                x = ''
            for i in range(len(x)):
                if x[i:].lower() in l:
                    s += x[:i]+'<' + x[i:].lower() + '>' + x[i:] + '</>'
                    x = ''
                    break
        print(s)

6530075721
# 1663024, 2022-10-29 10:15:17, xxxxx (0%)

#f1 = open(input(),'r')
#f2 = open(input(),'r')
f1 = open('data.txt','r')
f2 = open('data1.txt','r')
cl = []
for line in f1 :
    line = line.strip().split()
    for i in line :
        cl.append(i.lower())
print(cl)
for line in f2 :
    for i in cl :
        k = len(i)
        for j in range(len(line)-k) :
            w = line[j:j+k]
            if i == w.lower() :
                line = line.replace(w,'<'+i+'>'+w+'</>')
    print(line)
# 1663055, 2022-10-29 10:15:48, -xxxT (0%)

f1 = open(input(),'r')
f2 = open(input(),'r')
cl = []
for line in f1 :
    line = line.strip().split()
    for i in line :
        cl.append(i.lower())
print(cl)
for line in f2 :
    for i in cl :
        k = len(i)
        for j in range(len(line)-k) :
            w = line[j:j+k]
            if i == w.lower() :
                line = line.replace(w,'<'+i+'>'+w+'</>')
    print(line)
f1.close()
f2.close()
# 1663059, 2022-10-29 10:15:54, -xxxT (0%)

f1 = open(input(),'r')
f2 = open(input(),'r')
cl = []
for line in f1 :
    line = line.strip().split()
    for i in line :
        cl.append(i.lower())
print(cl)
for line in f2 :
    for i in cl :
        k = len(i)
        for j in range(len(line)-k) :
            w = line[j:j+k]
            if i == w.lower() :
                line = line.replace(w,'<'+i+'>'+w+'</>')
    print(line)
f1.close()
f2.close()
# 1663384, 2022-10-29 10:23:44, ----- (0%)

f1 = open(input(),'r')
f2 = open(input(),'r')
cl = []
for line in f1 :
    line = line.strip().split()
    for i in line :
        cl.append(i.lower())
print(cl)
for line in f2 :
    line = line.strip()
    s = line.lower()
    for i in cl :
        k = s.find(i)
        if k != -1 :
            w = line[k:k+len(i)]
            line = line.replace(w,'<'+i+'>'+w+'</>')
            s = line
    print(line)
f1.close()
f2.close()
# 1663558, 2022-10-29 10:27:01, PPPP- (80%)

f1 = open(input(),'r')
f2 = open(input(),'r')
cl = []
for line in f1 :
    line = line.strip().split()
    for i in line :
        cl.append(i.lower())
for line in f2 :
    line = line.strip()
    s = line.lower()
    for i in cl :
        k = s.find(i)
        if k != -1 :
            w = line[k:k+len(i)]
            line = line.replace(w,'<'+i+'>'+w+'</>')
            s = line.lower()
    print(line)
f1.close()
f2.close()
# 1664331, 2022-10-29 10:39:12, P---- (20%)

f1 = open(input(),'r')
f2 = open(input(),'r')
cl = []
for line in f1 :
    line = line.strip().split()
    for i in line :
        cl.append(i.lower())
for line in f2 :
    line = line.strip()
    s = line.lower()
    for i in cl :
        k = s.find(i)
        if k != -1 :
            w = line[k:k+len(i)]
            line = line[:k] + '<'+i+'>'+w+'</>' + line[k+len(i):]
            s = line.lower()
    print(line)
f1.close()
f2.close()
# 1664534, 2022-10-29 10:40:49, P---- (20%)

f1 = open(input(),'r')
f2 = open(input(),'r')
cl = []
for line in f1 :
    line = line.strip().split()
    for i in line :
        cl.append(i.lower())
for line in f2 :
    line = line.strip()
    s = line.lower()
    for i in cl :
        k = s.find(i)
        if k != -1 :
            w = line[k:k+len(i)]
            re = '<' + i + '>' + w + '</>'
            line = line[:k] + re + line[k+len(i):]
            s = line.lower()
    print(line)
f1.close()
f2.close()

6530006421
# 1662537, 2022-10-29 10:01:01, xxxxx (0%)

# Quiz 2_3
# This Code was written by Folkiesss Desu!!

def main():
    filenamae1 = input().strip()
    filenamae2 = input().strip()
    colour = []

    with open(filenamae1, 'r', encoding = 'utf-8') as f1:
        for line in f1:
            colour += [x.lower() for x in line.strip().split()]
    with open(filenamae2, 'r', encoding = 'utf-8') as f2:
        lyric = f2.readlines

    ans = [find_colour(line) for line in lyric]

    print("".join(ans))

def find_color(colour, s):
    new_s = s.lower()

    for c in colour:
        idx = 0
        if new_s.count(c):
            for i in range(count(c)):
                idx = new_s.find(c, idx)
                end_idx = idx + len(c)
                to_replace.append(s[idx:end_idx])
                idx = end_idx + 1
        for w in to_replace:
            s.replace(w, "<{}>".format(c))

    return s

main()

# 1663370, 2022-10-29 10:23:25, xxxxx (0%)

# Quiz 2_3
# This Code was written by Folkiesss Desu!!

def main():
    filenamae1 = input().strip()
    filenamae2 = input().strip()
    colour = []

    with open(filenamae1, 'r', encoding = 'utf-8') as f1:
        for line in f1:
            colour += [x.lower() for x in line.strip().split()]
    with open(filenamae2, 'r', encoding = 'utf-8') as f2:
        lyrics = f2.readlines()

    ans = [find_color(colour, x) for x in lyrics]

    print("".join(ans))

def find_color(colour, s):

    for c in colour:
        s.replace(c, "<"+c+">")

main()

# 1663400, 2022-10-29 10:24:01, ----- (0%)

# Quiz 2_3
# This Code was written by Folkiesss Desu!!

def main():
    filenamae1 = input().strip()
    filenamae2 = input().strip()
    colour = []

    with open(filenamae1, 'r', encoding = 'utf-8') as f1:
        for line in f1:
            colour += [x.lower() for x in line.strip().split()]
    with open(filenamae2, 'r', encoding = 'utf-8') as f2:
        lyrics = f2.readlines()

    ans = [find_color(colour, x) for x in lyrics]

    print("".join(ans))

def find_color(colour, s):

    for c in colour:
        s = s.replace(c, "<"+c+">")
    return s

main()

# 1663452, 2022-10-29 10:24:59, PPPP- (80%)

# Quiz 2_3
# This Code was written by Folkiesss Desu!!

def main():
    filenamae1 = input().strip()
    filenamae2 = input().strip()
    colour = []

    with open(filenamae1, 'r', encoding = 'utf-8') as f1:
        for line in f1:
            colour += [x.lower() for x in line.strip().split()]
    with open(filenamae2, 'r', encoding = 'utf-8') as f2:
        lyrics = f2.readlines()

    ans = [find_color(colour, x) for x in lyrics]

    print("".join(ans))

def find_color(colour, s):

    for c in colour:
        s = s.replace(c, "<"+c+">" + c + "</>")
        
    return s

main()


6530087221
# 1662656, 2022-10-29 10:04:52, ----- (0%)

colorfile = input() #name.txt
songfile = input() #song.txt
colorin = open(colorfile,'r')
song = open(songfile,'r')
color = []
for line in colorin :
    color += line.lower().split()
print(color)
for line in song :
    line = line.lower()
    for i in color:
        line = line.replace(i,'<'+i+'>'+i+'</>')
    print(line)
# 1662669, 2022-10-29 10:05:14, PPPP- (80%)

colorfile = input() #name.txt
songfile = input() #song.txt
colorin = open(colorfile,'r')
song = open(songfile,'r')
color = []
for line in colorin :
    color += line.lower().split()
for line in song :
    line = line.lower()
    for i in color:
        line = line.replace(i,'<'+i+'>'+i+'</>')
    print(line)
# 1662698, 2022-10-29 10:06:04, PPPP- (80%)

colorfile = input() #name.txt
songfile = input() #song.txt
colorin = open(colorfile,'r')
song = open(songfile,'r')
color = []
for line in colorin :
    color += line.lower().split()
for line in song :
    line = line.lower()
    for i in color:
        line = line.replace(i,'<'+i+'>'+i+'</>')
    print(line)
        
    
    

6531801121
# 1663085, 2022-10-29 10:16:25, PPPP- (80%)

color_path = input().strip()
lyrics_path = input().strip()

colors = list()
color_file = open(color_path, "r")
for line in color_file:
    temp = line.strip().split()
    for color in temp:
        colors.append(color.lower())
color_file.close()

lyric_file = open(lyrics_path, "r")
for line in lyric_file:
    for color in colors:
        line = line.replace(color, "<"+color+">"+color+"</>")
    print(line)
lyric_file.close()
# 1663977, 2022-10-29 10:34:45, ----- (0%)

color_path = input().strip()
lyrics_path = input().strip()

colors = list()
color_file = open(color_path, "r")
for line in color_file:
    temp = line.strip().split()
    for color in temp:
        colors.append(color.lower())
color_file.close()

lyric_file = open(lyrics_path, "r")
ly_col = list()
for line in lyric_file:
    tried = [word for word in line.strip().split()]
    for i in range(len(tried)):
        new = ""
        for j in range(len(tried[i])):
            if tried[i][j].isalpha():
                new += tried[i][j]
        ly_col.append(new)
    #for color in colors:
        #line = line.replace(color, "<"+color+">"+color+"</>")
    ly_col = [col for col in ly_col if col.lower() in colors]
    for ly in ly_col:
        line = line.replace(ly, "<"+ly.lower()+">"+ly+"</>")
    print(line)
lyric_file.close()
# 1664151, 2022-10-29 10:37:17, PPPP- (80%)

color_path = input().strip()
lyrics_path = input().strip()

colors = list()
color_file = open(color_path, "r")
for line in color_file:
    temp = line.strip().split()
    for color in temp:
        colors.append(color.lower())
color_file.close()

lyric_file = open(lyrics_path, "r")
ly_col = list()
for line in lyric_file:
    for color in colors:
        line = line.replace(color, "<"+color+">"+color+"</>")
    print(line)
lyric_file.close()

6531805721
# 1663067, 2022-10-29 10:15:59, ----- (0%)

color_file = input() ; song_file = input()

list_color = []
fn = open(color_file,'r')
for i in fn:
    k = i.split()
    m = [n.lower() for n in k]
    for j in m:
        list_color.append(j)

fn.close()

final = []
f = open(song_file,'r')
for i in f:
    p = i.strip()
    for i in list_color:
        p.replace(i,'<'+i+'>'+i+'</>')
    final.append(p)

for i in final:print(i)
# 1663168, 2022-10-29 10:18:50, ----- (0%)

color_file = input() ; song_file = input()

list_color = []
fn = open(color_file,'r')
for i in fn:
    if len(i) > 1:
        k = i.split()
        m = [n.lower() for n in k]
        for j in m:
            list_color.append(j)

fn.close()

final = []
f = open(song_file,'r')
for i in f:
    p = i.strip()
    for i in list_color:
        p.replace(i,'<'+i+'>'+i+'</>')
    final.append(p)
f.close()

for i in final:print(i)
# 1663210, 2022-10-29 10:19:42, PPPP- (80%)

color_file = input() ; song_file = input()

list_color = []
fn = open(color_file,'r')
for i in fn:
    if len(i) > 1:
        k = i.split()
        m = [n.lower() for n in k]
        for j in m:
            list_color.append(j)

fn.close()

final = []
f = open(song_file,'r')
for i in f:
    p = i.strip()
    for i in list_color:
        p = p.replace(i,'<'+i+'>'+i+'</>')
    final.append(p)
f.close()

for i in final:print(i)

6530077021
# 1662941, 2022-10-29 10:13:07, PP--- (40%)

x = input()
y = input()


color = []
c = open(x,'r')
for line in c:
    color += [e.lower() for e in line.split()]


l = open(y,'r')
for line in l:
    result = []
    value = line.strip().split()
    for m in value:
        word = ''
        word += m
        if not  'a' <=  m[0].lower() <= 'z':
            m = m[1:]
        if not  'a' <=  m[-1].lower() <= 'z':
            m = m[:-1]
        
        values = True
        for n in color :
            if n == m.lower():
                values = False
                break
        if values:
            result.append(word)
        else:
            result.append(word.replace(m,'<'+n+'>'+m+'</>'))
    print(' '.join(result))



    

# 1663932, 2022-10-29 10:34:05, PPPP- (80%)

x = input()
y = input()


color = []
c = open(x,'r')
for line in c:
    color += [e.lower() for e in line.split()]


l = open(y,'r')
for line in l:
    result = []
    value = line.strip().split()
    
    for m in value:
        word = ''
        word += m
        if not  'a' <=  m[0].lower() <= 'z':
            m = m[1:]
        if not  'a' <=  m[-1].lower() <= 'z':
            m = m[:-1]
        
        for n in color :
            key = m.lower().find(n)
            if key  != -1:
                word= word.replace(m[key:key+len(n)],'<'+n+'>'+m[key:key+len(n)]+'</>')
        result.append(word)

          
                    
    print(' '.join(result))


6531343021
# 1662344, 2022-10-29 09:54:59, PPPP- (80%)

colorfile = open(input())
lyricsfile = open(input())
colors = []
for line in colorfile:
    for color in line.split():
        colors.append(color.lower())
for line in lyricsfile:
    cap = []
    for i in range(len(line)):
        if 'A' <= line[i] <= 'Z':
            cap.append(i)
    line = line.lower()
    for color in colors:
        if color in line:
            line = line.replace(color, '<'+color+'>'+color+'</>')
    print(line.strip('\n'))
# 1663184, 2022-10-29 10:19:10, PPPP- (80%)

colorfile = open(input())
lyricsfile = open(input())
colors = []
for line in colorfile:
    for color in line.split():
        colors.append(color.lower())
for line in lyricsfile:
    cap = []
    for i in range(len(line)):
        if 'A' <= line[i] <= 'Z':
            cap.append(i)
    line = line.lower()
    for color in colors:
        if color in line:
            line = line.replace(color, '<'+color+'>'+color+'</>')
    print(line.strip('\n'))

6231122421
# 1663160, 2022-10-29 10:18:37, PPPP- (80%)

fc = input()
fs = input()

fco = open(fc)
c = fco.read()
fco.close()
fso = open(fs)
s = fso.read()
fso.close()

def color_tag(word):
    out = '<'+word.lower()+'>'+word+'</>'
    return out

c = c.lower().split()
for e in c:
    s = s.replace(e, color_tag(e))

print(s)


6530140821
# 1662275, 2022-10-29 09:52:36, PPPP- (80%)

filecolor = input()
lyric = input()
colorfile = open(filecolor, 'r')
lyricfile = open(lyric , 'r')
relyric = ""
color = []
for line in colorfile:
    line = line.lower()
    color+=(line.split())
for line in lyricfile:
    relyric+=line
for i in color:
    relyric = relyric.replace(i,"<"+i+">"+i+"</>")
    

print(relyric)





















6530189621
# 1663200, 2022-10-29 10:19:34, PPPP- (80%)

x=input()
y=input()
f1=open(x)
F1=''
for i in f1:
    F1+=i
f2=open(y)
F2=''
for i in f2:
    F2+=i
F22=F2.lower()
F11=F1.lower().split()
for i in F11:
    F22=F22.replace(i,'<'+i+'>'+i+'</>')
print(F22) 

6530210021
# 1664361, 2022-10-29 10:39:32, PPPP- (80%)

filename1 = input().strip()
filename2 = input().strip()
colors = open(filename1)
lyrics = open(filename2)
ls1,ls2 = [],[]
for line in colors:
    line = line.strip().split()
    for e in line:
        ls1.append(e.lower())
for line in lyrics:
    for e in ls1:
        if e in line:
            line = line.replace(e,'<'+ e + '>' + e + '</>')
    print(line)

Max Score = 60


6532136721
# 1662889, 2022-10-29 10:11:45, xxxxx (0%)

color_line = [x.strip() for x in open(input().strip(), "r").readlines()]
song_list = [x.strip() for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        color.append(j.lower())

for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col +">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        print(word[j], end='')
        j += 1
    print("")



# 1662936, 2022-10-29 10:12:59, PPP-- (60%)

color_line = [x.strip() for x in open(input().strip(), "r").readlines()]
song_list = [x.strip() for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        color.append(j.lower())

for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col +">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        print(word[j:j+1], end='')
        j += 1
    print("")



# 1663040, 2022-10-29 10:15:39, PPP-- (60%)

color_line = [x.strip() for x in open(input().strip(), "r").readlines()]
song_list = [x.strip() for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        color.append(j.strip().lower())

for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col.lower():
                continue
            print("<" + col.lower() +">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        print(word[j:j+1], end='')
        j += 1
    print("")



# 1663109, 2022-10-29 10:17:12, PPP-- (60%)

color_line = [x.strip() for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        color.append(j.lower())

#print(color)
for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col.lower():
                continue
            print("<" + col +">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        print(word[j:j+1], end='')
        j += 1



# 1663309, 2022-10-29 10:22:08, PPP-- (60%)

color_line = [x.strip() for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        color.append(j.lower())

#print(color)
for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col +">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663483, 2022-10-29 10:25:35, PPP-- (60%)

color_line = [x.strip() for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            if c.isalpha():
                s += c
        color.append(s.lower())

#print(color)
for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663508, 2022-10-29 10:26:07, PPP-- (60%)

color_line = [x.strip() for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            assert c.isalpha()
            if c.isalpha():
                s += c
        color.append(s.lower())

#print(color)
for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663579, 2022-10-29 10:27:29, PPP-- (60%)

color_line = [x for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            if c.isalpha():
                s += c
        color.append(s.lower())

#print(color)
for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663684, 2022-10-29 10:29:36, PPP-- (60%)

color_line = [x for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            if c.isalpha():
                s += c
        color.append(s.lower())

#print(color)
for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663742, 2022-10-29 10:30:39, PPPxx (60%)

color_line = [x for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            if c.isalpha():
                s += c
        color.append(s.lower())

#print(color)
for word in song_list:
    j=0
    while j < len(word):
        cnt=0
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            cnt += 1
        assert cnt <= 1
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663783, 2022-10-29 10:31:22, PPP-- (60%)

color_line = [x for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            if c.isalpha():
                s += c
        color.append(s.lower())

color = set(color)
#print(color)
for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663844, 2022-10-29 10:32:42, PPP-- (60%)

color_line = [x for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            if c.isalpha():
                s += c
        if s not in color:
            color.append(s.lower())

for word in song_list:
    j=0
    while j < len(word):
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            break
        if j!=len(word):
            print(word[j], end='')
        j += 1



# 1663888, 2022-10-29 10:33:21, PPPxx (60%)

color_line = [x for x in open(input().strip(), "r").readlines()]
song_list = [x for x in open(input().strip(), "r").readlines()]

color = []

for i in color_line:
    for j in i.split():
        s = ""
        for c in j:
            if c.isalpha():
                s += c
        if s not in color:
            color.append(s.lower())

for word in song_list:
    j=0
    while j < len(word):
        cnt=0
        for col in color:
            if word[j:j+len(col)].lower() != col:
                continue
            print("<" + col + ">" + word[j:j+len(col)] + "</>", end='')
            j += len(col)
            cnt += 1
        assert cnt<=1
        if j!=len(word):
            print(word[j], end='')
        j += 1




6532120621
# 1662685, 2022-10-29 10:05:40, PP--- (40%)

f1_n = input()
f2_n = input()
f1 = open(f1_n, "r")
colors = set()
for line in f1:
    line = line.strip()
    if line == '':
        continue
    words = line.split(" ")
    for color in words:
        colors.add(color.lower())

def wrap(c):
    return "<{}>{}</>".format(c.lower(), c)

f2 = open(f2_n, "r")
for line in f2:
    line = line.strip()
    if line == '':
        print()
        continue
    words = line.split(" ")
    for word in words:
        s = word
        for color in colors:
            i = 0
            n = len(s)
            m = len(color)
            while i + m <= n:
                if s[i: i+m].lower() == color:
 #                   print('find {}, from {} ->'.format(color, s), end='')
                    k = wrap(s[i: i+m])
                    s = s[:i] + k + s[i+m:]
                    i += len(k)
 #                   print(s)
                else:
                    i += 1
        print(s, end=' ')
    print()

f1.close()
f2.close()


# 1662848, 2022-10-29 10:10:29, PP--- (40%)

f1_n = input()
f2_n = input()
f1 = open(f1_n, "r")
colors = set()
for line in f1:
    line = line.strip()
    if line == '':
        continue
    words = line.split(" ")
    for color in words:
        colors.add(color.lower())

# print(colors)

f2 = open(f2_n, "r")
for line in f2:
    line = line.strip()
    if line == '':
        print()
        continue
    for color in colors:
        line = line.replace(color, "<{}>{}</>".format(color, color))
    print(line)

# 1663036, 2022-10-29 10:15:34, PPTTP (60%)

f1_n = input()
f2_n = input()
f1 = open(f1_n, "r")
colors = set()
for line in f1:
    line = line.strip()
    if line == '':
        continue
    words = line.split(" ")
    for color in words:
        colors.add(color.lower())

def wrap(c):
    return "<{}>{}</>".format(c.lower(), c)

f2 = open(f2_n, "r")
for line in f2:
    line = line.strip()
    if line == '':
        print()
        continue
    words = line.split(" ")
    for word in words:
        s = word
        for color in colors:
            i = 0
            n = len(s)
            m = len(color)
            while i + m <= len(s):
                if s[i: i+m].lower() == color:
 #                   print('find {}, from {} ->'.format(color, s), end='')
                    k = wrap(s[i: i+m])
                    s = s[:i] + k + s[i+m:]
                    i += len(k)
 #                   print(s)
                else:
                    i += 1
        print(s, end=' ')
    print()

f1.close()
f2.close()


# 1663257, 2022-10-29 10:20:57, PPTTP (60%)

f1_n = input()
f2_n = input()
f1 = open(f1_n, "r")
colors = set()
for line in f1:
    line = line.strip()
    if line == '':
        continue
    words = line.split(" ")
    for color in words:
        colors.add(color.lower())

def wrap(c):
    return "<{}>{}</>".format(c.lower(), c)

# f2 = open(f2_n, "r")
# for line in f2:
#     line = line.strip()
#     if line == '':
#         print()
#         continue
#     words = line.split(" ")
#     for word in words:
#         s = word
#         for color in colors:
#             i = 0
#             m = len(color)
#             while i + m <= len(s):
#                 if s[i: i+m].lower() == color:
#  #                   print('find {}, from {} ->'.format(color, s), end='')
#                     k = wrap(s[i: i+m])
#                     s = s[:i] + k + s[i+m:]
#                     i += len(k)
#  #                   print(s)
#                 else:
#                     i += 1
#         print(s, end=' ')
#     print()

color_len = set()
for x in colors:
    color_len.add(len(x))

f2 = open(f2_n, "r")
for line in f2:
    line = line.strip()
    if line == '':
        print()
        continue
    words = line.split(" ")
    for word in words:
        s = word
        for m in color_len:
            i = 0
            while i + m <= len(s):
                if s[i: i+m].lower() in colors:
                    k = wrap(s[i: i+m])
                    s = s[:i] + k + s[i+m:]
                    i += len(k)
                else:
                    i += 1
        print(s, end=' ')
    print()
f1.close()
f2.close()


# 1663812, 2022-10-29 10:32:03, PPTTP (60%)

f1_n = input()
f2_n = input()
f1 = open(f1_n, "r")
colors = set()
for line in f1:
    line = line.strip()
    if line == '':
        continue
    words = line.split(" ")
    for color in words:
        colors.add(color.lower())

def wrap(c):
    return "<{}>{}</>".format(c.lower(), c)

# f2 = open(f2_n, "r")
# for line in f2:
#     line = line.strip()
#     if line == '':
#         print()
#         continue
#     words = line.split(" ")
#     for word in words:
#         s = word
#         for color in colors:
#             i = 0
#             m = len(color)
#             while i + m <= len(s):
#                 if s[i: i+m].lower() == color:
#  #                   print('find {}, from {} ->'.format(color, s), end='')
#                     k = wrap(s[i: i+m])
#                     s = s[:i] + k + s[i+m:]
#                     i += len(k)
#  #                   print(s)
#                 else:
#                     i += 1
#         print(s, end=' ')
#     print()

color_len = set()
for x in colors:
    color_len.add(len(x))

mm = min(color_len)

f2 = open(f2_n, "r")
for line in f2:
    line = line.strip()
    if line == '':
        print()
        continue
    words = line.split(" ")
    l = ""
    for word in words:
        i = 0
        n = len(word)
        while i + mm <= n:
            found = False
            for m in color_len:
                if i + m <= n and word[i: i+m].lower() in colors:
                    l += wrap(word[i:i+m])
                    i += m
                    found = True
                    break
            if not found:
                l += word[i]
                i += 1
        while i < n:
            l += word[i]
            i += 1
        l += ' '
    print(l)
f1.close()
f2.close()


# 1663874, 2022-10-29 10:33:11, PPTTP (60%)

f1_n = input()
f2_n = input()
f1 = open(f1_n, "r")
colors = set()
for line in f1:
    line = line.strip()
    if line == '':
        continue
    words = line.split(" ")
    for color in words:
        colors.add(color.lower())

def wrap(c):
    return "<{}>{}</>".format(c.lower(), c)

# f2 = open(f2_n, "r")
# for line in f2:
#     line = line.strip()
#     if line == '':
#         print()
#         continue
#     words = line.split(" ")
#     for word in words:
#         s = word
#         for color in colors:
#             i = 0
#             m = len(color)
#             while i + m <= len(s):
#                 if s[i: i+m].lower() == color:
#  #                   print('find {}, from {} ->'.format(color, s), end='')
#                     k = wrap(s[i: i+m])
#                     s = s[:i] + k + s[i+m:]
#                     i += len(k)
#  #                   print(s)
#                 else:
#                     i += 1
#         print(s, end=' ')
#     print()

color_len = set()
for x in colors:
    color_len.add(len(x))

mm = min(color_len)

f2 = open(f2_n, "r")
for line in f2:
    line = line.strip()
    if line == '':
        print()
        continue
    words = line.split(" ")
    l = ""
    for word in words:
        s = word.lower()
        i = 0
        n = len(word)
        while i + mm <= n:
            found = False
            for m in color_len:
                if i + m <= n and s[i: i+m] in colors:
                    l += wrap(word[i:i+m])
                    i += m
                    found = True
                    break
            if not found:
                l += word[i]
                i += 1
        l += word[i:n] + ' '
    print(l)
f1.close()
f2.close()



6230148621
# 1662762, 2022-10-29 10:08:15, PPP-- (60%)

color_file_name = input().strip()
song_list_name = input().strip()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

color_file = open(color_file_name, "r")
color_list = []
for line in color_file:
    line_strip = line.strip()
    color_list += line_strip.split()
color_file.close()

song_file = open(song_list_name, "r")
song_list = []
for line in song_file:
    line_strip = line.strip()
    for color in color_list:
        line_strip = line_strip.replace(color, "<" + color + ">" + color + "</>")
    song_list.append(line_strip)
for song in song_list:
    print(song)
song_file.close()
# 1663627, 2022-10-29 10:28:18, PPP-- (60%)

color_file_name = input().strip()
song_list_name = input().strip()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

color_file = open(color_file_name, "r")
color_list = []
for line in color_file:
    line_strip = line.strip()
    color_list += line_strip.split()
color_file.close()

song_file = open(song_list_name, "r")
song_list = []
for line in song_file:
    line_strip = line.strip()
    for color in color_list:
        line_strip = line_strip.replace(color, "<" + color + ">" + color + "</>")
    song_list.append(line_strip)
for song in song_list:
    print(song)
song_file.close()






# 1663717, 2022-10-29 10:30:15, PPP-- (60%)

color_file_name = input().strip()
song_list_name = input().strip()
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

color_file = open(color_file_name, "r")
color_list = []
for line in color_file:
    line_strip = line.strip()
    color_list += line_strip.split()
color_file.close()

def output_word_song_list(song_list):
    start = 0
    end = 0
    out = []
    for word in song_list:
        for i in range(len(word)):
            if word[i] in alpha:
                start = i
                break
        for i in range(len(word)-1, -1, -1):
            if word[i] in alpha:
                end = i
                break
        out.append(word[start:end+1])
    return out

song_file = open(song_list_name, "r")
song_list = []
for line in song_file:
    line_strip = line.strip()
    line_split = line_strip.split()
    words_song = output_word_song_list(line_split)
    for color in color_list:
        can_rep = False
        if color in line_strip:
            can_rep = True
            line_strip = line_strip.replace(color, "<" + color + ">" + color + "</>")
        if not can_rep and color.lower() in line_strip.lower():
            for word in words_song:
                if color.lower() == word.lower():
                    line_strip = line_strip.replace(word, "<" + color.lower() + ">" + word + "</>")
                    break
            
            
    song_list.append(line_strip)
for song in song_list:
    print(song)
song_file.close()








6530105921
# 1662996, 2022-10-29 10:14:28, ----- (0%)

colorf = input().strip()
songf = input().strip()
cf = open(colorf)
sf = open(songf)
# cf = open("color.txt")
# sf = open("song.txt")
allcolor = []
song = ""
for line in cf:
    allcolor += line.strip().split()
for line in sf:
    song += line
for e in allcolor:
    song.replace(e,"<"+e+">"+e+"</>")
print(song)
# 1663042, 2022-10-29 10:15:40, ----- (0%)

colorf = input().strip()
songf = input().strip()
cf = open(colorf)
sf = open(songf)
# cf = open("color.txt")
# sf = open("song.txt")
allcolor = []
song = ""
for line in cf:
    allcolor += line.strip().split()
for line in sf:
    song += line
for e in allcolor:
    song.replace(e,"<"+e+">"+e+"</>")
print(song)
# 1663197, 2022-10-29 10:19:28, PPP-- (60%)

colorf = input().strip()
songf = input().strip()
cf = open(colorf)
sf = open(songf)
# cf = open("color.txt")
# sf = open("song.txt")
allcolor = []
song = ""
for line in cf:
    allcolor += line.strip().split()
for line in sf:
    song += line
for e in allcolor:
    song = song.replace(e,"<"+e+">"+e+"</>")
print(song)

6531305221
# 1663054, 2022-10-29 10:15:48, PPP-- (60%)

color = input()
song = input()
co = []
x = open(color, 'r')
for i in x:
    i = i.strip()
    i = i.split()
    for j in i:
        co.append(j)
x.close()

y = open(song, 'r')
for i in y:
    i = i.strip()
    for j in co:
        i = i.replace(j, ('<'+str(j)+'>'+str(j)+'</>'))

    print(i)
x.close()

Max Score = 40


6532124121
# 1662297, 2022-10-29 09:53:27, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split()
    #print("fff",w,line)
    ans = ""
    for i in w:
        found = False
        for j in lc:
            if(j in i.lower()):
                n = len(j)
                fid = i.lower().find(j[0])
                d = ""
                d+=i[:fid]
                d+="<"+j+">"
                d+=i[fid:fid+n]
                d+="</>"
                d+=i[fid+n:]
                ans+=d+" "
                found = True
        if(found==False):
            ans+=i+" "
    print(ans)

inc.close()
# 1662387, 2022-10-29 09:56:35, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split()
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        for j in lc:
            if(j in i.lower()):
                n = len(j)
                fid = i.lower().find(j[0])
                d = ""
                d+=i[:fid]
                d+="<"+j+">"
                d+=i[fid:fid+n]
                d+="</>"
                d+=i[fid+n:]
                ans+=d+" "
                found = True
        if(found==False):
            ans+=i+" "
    print(ans)

inc.close()
# 1662527, 2022-10-29 10:00:45, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split()
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        for j in lc:
            if(j in i.lower()):
                n = len(j)
                fid = i.lower().find(j[0])
                d = ""
                d+=i[:fid]
                d+="<"+j+">"
                d+=i[fid:fid+n]
                d+="</>"
                d+=i[fid+n:]
                ans+=d+" "
                found = True
                break
        if(found==False):
            ans+=i+" "
    print(ans)

inc.close()
# 1662700, 2022-10-29 10:06:06, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split()
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i.lower()
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d):
                n = len(j)
                fid = d.find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans)

inc.close()
# 1662909, 2022-10-29 10:12:23, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split()
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans)

inc.close()
# 1663066, 2022-10-29 10:15:58, ----- (0%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split(" ")
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans)

inc.close()
# 1663092, 2022-10-29 10:16:35, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split(" ")
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans)

inc.close()
# 1663166, 2022-10-29 10:18:49, ----- (0%)

"""
color.txt
song.txt
"""
color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split(" ")
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans.strip())

inc.close()
# 1663248, 2022-10-29 10:20:42, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
inc = open(song,"r")
for line in inc:
    w = line.strip().split(" ")
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans)
inc.close()
# 1663566, 2022-10-29 10:27:14, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
ins = open(song,"r")
for line in ins:
    w = line.strip().split(" ")
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans)
ins.close()
# 1663619, 2022-10-29 10:28:08, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
ins = open(song,"r")
for line in ins:
    w = line.strip().split()
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        if(found==False):
            ans+=i+" "
        else:
            ans+=d+" "
    print(ans)
ins.close()
# 1663677, 2022-10-29 10:29:24, compilation error (0%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
ins = open(song,"r")
for line in ins:
    w = line.strip().split()
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
          ans+=d+" "
    print(ans)
ins.close()
# 1663734, 2022-10-29 10:30:33, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            lc.append(i.lower())
inc.close()
#print(lc)
ins = open(song,"r")
for line in ins:
    w = line.strip().split(" ")
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        ans+=d+" "
    print(ans)
ins.close()
# 1664186, 2022-10-29 10:37:49, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            ans = ""
            k = i.lower()
            for j in k:
                if(j in "abcdefghijklmnopqrstuvwxyz"):
                    ans+=j
            lc.append(ans)
inc.close()
#print(lc)
ins = open(song,"r")
for line in ins:
    w = line.strip().split(" ")
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        #print(d)
        ans+=d+" "
    print(ans)
ins.close()
# 1664269, 2022-10-29 10:38:38, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            ans = ""
            k = i.lower()
            for j in k:
                if(j in "abcdefghijklmnopqrstuvwxyz"):
                    ans+=j
            lc.append(ans)
inc.close()
#print(lc)
ins = open(song,"r")
for line in ins:
    w = line.strip().split()
    if(line=="\n"):
        print("")
        continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        #print(d)
        ans+=d+" "
    print(ans)
ins.close()
# 1664440, 2022-10-29 10:40:07, PP--- (40%)

color = input()
song = input()
lc = []
inc = open(color,"r")
for line in inc:
    w = line.strip().split()
    if(len(w)>0):
        for i in w:
            ans = ""
            k = i.lower()
            for j in k:
                if(j in "abcdefghijklmnopqrstuvwxyz"):
                    ans+=j
            lc.append(ans)
inc.close()
#print(lc)
ins = open(song,"r")
for line in ins:
    w = line.strip().split()
    #if(line=="\n"):
    #    print("")
    #    continue
    ans = ""
    for i in w:
        found = False
        d = i
        for j in lc:
            #d = i.lower()
            tmp = d
            if(j in d.lower()):
                n = len(j)
                fid = d.lower().find(j[0])
                d = ""
                d+=tmp[:fid]
                d+="<"+j+">"
                d+=tmp[fid:fid+n]
                d+="</>"
                d+=tmp[fid+n:]
                tmp = d
                found = True
        #print(d)
        ans+=d+" "
    print(ans)
ins.close()

6532125821
# 1663615, 2022-10-29 10:28:04, xxxxx (0%)


cf = open(input() , "r")
tf = open(input() , "r")

color_set = set()

def new_substring(color_name):
    return "<" + color_name.lower() + ">" + color_name + "</>"

def new_line(line):
    ol = line
    nl = ""
    while(len(ol) > 0):
        mn_idx = 20000000
        color_name = ""
        tmp_ol = ol.lower()
        for color in color_set:
            f_idx = tmp_ol.find(color.lower())
            if(f_idx != -1):
                if(f_idx < mn_idx):
                    mn_idx = f_idx
                    color_name = color
        if(mn_idx == 20000000):
            nl += ol
            ol = ""
        else:
            nl += ol[:mn_idx]
            nl += new_substring(color_name)
            ol = ol[mn_idx + len(color_name):]
    return nl
    
line = cf.readline().strip()
while(len(line) > 0):
    for color in line.split():
        color_set.append(color.lower())
    line = cf.readline().strip()

line = tf.readline().strip()
while(len(line) > 0):
    print(new_line(line))
    line = tf.readline().strip()
# 1663739, 2022-10-29 10:30:35, xxxxx (0%)


cf = open(input(), 'r')
tf = open(input(), 'r')

color_set = set()

def new_substring(color_name):
    return "<" + color_name.lower() + ">" + color_name + "</>"

def new_line(line):
    ol = line
    nl = ""
    while(len(ol) > 0):
        mn_idx = 20000000
        color_name = ""
        tmp_ol = ol.lower()
        for color in color_set:
            f_idx = tmp_ol.find(color.lower())
            if(f_idx != -1):
                if(f_idx < mn_idx):
                    mn_idx = f_idx
                    color_name = color
        if(mn_idx == 20000000):
            nl += ol
            ol = ""
        else:
            nl += ol[:mn_idx]
            nl += new_substring(color_name)
            ol = ol[mn_idx + len(color_name):]
    return nl
    
line = cf.readline().strip()
while(len(line) > 0):
    for color in line.split():
        color_set.append(color.lower())
    line = cf.readline().strip()

line = tf.readline().strip()
while(len(line) > 0):
    print(new_line(line))
    line = tf.readline().strip()
# 1663999, 2022-10-29 10:35:06, PP--- (40%)


cf = open(input(), 'r')
tf = open(input(), 'r')

color_set = set()

def new_substring(color_name):
    return "<" + color_name.lower() + ">" + color_name + "</>"

def new_line(line):
    ol = line
    nl = ""
    while(len(ol) > 0):
        mn_idx = 20000000
        color_name = ""
        tmp_ol = ol.lower()
        for color in color_set:
            f_idx = tmp_ol.find(color.lower())
            if(f_idx != -1):
                if(f_idx < mn_idx):
                    mn_idx = f_idx
                    color_name = color
        if(mn_idx == 20000000):
            nl += ol
            ol = ""
        else:
            nl += ol[:mn_idx]
            nl += new_substring(color_name)
            ol = ol[mn_idx + len(color_name):]
    return nl
    
line = cf.readline().strip()
while(len(line) > 0):
    for color in line.split():
        color_set = color_set | set([color.lower()])
    line = cf.readline().strip()

line = tf.readline().strip()
while(len(line) > 0):
    print(new_line(line))
    line = tf.readline().strip()
# 1664185, 2022-10-29 10:37:48, PP--- (40%)


cf = open(input(), 'r')
tf = open(input(), 'r')

color_set = set()

def new_substring(color_name):
    return "<" + color_name.lower() + ">" + color_name + "</>"

def new_line(line):
    ol = line
    nl = ""
    while(len(ol) > 0):
        mn_idx = 20000000
        color_name = ""
        tmp_ol = ol.lower()
        for color in color_set:
            f_idx = tmp_ol.find(color.lower())
            if(f_idx != -1):
                if(f_idx < mn_idx):
                    mn_idx = f_idx
                    color_name = color
        if(mn_idx == 20000000):
            nl += ol
            ol = ""
        else:
            nl += ol[:mn_idx]
            nl += new_substring(color_name)
            ol = ol[mn_idx + len(color_name):]
    return nl
    
line = cf.readline().strip()
while(len(line) > 0):
    for color in line.split():
        color_set = color_set | set([color])
    line = cf.readline().strip()

line = tf.readline().strip()
while(len(line) > 0):
    print(new_line(line))
    line = tf.readline().strip()
# 1664332, 2022-10-29 10:39:12, xxxxx (0%)


cf = open(input(), 'r')
tf = open(input(), 'r')

color_set = set()

def new_substring(color_name):
    return "<" + color_name.lower() + ">" + color_name + "</>"

def new_line(line):
    ol = line
    nl = ""
    while(len(ol) > 0):
        mn_idx = 20000000
        color_name = ""
        tmp_ol = ol.lower()
        for color in color_set:
            f_idx = tmp_ol.find(color.lower())
            if(f_idx != -1):
                if(f_idx < mn_idx):
                    mn_idx = f_idx
                    color_name = ol[f_idx , f_idx + len(color)]
        if(mn_idx == 20000000):
            nl += ol
            ol = ""
        else:
            nl += ol[:mn_idx]
            nl += new_substring(color_name)
            ol = ol[mn_idx + len(color_name):]
    return nl
    
line = cf.readline().strip()
while(len(line) > 0):
    for color in line.split():
        color_set = color_set | set([color])
    line = cf.readline().strip()

line = tf.readline().strip()
while(len(line) > 0):
    print(new_line(line))
    line = tf.readline().strip()
# 1664382, 2022-10-29 10:39:41, PP--- (40%)


cf = open(input(), 'r')
tf = open(input(), 'r')

color_set = set()

def new_substring(color_name):
    return "<" + color_name.lower() + ">" + color_name + "</>"

def new_line(line):
    ol = line
    nl = ""
    while(len(ol) > 0):
        mn_idx = 20000000
        color_name = ""
        tmp_ol = ol.lower()
        for color in color_set:
            f_idx = tmp_ol.find(color.lower())
            if(f_idx != -1):
                if(f_idx < mn_idx):
                    mn_idx = f_idx
                    color_name = ol[f_idx : f_idx + len(color)]
        if(mn_idx == 20000000):
            nl += ol
            ol = ""
        else:
            nl += ol[:mn_idx]
            nl += new_substring(color_name)
            ol = ol[mn_idx + len(color_name):]
    return nl
    
line = cf.readline().strip()
while(len(line) > 0):
    for color in line.split():
        color_set = color_set | set([color])
    line = cf.readline().strip()

line = tf.readline().strip()
while(len(line) > 0):
    print(new_line(line))
    line = tf.readline().strip()
# 1664458, 2022-10-29 10:40:17, PP--- (40%)


cf = open(input(), 'r')
tf = open(input(), 'r')

color_set = set()

def new_substring(color_name):
    return "<" + color_name.lower() + ">" + color_name + "</>"

def new_line(line):
    ol = line
    nl = ""
    while(len(ol) > 0):
        mn_idx = 20000000
        color_name = ""
        tmp_ol = ol.lower()
        for color in color_set:
            f_idx = tmp_ol.find(color.lower())
            if(f_idx != -1):
                if(f_idx < mn_idx):
                    mn_idx = f_idx
                    color_name = ol[f_idx : f_idx + len(color)]
        if(mn_idx == 20000000):
            nl += ol
            ol = ""
        else:
            nl += ol[:mn_idx]
            nl += new_substring(color_name)
            ol = ol[mn_idx + len(color_name):]
    return nl
    
line = cf.readline().strip()
while(len(line) > 0):
    for color in line.split():
        color_set = color_set | set([color])
    line = cf.readline().strip()

line = tf.readline().strip()
while(len(line) > 0):
    print(new_line(line))
    line = tf.readline().strip()

6231422721
# 1663300, 2022-10-29 10:22:00, xxxxx (0%)

name1 = input()
fn1 = open(name1,"r")
color = []
for i in f1 :
    color.append(i.split())
fn1.close()

def match(a,b) :
    for i in b :
        if a.find(i) != -1 :
            return(a[0:a.lower().find(i.lower())]+"<"+i+">"+a[a.lower().find(i.lower()):a.lower().find(i.lower())+len(i)]+"</>"+a[a.lower().find(i.lower())+len(i):])
    return a
    
    
       
change = []
for i in color :
    for e in i :
        change.append(e.lower())
result = []
name2 = input()
fn2 = open(name2, "r")
for i in fn2 :
    result.append(i.split())
fn2.close()
for i in result :
    report = str()
    for e in i :
        report += match(e,change)
    print(report)
# 1663486, 2022-10-29 10:25:39, PP--- (40%)

name1 = input()
fn1 = open(name1,"r")
color = []
for i in fn1 :
    color.append(i.split())
fn1.close()

def match(a,b) :
    for i in b :
        if a.find(i) != -1 :
            return(a[0:a.lower().find(i.lower())]+"<"+i+">"+a[a.lower().find(i.lower()):a.lower().find(i.lower())+len(i)]+"</>"+a[a.lower().find(i.lower())+len(i):])
    return a
    
    
       
change = []
for i in color :
    for e in i :
        change.append(e.lower())
result = []
name2 = input()
fn2 = open(name2, "r")
for i in fn2 :
    result.append(i.split())
fn2.close()
for i in result :
    report = str()
    for e in i :
        report += match(e,change)+" "
    print(report)
# 1663526, 2022-10-29 10:26:30, PP--- (40%)

name1 = input()
fn1 = open(name1,"r")
color = []
for i in fn1 :
    color.append(i.split())
fn1.close()

def match(a,b) :
    for i in b :
        if a.lower().find(i.lower()) != -1 :
            return(a[0:a.lower().find(i.lower())]+"<"+i+">"+a[a.lower().find(i.lower()):a.lower().find(i.lower())+len(i)]+"</>"+a[a.lower().find(i.lower())+len(i):])
    return a
    
    
       
change = []
for i in color :
    for e in i :
        change.append(e.lower())
result = []
name2 = input()
fn2 = open(name2, "r")
for i in fn2 :
    result.append(i.split())
fn2.close()
for i in result :
    report = str()
    for e in i :
        report += match(e,change)+" "
    print(report)
# 1663665, 2022-10-29 10:29:08, PP--- (40%)

name1 = input()
fn1 = open(name1,"r")
color = []
for i in fn1 :
    color.append(i.split())
fn1.close()

def match(a,b) :
    for i in b :
        if a.lower().find(i.lower()) != -1 :
            return(a[0:a.lower().find(i.lower())]+"<"+i+">"+a[a.lower().find(i.lower()):a.lower().find(i.lower())+len(i)]+"</>"+a[a.lower().find(i.lower())+len(i):])
    return a
    
    
       
change = []
for i in color :
    for e in i :
        change.append(e.lower())
result = []
name2 = input()
fn2 = open(name2, "r")
for i in fn2 :
    result.append(i.split())
fn2.close()
for i in result :
    report = str()
    for e in i :
        report += match(e,change)+" "
    print(report)
# 1663748, 2022-10-29 10:30:44, PP--- (40%)

name1 = input()
fn1 = open(name1,"r")
color = []
for i in fn1 :
    color.append(i.split())
fn1.close()

def match(a,b) :
    for i in b :
        if a.lower().find(i.lower()) != -1 :
            return(a[0:a.lower().find(i.lower())]+"<"+i.lower()+">"+a[a.lower().find(i.lower()):a.lower().find(i.lower())+len(i)]+"</>"+a[a.lower().find(i.lower())+len(i):])
    return a
    
    
       
change = []
for i in color :
    for e in i :
        change.append(e.lower())
result = []
name2 = input()
fn2 = open(name2, "r")
for i in fn2 :
    result.append(i.split())
fn2.close()
for i in result :
    report = str()
    for e in i :
        report += match(e,change)+" "
    print(report)

6530003521
# 1663219, 2022-10-29 10:19:52, PP--- (40%)

def color_tag(t) :
    a = t.lower()
    return '<'+a+'>'+t+'</>'
def color_line(t,color) :
    text = []
    for e in t :
        if e.lower() in color :
            text.append(color_tag(e))
        else : text.append(e)
    return ' '.join(text)
            

color_file_name = input()
song_file_name = input()
cf = open(color_file_name)
sf = open(song_file_name)
color = []

for line in cf :
    a = line.strip().split()
    for e in a :
        color.append(e.lower())
 
for line in sf :
    print(color_line(line.strip().split(),color))
    
cf.close() ; sf.close()

# 1663846, 2022-10-29 10:32:43, PP--- (40%)

def color_tag(t) :
    a = t.lower()
    return '<'+a+'>'+t+'</>'
def color_line(t,color) :
    text = []
    Found = False
    for e in t :
        if e.lower() in color :
            text.append(color_tag(e))
        
        else :
            for k in color :
                if k in e :
                    j = e.find(k)
                    text.append(e[0:j] + color_tag(e[j:]))
                    Found = True
                    break
            if not Found :
                text.append(e)
    return ' '.join(text)

color_file_name = input()
song_file_name = input()
cf = open(color_file_name)
sf = open(song_file_name)
color = []
for line in cf :
    a = line.strip().split()
    for e in a :
        color.append(e.lower())
 
for line in sf :
    a = line.strip().split()
    print(color_line(a,color))
    
cf.close() ; sf.close()
# 1664172, 2022-10-29 10:37:34, PP--- (40%)

def color_tag(t) :
    a = t.lower()
    return '<'+a+'>'+t+'</>'
def color_line(t,color) :
    text = []
    Found = False
    for e in t :
        if e.lower() in color :
            text.append(color_tag(e))
        
        else :
            for k in color :
                if k in e :
                    j = e.find(k)
                    if j == 0 :
                        text.append( color_tag(e[j:]) + e[j:])
                    else :
                        text.append(e[0:j] + color_tag(e[j:]) )
                    Found = True
                    break
            if not Found :
                text.append(e)
    return ' '.join(text)

color_file_name = input()
song_file_name = input()
cf = open(color_file_name)
sf = open(song_file_name)
color = []
for line in cf :
    a = line.strip().split()
    for e in a :
        color.append(e.lower())
 
for line in sf :
    a = line.strip().split()
    print(color_line(a,color))
    
cf.close() ; sf.close()
# 1664422, 2022-10-29 10:40:01, PP--- (40%)

def color_tag(t) :
    a = t.lower()
    return '<'+a+'>'+t+'</>'
def color_line(t,color) :
    text = []
    Found = False
    for e in t :
        if e.lower() in color :
            text.append(color_tag(e))
        
        else :
            for k in color :
                if k in e.lower() :
                    j = e.lower().find(k)
                    if j == 0 :
                        text.append( color_tag(e[0:len(k)]) + e[len(k):])
                    else :
                        text.append(e[0:j] + color_tag(e[j:]) )
                    Found = True
                    break
            if not Found :
                text.append(e)
    return ' '.join(text)

color_file_name = input()
song_file_name = input()
cf = open(color_file_name)
sf = open(song_file_name)
color = []
for line in cf :
    a = line.strip().split()
    for e in a :
        color.append(e.lower())
 
for line in sf :
    a = line.strip().split()
    print(color_line(a,color))
    
cf.close() ; sf.close()
# 1664642, 2022-10-29 10:41:58, PP--- (40%)

def color_tag(t) :
    a = t.lower()
    return '<'+a+'>'+t+'</>'
def color_line(t,color) :
    text = []
    Found = False
    for e in t :
        if e.lower() in color :
            text.append(color_tag(e))
        
        else :
            for k in color :
                if k in e.lower() :
                    j = e.lower().find(k)
                    if j == 0 :
                        text.append( color_tag(e[0:len(k)]) + e[len(k):])
                    else :
                        text.append(e[0:j] + color_tag(e[j:len(k)]) + e[len(k):] )
                    Found = True
                    break
            if not Found :
                text.append(e)
    return ' '.join(text)

color_file_name = input()
song_file_name = input()
cf = open(color_file_name)
sf = open(song_file_name)
color = []
for line in cf :
    a = line.strip().split()
    for e in a :
        color.append(e.lower())
 
for line in sf :
    a = line.strip().split()
    print(color_line(a,color))
    
cf.close() ; sf.close()

6530181521
# 1662679, 2022-10-29 10:05:33, ----- (0%)

f1 = open(input(),'r')
f2 = open(input(),'r')
def test(c,t) :
    if len(c) > len(t) :
        return ''
    x = ''
    for i in range(len(t)-len(c)+1) :
        if c == t[i:i+len(c)].lower() :
            return t[:i] + '<'+c+'>'+t[i:i+len(c)]+'</>' + t[i+len(c):]
    return ''

color = []
for line in f1 :
    color += [e.lower() for e in line.strip().split()]
print(color)
text = []
for line in f2 :
    out = []
    text = line.strip().split()
    for t in text :
        for c in color :
            m = test(c,t)
            if m != '' :
                out.append(m)
                break
        if m == '' :
            out.append(t)
    print(' '.join(out))
f1.close()
f2.close()
# 1662696, 2022-10-29 10:06:02, PP--- (40%)

f1 = open(input(),'r')
f2 = open(input(),'r')
def test(c,t) :
    if len(c) > len(t) :
        return ''
    x = ''
    for i in range(len(t)-len(c)+1) :
        if c == t[i:i+len(c)].lower() :
            return t[:i] + '<'+c+'>'+t[i:i+len(c)]+'</>' + t[i+len(c):]
    return ''

color = []
for line in f1 :
    color += [e.lower() for e in line.strip().split()]
text = []
for line in f2 :
    out = []
    text = line.strip().split()
    for t in text :
        for c in color :
            m = test(c,t)
            if m != '' :
                out.append(m)
                break
        if m == '' :
            out.append(t)
    print(' '.join(out))
f1.close()
f2.close()
# 1662792, 2022-10-29 10:08:53, PP--- (40%)

f1 = open(input(),'r')
f2 = open(input(),'r')
def test(c,t) :
    if len(c) > len(t) :
        return ''
    x = ''
    for i in range(len(t)-len(c)+1) :
        if c == t[i:i+len(c)] :
            return t[:i] + '<'+c+'>'+t[i:i+len(c)]+'</>' + t[i+len(c):]
    return ''

color = []
for line in f1 :
    color += [e.lower() for e in line.strip().split()]
text = []
for line in f2 :
    out = []
    text = line.strip().split()
    for t in text :
        for c in color :
            m = test(c,t)
            if m != '' :
                out.append(m)
                break
        if m == '' :
            out.append(t)
    print(' '.join(out))
f1.close()
f2.close()
# 1663896, 2022-10-29 10:33:26, ----- (0%)

f1 = open(input(),'r')
f2 = open(input(),'r')

color = []
for line in f1 :
    color += [e.lower() for e in line.strip().split()]
text = ''.join(f2.readlines())
q = 0
for c in color :
    t = ''
    for i in range(len(text)-len(c)+1) :
        if q > 0 :
            q -= 1
        else :
            if text[i:i+len(c)].lower() == c :
                t += '<'+c+'>'+text[i:i+len(c)]+'</>'
                q = len(c) - 1
            else :
                t += text[i]
    text = t + t[-len(c)]
print(text)
            

# 1664247, 2022-10-29 10:38:28, P-P-- (40%)

f1 = open(input(),'r')
f2 = open(input(),'r')

color = []
for line in f1 :
    color += [e.lower() for e in line.strip().split()]
text = ''.join(f2.readlines())
q = 0
for c in color :
    t = ''
    for i in range(len(text)-len(c)+1) :
        if q > 0 :
            q -= 1
        else :
            if text[i:i+len(c)].lower() == c :
                t += '<'+c+'>'+text[i:i+len(c)]+'</>'
                q = len(c) - 1
            else :
                t += text[i]
    text = t + text[-len(c)+1:]
print(text)

6531342421
# 1663280, 2022-10-29 10:21:30, PP--- (40%)

f1 = input().strip()
f2 = input().strip()
fn = open(f1,"r")
line = fn.readline().strip()
b=""
c=[]
while len(line) > 0:
    a = line.lower().split()
    for x in a:
        b = b+x
        c.append(x)
    line = fn.readline().strip()
fn = open(f2,"r")
line = fn.readline().strip()
while len(line) > 0:
    ans=""
    t=""
    for i in range(len(line)):
        t = t + line[i]
        if t.lower() not in b:
            ans = ans + t
            t=""
        if t.lower() in c:
            ans = ans + '<' + t.lower() + '>' + t + '</>'
            t=""
    print(ans)
    line = fn.readline().strip()
fn.close()
# 1663373, 2022-10-29 10:23:30, ----- (0%)

f1 = input().strip()
f2 = input().strip()
fn = open(f1,"r")
line = fn.readline().strip()
b=""
c=[]
while len(line) > 0:
    a = line.lower().split()
    for x in a:
        b = b+x+' '
        c.append(x)
    line = fn.readline().strip()
fn = open(f2,"r")
line = fn.readline().strip()
while len(line) > 0:
    ans=""
    t=""
    for i in range(len(line)):
        t = t + line[i]
        if t.lower() not in b:
            ans = ans + t
            t=""
        if t.lower() in c:
            ans = ans + '<' + t.lower() + '>' + t + '</>'
            t=""
    print(ans)
    line = fn.readline().strip()
fn.close()
# 1663382, 2022-10-29 10:23:40, compilation error (0%)

f1 = input().strip()
f2 = input().strip()
fn = open(f1,"r")
line = fn.readline().strip()
b=""
c=[]
while len(line) > 0:
    a = line.lower().split()
    for x in a:
        b = b+x+
        c.append(x)
    line = fn.readline().strip()
fn = open(f2,"r")
line = fn.readline().strip()
while len(line) > 0:
    ans=""
    t=""
    for i in range(len(line)):
        t = t + line[i]
        if t.lower() not in b:
            ans = ans + t
            t=""
        if t.lower() in c:
            ans = ans + '<' + t.lower() + '>' + t + '</>'
            t=""
    print(ans)
    line = fn.readline().strip()
fn.close()
# 1663383, 2022-10-29 10:23:44, PP--- (40%)

f1 = input().strip()
f2 = input().strip()
fn = open(f1,"r")
line = fn.readline().strip()
b=""
c=[]
while len(line) > 0:
    a = line.lower().split()
    for x in a:
        b = b+x
        c.append(x)
    line = fn.readline().strip()
fn = open(f2,"r")
line = fn.readline().strip()
while len(line) > 0:
    ans=""
    t=""
    for i in range(len(line)):
        t = t + line[i]
        if t.lower() not in b:
            ans = ans + t
            t=""
        if t.lower() in c:
            ans = ans + '<' + t.lower() + '>' + t + '</>'
            t=""
    print(ans)
    line = fn.readline().strip()
fn.close()

6532143021
# 1663435, 2022-10-29 10:24:39, ----- (0%)

fcolor = input()
fmusic = input()

f = open(fcolor, 'r')
color = []
for i in f:
    color += [j.lower() for j in i.split()]

f.close()
# print(color)

f = open(fmusic, 'r')
for i in f:
    word = i.split()
    for j in color:
        for k in range(len(word)):
            # print(j,k.lower())
            if j in word[k].lower():
                print(j,k)
                word[k] = '<'+j+'>'+word[k][:len(j)]+'</>'+word[k][len(j):]
                # print(k)


    print(' '.join(word))
f.close()

# color.txt
# music.txt
# 1663637, 2022-10-29 10:28:30, compilation error (0%)

fcolor = input()
fmusic = input()

f = open(fcolor, 'r')
color = []
for i in f:
    color += [j.lower() for j in i.split()]

f.close()
# print(color)

f = open(fmusic, 'r')
for i in f:
    word = i.split()
    for j in color:
        for k in range(len(word)):
            # print(j,k.lower())
            if j in word[k].lower():
                print(j,k)
                word[k] = '<'+j+'>'+word[k][:len(j)]+'</>'+word[k][len(j):]
                # print(k)


    print('fcolor = input()
fmusic = input()

f = open(fcolor, 'r')
color = []
for i in f:
    color += [j.lower() for j in i.split()]

f.close()
# print(color)

f = open(fmusic, 'r')
for i in f:
    word = i.split()
    for j in color:
        for k in range(len(word)):
            # print(j,k.lower())
            if j in word[k].lower():
                index = word[k].lower().index(j)
                word[k] = word[k][:index]+'<'+j+'>'+word[k][index:len(j)]+'</>'+word[k][len(j):]
                # print(k)


    print(' '.join(word))
f.close()

# color.txt
# music.txt '.join(word))
f.close()

# color.txt
# music.txt
# 1663728, 2022-10-29 10:30:29, PP--- (40%)

fcolor = input()
fmusic = input()

f = open(fcolor, 'r')
color = []
for i in f:
    color += [j.lower() for j in i.split()]

f.close()
# print(color)

f = open(fmusic, 'r')
for i in f:
    word = i.split()
    for j in color:
        for k in range(len(word)):
            if j in word[k].lower():
                index = word[k].lower().index(j)
                word[k] = word[k][:index]+'<'+j+'>'+word[k][index:index+len(j)]+'</>'+word[k][index+len(j):]
                # print(k)


    print(' '.join(word))
f.close()

# color.txt
# music.txt
# 1664021, 2022-10-29 10:35:26, PP--- (40%)

fcolor = input()
fmusic = input()

f = open(fcolor, 'r')
color = []
for i in f:
    color += [j.lower() for j in i.split()]

f.close()

f = open(fmusic, 'r')
for i in f:
    word = i.split(' ')
    for j in color:
        for k in range(len(word)):
            if j in word[k].lower():
                index = word[k].lower().index(j)
                word[k] = word[k][:index]+'<'+j+'>'+word[k][index:index+len(j)]+'</>'+word[k][index+len(j):]


    print(' '.join(word))
f.close()

# color.txt
# music.txt

6530164921
# 1662957, 2022-10-29 10:13:39, PP--- (40%)

def color_code(sg,cl):
    check = ""
    res = ""
    for j in cl:
        if j in sg.lower():
            for k in range(len(sg)):
                check += sg[k]
                if j in check.lower():
                    res += check[:len(check)-len(j):]
                    res += "<" + j + ">" + check[len(check)-len(j)::] + "</>"
                    res += sg[len(check)::]
                    return res
        else:
            continue
    return sg
    
    

f1 = open(input(),"r")
f2 = open(input(),"r")
color = []

for line in f1:
    c = str(line).split()
    for i in c:
        color.append(i.lower())

result = []
song = []
for line in f2:
    c = str(line).split()
    for i in c:
        song.append(i)
    song.append("\n")
        
#print(song)
#print(color)

for i in song:
    result.append(color_code(i,color)+" ")
    
for i in result:
    print(i,end="")
            

'''
color.txt
song.txt
'''

        



# 1664276, 2022-10-29 10:38:43, PP--- (40%)

def color_code(sg,cl):
    check = ""
    res = ""
    for j in cl:
        if j in sg.lower():
            for k in range(len(sg)):
                check += sg[k]
                if j in check.lower():
                    res += check[:len(check)-len(j):]
                    res += "<" + j + ">" + check[len(check)-len(j)::] + "</>"
                    res += sg[len(check)::]
                    return res
        else:
            continue
    return sg
    
    

f1 = open(input(),"r")
f2 = open(input(),"r")
color = []

for line in f1:
    c = str(line).split()
    for i in c:
        color.append(i.lower())

result = []
song = []
for line in f2:
    c = str(line).split()
    for i in c:
        song.append(i)
    song.append("\n")
        
#print(song)
#print(color)

for i in song:
    result.append(color_code(i,color))
    if result[::-1] == "\n":
        pass
    else:
        result.append(" ")
    
for i in result:
    print(i,end="")
            

'''
color.txt
song.txt
'''

        



# 1664306, 2022-10-29 10:38:58, PP--- (40%)

def color_code(sg,cl):
    check = ""
    res = ""
    for j in cl:
        if j in sg.lower():
            for k in range(len(sg)):
                check += sg[k]
                if j in check.lower():
                    res += check[:len(check)-len(j):]
                    res += "<" + j + ">" + check[len(check)-len(j)::] + "</>"
                    res += sg[len(check)::]
                    return res
        else:
            continue
    return sg
    
    

f1 = open(input(),"r")
f2 = open(input(),"r")
color = []

for line in f1:
    c = str(line).split()
    for i in c:
        color.append(i.lower())

result = []
song = []
for line in f2:
    c = str(line).split()
    for i in c:
        song.append(i)
    song.append("\n")
        
#print(song)
#print(color)

for i in song:
    result.append(color_code(i,color))
    if result[::-1] == "\n":
        pass
    else:
        result.append(" ")
    
for i in result:
    print(i,end="")
            

'''
color.txt
song.txt
'''

        




6530171221
# 1663364, 2022-10-29 10:23:15, compilation error (0%)

opd = open(input(),'r')
ops = open(input()','r')
colors = []
for i in opd:
    line = i.strip().split()
    for k in range(len(line)):
        colors.append(line[k].lower())
for j in ops:
    linesong = j.strip().split()
    result = ''
    for a in range(len(linesong)):
        clow = linesong[a].lower().strip(',')
        if clow in colors:
            f = '<'+clow+'>'+linesong[a][:-1]+'</>'
            if ',' in linesong[a]:result += f+','+' '
            else: result += f+' '  
        else: result += linesong[a]+' ' 
    print(result) 
# 1663436, 2022-10-29 10:24:39, PP--- (40%)

opd = open(input(),'r')
ops = open(input(),'r')
colors = []
for i in opd:
    line = i.strip().split()
    for k in range(len(line)):
        colors.append(line[k].lower())
for j in ops:
    linesong = j.strip().split()
    result = ''
    for a in range(len(linesong)):
        clow = linesong[a].lower().strip(',')
        if clow in colors:
            f = '<'+clow+'>'+linesong[a]+'</>'
            if ',' in linesong[a]:result += f+','+' '
            else: result += f+' '  
        else: result += linesong[a]+' ' 
    print(result) 
# 1663935, 2022-10-29 10:34:05, PP--- (40%)

opd = open(input(),'r')
ops = open(input(),'r')
colors = []
for i in opd:
    line = i.strip().split()
    for k in range(len(line)):
        colors.append(line[k].lower())
for j in ops:
    linesong = j.strip().split()
    result = ''
    for a in range(len(linesong)):
        clow = linesong[a].lower()
        sp = ''
        for s in clow :
            if not 'a' <= s <= 'z':
                sp += s
        z = clow.strip(sp)
        q = linesong[a].strip(sp)
        if z in colors:
            f = '<'+z+'>'+q+'</>'
            result += f+sp+' '
        else: result += linesong[a]+' ' 
    print(result)     


6531317821
# 1663938, 2022-10-29 10:34:07, PPTTT (40%)

def adder(word,color):
    return "<"+str(color.lower())+">"+str(word)+"</>"
def checker(word,color):
    g = ""
    if color.lower() in word.lower():
        n = 0
        while n < len(word):
            if word.lower()[n:n+len(color.lower())] == color.lower():
                g += adder(word[n:n+len(color)],color)
                n = word.find(color.lower()) + len(color) +1
            else:
                g += word[n]
                n += 1
        return g
file_color = open(input(),"r")
file_lyrics = open(input(),"r")
color,lyrics = [],[]
for line in file_color:
    line = line.split()
    for e in line:
        color.append(e)

for line in file_lyrics:
    line = line.split()
    g = ""
    for e in line:
        c = True
        for c in color:
            if c.lower() in e.lower():
                g += checker(e,c.lower())
                c = False
                break
        if c:
            g += e
        g += " "
    lyrics.append(g)
for e in lyrics:
    print(e)
                

file_color.close()
file_lyrics.close()
# 1664441, 2022-10-29 10:40:07, PP--- (40%)

def adder(word,color):
    return "<"+str(color.lower())+">"+str(word)+"</>"
def checker(word,color):
    g = ""
    if color.lower() in word.lower():
        n = 0
        while n < len(word):
            if word.lower()[n:n+len(color.lower())] == color.lower():
                g += adder(word[n:n+len(color)],color)
                n += len(word[n:n+len(color)])
            else:
                g += word[n]
                n += 1
        return g
    else:
        return word
file_color = open(input(),"r")
file_lyrics = open(input(),"r")
color,lyrics = [],[]
for line in file_color:
    line = line.split()
    for e in line:
        color.append(e)

for line in file_lyrics:
    line = line.split()
    g = ""
    for e in line:
        c = True
        for c in color:
            if c.lower() in e.lower():
                g += checker(e,c.lower())
                c = False
                break
        if c:
            g += e
        g += " "
    lyrics.append(g)
for e in lyrics:
    print(e)
                

file_color.close()
file_lyrics.close()
# 1664597, 2022-10-29 10:41:26, PP--- (40%)

def adder(word,color):
    return "<"+str(color.lower())+">"+str(word)+"</>"
def checker(word,color):
    g = ""
    if color.lower() in word.lower():
        n = 0
        while n < len(word):
            if word.lower()[n:n+len(color.lower())] == color.lower():
                g += adder(word[n:n+len(color)],color)
                n += len(word[n:n+len(color)])
            else:
                g += word[n]
                n += 1
        return g
    else:
        return word 
file_color = open(input(),"r")
file_lyrics = open(input(),"r")
color,lyrics = [],[]
for line in file_color:
    line = line.split()
    for e in line:
        color.append(e)

for line in file_lyrics:
    line = line.split()
    g = ""
    for e in line:
        c = True
        for c in color:
            if c.lower() in e.lower():
                g += checker(e,c.lower())
                c = False
                break
        if c:
            g += e
        g += " "
    lyrics.append(g)
for e in lyrics:
    print(e)
                

file_color.close()
file_lyrics.close()

6532084721
# 1663666, 2022-10-29 10:29:10, P---- (20%)

from operator import truediv


c = input().strip()
m = input().strip()

col = list()
with open(c,'r') as f1:
    while True:
        s = f1.readline().strip()
        if s == '': break
        s = s.lower().split()
        for i in s:
            col.append(i)

with open(m,'r') as f2:
    while True:
        s = f2.readline().strip()
        if s == '': break
        t = s.lower()
        for i in col:
            if i in t:
                idx = t.find(i)
                tmp = s
                s = tmp[:idx] + '<'+ i +'>' + tmp[idx:idx+len(i)] + '</>' + tmp[idx+len(i):]
                t = s
                #idx = t.find(i)
                #while(idx!=-1):
                #    tmp = t
                #    s = tmp[:idx] + '<'+ i +'>' + tmp[idx:idx+len(i)] + '</>' + tmp[idx+len(i)+3:]
                #    t = s
                #    idx = t.find(i,idx+5+len(i))
        print(s)
    print(s)

# 1664040, 2022-10-29 10:35:43, PP--- (40%)

from operator import truediv


c = input().strip()
m = input().strip()

col = list()
with open(c,'r') as f1:
    while True:
        s = f1.readline().strip()
        if s == '': break
        s = s.lower().split()
        for i in s:
            col.append(i)

with open(m,'r') as f2:
    while True:
        s = f2.readline().strip()
        if s == '': break
        t = s.lower()
        for i in col:
            if i in t:
                #idx = t.find(i)
                #tmp = s
                #s = tmp[:idx] + '<'+ i +'>' + tmp[idx:idx+len(i)] + '</>' + tmp[idx+len(i):]
                #t = s
                idx = t.find(i)
                while(idx!=-1):
                    tmp = s
                    s = tmp[:idx] + '<'+ i +'>' + tmp[idx:idx+len(i)] + '</>' + tmp[idx+len(i):]
                    t = s.lower()
                    idx = t.find(i,idx+5+len(i))
        print(s)

# 1664416, 2022-10-29 10:39:59, PP--- (40%)

from operator import truediv


c = input().strip()
m = input().strip()

col = list()
with open(c,'r') as f1:
    while True:
        s = f1.readline().strip()
        if s == '': break
        s = s.lower().split()
        for i in s:
            col.append(i)

with open(m,'r') as f2:
    while True:
        s = f2.readline().strip()
        if len(s) == 0: break
        t = s.lower()
        for i in col:
            if i in t:
                #idx = t.find(i)
                #tmp = s
                #s = tmp[:idx] + '<'+ i +'>' + tmp[idx:idx+len(i)] + '</>' + tmp[idx+len(i):]
                #t = s
                idx = t.find(i)
                while(idx!=-1):
                    tmp = s
                    s = tmp[:idx] + '<'+ i +'>' + tmp[idx:idx+len(i)] + '</>' + tmp[idx+len(i):]
                    t = s.lower()
                    idx = t.find(i,idx+5+len(i))
        print(s)

6531407621
# 1663800, 2022-10-29 10:31:45, xxxxx (0%)

fc = open("cl.txt", "r")
color = []
for line in fc:
    l = (line.strip()).lower()
    color += l.split()
    
print(color)    
fc.close()
def get_cl(s, c):
    for e in c:
        if e in s.lower():
            return "<"+e+">"+s[:len(e)]+"</>"+s[len(e):]
    return s
fl = open("ly.txt", "r")
for line in fl:
    l = line.strip()
    f = l.split()
    s = ""
    for e in f:
        s += get_cl(e,color) +" "
    print(s)

# 1663953, 2022-10-29 10:34:18, PP--- (40%)

x = input()
y = input()

fc = open(x, "r")
color = []
for line in fc:
    l = (line.strip()).lower()
    color += l.split()
fc.close()

def get_cl(s, c):
    for e in c:
        if e in s.lower():
            return "<"+e+">"+s[:len(e)]+"</>"+s[len(e):]
    return s

fl = open(y, "r")
for line in fl:
    l = line.strip()
    f = l.split()
    s = ""
    for e in f:
        s += get_cl(e,color) +" "
    print(s)


6431523621
# 1662654, 2022-10-29 10:04:49, PP--- (40%)

fs = open(input().strip())
fn = open(input().strip())
def color(fs) :
    colors = []
    for line in fs :
        ls = line.strip().split()
        for i in ls :
            if i!='' :
                colors.append(i.lower())
    return colors
cc = color(fs)
for line in fn : #แต่ละบรรทัด
    if len(line)==0 :
        print(line)
    else :
        lw = line.strip().split()
        show = ''
        for word in lw : #แต่ละคำในบรรทัด
            t = True
            for s in cc : #แต่ละสี
                if s in word.lower() :
                    k = word.lower().find(s[0])
                    l = word.lower().find(s[-1])
                    show+=word[:k]+'<'+s+'>'+word[k:l+1]+'</>'+word[l+1:]+' '
                    t = False
                    break
            if t :
                show+=word+' '
        print(show[:-1])
fs.close()
fn.close()


Max Score = 20


6531514021
# 1662601, 2022-10-29 10:03:04, xxxxx (0%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.coles()
fnlyric.close()
print(''.join(listlyric))
# 1662686, 2022-10-29 10:05:41, xxxxx (0%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.cloes()
fnlyric.close()
print(''.join(listlyric))
# 1662691, 2022-10-29 10:05:53, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.close()
fnlyric.close()
print(''.join(listlyric))
# 1662800, 2022-10-29 10:09:01, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
print(''.join(listlyric))
fncolor.close()
fnlyric.close()

# 1662960, 2022-10-29 10:13:42, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].split()
    for e in x :
        y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
print(''.join(listlyric))
fncolor.close()
fnlyric.close()
# 1662976, 2022-10-29 10:14:05, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].split()
    for e in x :
        y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].find(y[j]) != -1 :
            k = listlyric[i].find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
print(''.join(listlyric))
fncolor.close()
fnlyric.close()
# 1663011, 2022-10-29 10:14:52, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for k in range(len(listcolor)) :
    x = listcolor[k].split()
    for e in x :
        y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].find(y[j]) != -1 :
            k = listlyric[i].find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
print(''.join(listlyric))
fncolor.close()
fnlyric.close()
# 1663020, 2022-10-29 10:15:05, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for k in range(len(listcolor)) :
    x = listcolor[k].split()
    for e in x :
        y.append(e.lower())
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].find(y[j]) != -1 :
            k = listlyric[i].find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
print(''.join(listlyric))
fncolor.close()
fnlyric.close()
# 1663125, 2022-10-29 10:17:43, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].find(y[j]) != -1 :
            k = listlyric[i].find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
print(''.join(listlyric))
fncolor.close()
fnlyric.close()
# 1663497, 2022-10-29 10:25:51, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.close()
fnlyric.close()
ns = ''
for i in range(len(listlyric)) :
    ns += listlyric[i]
print(ns)
# 1663571, 2022-10-29 10:27:19, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.close()
fnlyric.close()
ns = ''
for i in range(len(listlyric)) :
#     ns += listlyric[i]
    print(listlyric[i])
# 1663598, 2022-10-29 10:27:49, ----- (0%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.close()
fnlyric.close()
# for i in range(len(listlyric)) :
print(listlyric)
# 1663628, 2022-10-29 10:28:20, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.close()
fnlyric.close()
ns = ''
for i in range(len(listlyric)) :
    ns += listlyric[i]
print(ns)
# 1663934, 2022-10-29 10:34:05, TTTTT (0%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
fncolor.close()
fnlyric.close()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        while listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
ns = ''
for i in range(len(listlyric)) :
    ns += listlyric[i]
print(ns)
# 1663972, 2022-10-29 10:34:41, TTTTT (0%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        while listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.close()
fnlyric.close()
ns = ''
for i in range(len(listlyric)) :
    ns += listlyric[i]
print(ns)

# 1664062, 2022-10-29 10:35:56, TTTTT (0%)

filename_color = input().strip()
filename_lyric = input().strip()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
ns = ''
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        while listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
fncolor.close()
fnlyric.close()
ns = ''
for i in range(len(listlyric)) :
    ns += listlyric[i]
print(ns)
# 1664106, 2022-10-29 10:36:45, P---- (20%)

filename_color = input()
filename_lyric = input()
fncolor = open(filename_color, 'r')
fnlyric = open(filename_lyric, 'r')
listcolor = fncolor.readlines()
listlyric = fnlyric.readlines()
fncolor.close()
fnlyric.close()
y = []
for i in range(len(listcolor)) :
    x = listcolor[i].strip().split()
    for e in x :
        if e.lower() not in y:
            y.append(e.lower())
for i in range(len(listlyric)) :
    for j in range(len(y)) :
        if listlyric[i].lower().find(y[j]) != -1 :
            k = listlyric[i].lower().find(y[j])
            listlyric[i] = listlyric[i][:k]+'<'+y[j]+'>'+listlyric[i][k:k+len(y[j])]+'</>'+listlyric[i][k+len(y[j]):]
ns = ''
for i in range(len(listlyric)) :
    ns += listlyric[i]
print(ns)

6531330921
# 1662756, 2022-10-29 10:08:03, P---- (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    line = line.strip()
    for color in colors:
        if color in line.lower():
            line = line[:line.lower().find(color)]+"<"+color+">"+line[line.lower().find(color):line.lower().find(color)+len(color)]+"</>"+line[line.lower().find(color)+len(color):]
    print(line)
# 1662759, 2022-10-29 10:08:11, P---- (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    line = line.strip()
    for color in colors:
        if color in line.lower():
            line = line[:line.lower().find(color)]+"<"+color+">"+line[line.lower().find(color):line.lower().find(color)+len(color)]+"</>"+line[line.lower().find(color)+len(color):]
    print(line)
# 1662837, 2022-10-29 10:10:12, P---- (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    line = line.strip()
    for color in colors:
        if color in line.lower():
            line = line[:line.lower().find(color)]+"<"+color+">"+line[line.lower().find(color):line.lower().find(color)+len(color)]+"</>"+line[line.lower().find(color)+len(color):]
    print(line)
# 1663225, 2022-10-29 10:19:58, P---- (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    col = colors.copy()
    line = line.strip()
    i = 0
    while True:
        if i >= len(col):
            break
        if col[i] in line.lower():
            line = line[:line.lower().find(col[i])]+"<"+col[i]+">"+line[line.lower().find(col[i]):line.lower().find(col[i])+len(col[i])]+"</>"+line[line.lower().find(col[i])+len(col[i]):]
            col.pop(i)
            i = 0
        else:
            i += 1
    print(line)
# 1663229, 2022-10-29 10:20:04, P---- (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    col = colors.copy()
    line = line.strip()
    i = 0
    while True:
        if i >= len(col):
            break
        if col[i] in line.lower():
            line = line[:line.lower().find(col[i])]+"<"+col[i]+">"+line[line.lower().find(col[i]):line.lower().find(col[i])+len(col[i])]+"</>"+line[line.lower().find(col[i])+len(col[i]):]
            col.pop(i)
            i = 0
        else:
            i += 1
    print(line)
# 1663286, 2022-10-29 10:21:43, P---- (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    col = colors.copy()
    line = line.strip()
    i = 0
    while True:
        if i >= len(col):
            break
        if col[i] in line.lower():
            line = line[:line.lower().find(col[i])]+"<"+col[i]+">"+line[line.lower().find(col[i]):line.lower().find(col[i])+len(col[i])]+"</>"+line[line.lower().find(col[i])+len(col[i]):]
            col.pop(i)
            i = 0
        else:
            col.pop(i)
            i += 1
    print(line)
# 1663391, 2022-10-29 10:23:49, P---- (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    col = colors.copy()
    line = line.strip()
    i = 0
    while True:
        if i >= len(col):
            break
        if col[i] in line.lower():
            line = line[:line.lower().find(col[i])]+"<"+col[i]+">"+line[line.lower().find(col[i]):line.lower().find(col[i])+len(col[i])]+"</>"+line[line.lower().find(col[i])+len(col[i]):]
            col.pop(i)
            i = 0
        else:
            col.pop(i)
    print(line)
# 1663469, 2022-10-29 10:25:25, TTTTT (0%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    col = colors.copy()
    line = line.strip()
    i = 0
    while True:
        if i >= len(col):
            break
        while True:
            if col[i] in line.lower():
                line = line[:line.lower().find(col[i])]+"<"+col[i]+">"+line[line.lower().find(col[i]):line.lower().find(col[i])+len(col[i])]+"</>"+line[line.lower().find(col[i])+len(col[i]):]
            else:
                break
        col.pop(i)
    print(line)
# 1663869, 2022-10-29 10:33:09, PTTTT (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    col = colors.copy()
    line = line.strip()
    i = 0
    while True:
        a = 0
        if i >= len(col):
            break
        while True:
            if col[i] in line.lower()[a:]:
                line = line[:line.lower().find(col[i])]+"<"+col[i]+">"+line[line.lower().find(col[i]):line.lower().find(col[i])+len(col[i])]+"</>"+line[line.lower().find(col[i])+len(col[i]):]
                a = line.lower().find(col[i])+len(col[i])+2
            else:
                break
        col.pop(i)
    print(line)
# 1663907, 2022-10-29 10:33:40, PTTTT (20%)

colorf = open(input(),"r")
lyricsf = open(input(),"r")
colors = []
for line in colorf:
    x = line.split()
    for e in x:
        colors.append(e.lower())
for line in lyricsf:
    col = colors.copy()
    line = line.strip()
    i = 0
    while True:
        a = 0
        if i >= len(col):
            break
        while True:
            if col[i] in line.lower()[a:]:
                line = line[:line.lower().find(col[i])]+"<"+col[i]+">"+line[line.lower().find(col[i]):line.lower().find(col[i])+len(col[i])]+"</>"+line[line.lower().find(col[i])+len(col[i]):]
                a = line.lower().find(col[i])+len(col[i])+2
            else:
                break
        col.pop(i)
    print(line)

6531304621
# 1663140, 2022-10-29 10:18:07, P---- (20%)

color = open(input() , 'r')
song = open(input() , 'r')
lencolor = set()
lcolor = []
for line in color:
    for ch in line.split():
        lcolor.append(ch.lower())
        lencolor.add(len(ch))
for line in song:
    change = []
    for i in range(len(line)):
        for e in lencolor:
            if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                change.append(line[i:i+e])
    for e in change:
        line = line.replace(e, '<' + e.lower() + '>' + e + '</>')
    print(line)
# 1663681, 2022-10-29 10:29:32, ----- (0%)

color = open(input() , 'r')
song = open(input() , 'r')
lencolor = set()
lcolor = []
for line in color:
    for ch in line.split():
        lcolor.append(ch.lower())
        lencolor.add(len(ch))
change = []
for line in song:
    for i in range(len(line)):
        for e in lencolor:
            if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                change.append(line[i:i+e])
    for e in change:
        line = line.replace(e, '<' + e.lower() + '>' + e + '</>')
    print(line)
# 1663719, 2022-10-29 10:30:16, P---- (20%)

color = open(input() , 'r')
song = open(input() , 'r')

lencolor = set()
lcolor = []
for line in color:
    for ch in line.split():
        lcolor.append(ch.lower())
        lencolor.add(len(ch))
for line in song:
    change = []
    for i in range(len(line)):
        for e in lencolor:
            if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                change.append(line[i:i+e])
    for e in change:
        line = line.replace(e, '<' + e.lower() + '>' + e + '</>')
    print(line)
# 1663973, 2022-10-29 10:34:42, P---- (20%)

color = open(input() , 'r')
song = open(input() , 'r')

lencolor = set()
lcolor = []
for line in color:
    for ch in line.split():
        if ch != '':
            lcolor.append(ch.lower())
            lencolor.add(len(ch))
for line in song:
    change = []
    for i in range(len(line)):
        for e in lencolor:
            if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                change.append(line[i:i+e])
    for e in change:
        line = line.replace(e, '<' + e.lower() + '>' + e + '</>')
    print(line)
# 1664086, 2022-10-29 10:36:15, compilation error (0%)

color = open(input() , 'r')
song = open(input() , 'r')

lencolor = set()
lcolor = []
for line in color:
    for ch in line.split()::
          lcolor.append(ch.lower())
          lencolor.add(len(ch))
for line in song:
    change = []
    for i in range(len(line)):
        for e in sorted(lencolor):
            if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                change.append(line[i:i+e])
    for e in change:
        line = line.replace(e, '<' + e.lower() + '>' + e + '</>')
    print(line)
# 1664460, 2022-10-29 10:40:18, P---- (20%)

color = open(input() , 'r')
song = open(input() , 'r')
lencolor = set()
lcolor = []
for line in color:
    for ch in line.split():
        lcolor.append(ch.lower())
        lencolor.add(len(ch))
for line in song:
    if line != '':
        change = []
        for i in range(len(line)):
            for e in lencolor:
                if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                    change.append(line[i:i+e])
        for e in change:
            line = line.replace(e, '<' + e.lower() + '>' + e + '</>')
        print(line)
    else:
        print(line)
# 1664551, 2022-10-29 10:40:59, P---- (20%)

color = open(input() , 'r')
song = open(input() , 'r')
lencolor = set()
lcolor = []
for line in color:
    for ch in line.split():
        lcolor.append(ch.lower())
        lencolor.add(len(ch))
for line in song:
    if line != '':
        change = []
        for i in range(len(line)):
            for e in lencolor:
                if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                    change.append(line[i:i+e])
        for e in change:
            line = line.replace(e, '<' + e + '>' + e + '</>')
        print(line)
    else:
        print(line)
# 1664576, 2022-10-29 10:41:13, P---- (20%)

color = open(input() , 'r')
song = open(input() , 'r')
lencolor = set()
lcolor = []
for line in color:
    for ch in line.split():
        lcolor.append(ch.lower())
        lencolor.add(len(ch))
for line in song:
    if line != '':
        change = []
        for i in range(len(line)):
            for e in lencolor:
                if i + e <= len(line) and line[i:i+e].lower() in lcolor:
                    change.append(line[i:i+e])
        for e in change:
            line = line.replace(e, '<' + e.lower() + '>' + e + '</>')
        print(line)
    else:
        print(line)

6530159821
# 1662412, 2022-10-29 09:57:20, P---- (20%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    for i in s:
        line+=" "*len(i)
        for n in range(len(line)):
            if i==line[n:n+len(i)].lower():
                line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                break
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y,'r')
for line in fn1:
    line=line.strip()
    print(rename(line,ans))
fn1.close()


# 1662535, 2022-10-29 10:00:57, P---- (20%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    for i in s:
        line+=" "*len(i)
        for n in range(len(line)):
            if i==line[n:n+len(i)].lower():
                line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                break
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y,'r')
for line in fn1:
    line=line.strip()
    print(rename(line,ans))
fn1.close()


# 1662587, 2022-10-29 10:02:39, P---- (20%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    if s==[]:
        return line
    else:
        for i in s:
            line+=" "*len(i)
            for n in range(len(line)):
                if i==line[n:n+len(i)].lower():
                    line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                    break
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y,'r')
for line in fn1:
    line=line.strip()
    print(rename(line,ans))
fn1.close()


# 1662615, 2022-10-29 10:03:18, P---- (20%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    if s==[]:
        return line
    else:
        for i in s:
            line+=" "*len(i)
            for n in range(len(line)):
                if i==line[n:n+len(i)].lower():
                    line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                    break
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y)
for line in fn1:
    line=line.strip()
    print(rename(line,ans))
fn1.close()


# 1662813, 2022-10-29 10:09:21, P---- (20%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    if s==[]:
        return line
    else:
        for i in s:
            line+=" "*len(i)
            for n in range(len(line)):
                if i==line[n:n+len(i)].lower():
                    line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                    break 
            if n>len(line):break        
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y)
for line in fn1:
    line=line.strip()
    
    print(rename(line,ans))
fn1.close()


# 1662928, 2022-10-29 10:12:46, P---- (20%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    if s==[]:
        return line
    else:
        for i in s:
            line+=" "*len(i)
            for n in range(len(line)-len(i)):
                if i==line[n:n+len(i)].lower():
                    line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                    break 
                if n>len(line):break        
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y)
for line in fn1:
    line=line.strip()
    print(rename(line,ans))
fn1.close()


# 1664523, 2022-10-29 10:40:46, P---- (20%)

x=input().strip()
y=input().strip()#

def rename(line,s):
    if s==[]:
        return line
    else:
        for i in s:
            line+=" "*len(i)
            for n in range(len(line)-len(i)):
                if i==line[n:n+len(i)].lower():
                    line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                    break 
                if n>len(line):break        
    return line
def check(line,s):
    for i in s:
        fn=0
        s1=0
        while True:
            s2=line.lower().find(i[0],s1)
            if s2==-1:break
            if line[s2:s2+len(i)].lower()==i.lower():
                line=line[0:s2]+'<'+str(i)+'>'+line[s2:s2+len(i)]+"</>"+line[s2+len(i):]
                break
            s1=s2+1
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y)
for line in fn1:
    line=line.strip()
    print(check(line,ans))
fn1.close()



6530187321
# 1662460, 2022-10-29 09:58:34, ----- (0%)

x = open(input())
d = []
for line in x:
    d += line.lower().split()
x.close()
x = open(input())
b = x.read()
x.close()
def color_tag(a):
    a = '<'+ a.lower() + '>' + a + '</>'
    return a
y = b.lower()
for e in d:
    a = y.count(e)
    c = 0
    for i in range(a):
        x = y.find(e,c)
        b = b[:x] + color_tag(b[x:x+len(e)]) + b[x+len(e):]
        y = y[:x] + color_tag(y[x:x+len(e)]) + y[x+len(e):]
        c = x + len(e)
print(b)
# 1662491, 2022-10-29 09:59:24, ----- (0%)

x = open(input())
d = []
for line in x:
    d += line.lower().split()
x.close()
x = open(input())
b = x.read()
x.close()
def color_tag(a):
    a = '<'+ a.lower() + '>' + a + '</>'
    return a
y = b.lower()
for e in d:
    a = y.count(e)
    c = 0
    for i in range(a):
        x = y.find(e,c)
        b = b[:x] + color_tag(b[x:x+len(e)]) + b[x+len(e):]
        y = y[:x] + color_tag(y[x:x+len(e)]) + y[x+len(e):]
        c = x + len(e)
print(b.strip())
# 1662571, 2022-10-29 10:02:12, ----- (0%)

x = open(input().strip())
d = []
for line in x:
    d += line.lower().split()
x.close()
x = open(input().strip())
b = x.read()
x.close()
def color_tag(a):
    a = '<'+ a.lower() + '>' + a + '</>'
    return a
y = b.lower()
for e in d:
    a = y.count(e)
    c = 0
    for i in range(a):
        x = y.find(e,c)
        b = b[:x] + color_tag(b[x:x+len(e)]) + b[x+len(e):]
        y = y[:x] + color_tag(y[x:x+len(e)]) + y[x+len(e):]
        c = x + len(e)
print(b.strip())
        

# 1662818, 2022-10-29 10:09:24, ----- (0%)

color = input().strip()
song = input().strip()
color = open(color,'r')
d = []
for line in color:
    d += line.lower().split()
color.close()
song = open(song, 'r')
b = song.read()
song.close()
def color_tag(a):
    a = '<'+ a.lower() + '>' + a + '</>'
    return a
y = b.lower()
for e in d:
    a = y.count(e)
    c = 0
    for i in range(a):
        x = y.find(e,c)
        b = b[:x] + color_tag(b[x:x+len(e)]) + b[x+len(e):]
        y = y[:x] + color_tag(y[x:x+len(e)]) + y[x+len(e):]
        c = x + len(e)
print(b.strip())
# 1663873, 2022-10-29 10:33:11, P---- (20%)

color = input().strip()
song = input().strip()
def color_tag(a):
    a = '<'+ a.lower() + '>' + a + '</>'
    return a
color = open(color,'r')
d = []
for line in color:
    d += line.lower().split()
color.close()
song = open(song, 'r')
out = ''
for line in song:
    y = line.lower()
    for e in d:
        a = y.count(e)
        c = 0
        for i in range(a):
            x = y.find(e,c)
            line = line[:x] + color_tag(line[x:x+len(e)]) + line[x+len(e):]
            y = y[:x] + color_tag(y[x:x+len(e)]) + y[x+len(e):]
            c = x + len(e)
    out += line
song.close()
print(out.strip())
        

# 1663944, 2022-10-29 10:34:10, P---- (20%)

color = input().strip()
song = input().strip()
def color_tag(a):
    a = '<'+ a.lower() + '>' + a + '</>'
    return a
color = open(color,'r')
d = []
for line in color:
    d += line.lower().split()
color.close()
song = open(song, 'r')
out = ''
for line in song:
    y = line.lower()
    for e in d:
        a = y.count(e)
        c = 0
        for i in range(a):
            x = y.find(e,c)
            line = line[:x] + color_tag(line[x:x+len(e)]) + line[x+len(e):]
            y = y[:x] + color_tag(y[x:x+len(e)]) + y[x+len(e):]
            c = x + len(e)
    out += line
song.close()
print(out)

6330148721
# 1664768, 2022-10-29 18:44:02, ----- (0%)

cfile = input().strip()
sfile = input().strip()

read_color = open(cfile, "r")
read_song = open(sfile, "r")
x = []
y = []
for line in read_color:
    if line != "\n":
        x += line.strip().split(" ")
for e in x:
    y += [e.lower()]
for line in read_song:
    for e in y:
        if(len(line) == 0): continue
        f = line.lower().find(e)
        if(f != -1):
            if(f == len(line) - 1):
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>"
            else:
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>" + line[f+len(e):]
    print(line[:-1])
read_song.close()
read_color.close()

# 1664769, 2022-10-29 18:45:56, P---- (20%)

cfile = input().strip()
sfile = input().strip()

read_color = open(cfile, "r")
read_song = open(sfile, "r")
x = []
y = []
for line in read_color:
    if line != "\n":
        x += line.strip().split(" ")
for e in x:
    y += [e.lower()]
for line in read_song:
    for e in y:
        if(len(line) == 0): continue
        f = line.lower().find(e)
        if(f != -1):
            if(f == len(line) - 1):
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>"
            else:
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>" + line[f+len(e):]
    if(line[-1] == "\n"):
        print(line[:-1])
    else:
        print(line)
read_song.close()
read_color.close()

# 1664770, 2022-10-29 18:47:43, ----- (0%)

cfile = input().strip()
sfile = input().strip()

read_color = open(cfile, "r")
read_song = open(sfile, "r")
x = []
y = []
for line in read_color:
    if line[-1] == "\n":
        x += line[:-1].strip().split(" ")
for e in x:
    y += [e.lower()]
for line in read_song:
    for e in y:
        if(len(line) == 0): continue
        f = line.lower().find(e)
        if(f != -1):
            if(f == len(line) - 1):
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>"
            else:
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>" + line[f+len(e):]
    if(line[-1] == "\n"):
        print(line[:-1])
    else:
        print(line)
read_song.close()
read_color.close()

# 1664774, 2022-10-29 19:06:12, ----- (0%)

cfile = input().strip()
sfile = input().strip()

read_color = open(cfile, "r")
read_song = open(sfile, "r")
x = []
for line in read_color:
    line = line.strip()
    if(len(line) != 0):
        x += line.strip().lower().split(" ")
print(x)
for line in read_song:
    if(line == "\n"):
        print("")
    else:
        for e in x:
            f = line.lower().find(e)
            if(f != -1):
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>" + line[f+len(e):]
        if(line[-1] == "\n"):
            print(line[:-1])
        else:
            print(line)
read_song.close()
read_color.close()

# 1664775, 2022-10-29 19:06:43, P---- (20%)

cfile = input().strip()
sfile = input().strip()

read_color = open(cfile, "r")
read_song = open(sfile, "r")
x = []
for line in read_color:
    line = line.strip()
    if(len(line) != 0):
        x += line.strip().lower().split(" ")
for line in read_song:
    if(line == "\n"):
        print("")
    else:
        for e in x:
            f = line.lower().find(e)
            if(f != -1):
                line = line[:f] + "<" + e + ">" + line[f:f+len(e)] + "</>" + line[f+len(e):]
        if(line[-1] == "\n"):
            print(line[:-1])
        else:
            print(line)
read_song.close()
read_color.close()


6530128321
# 1663753, 2022-10-29 10:30:48, P---- (20%)



def insert_tag(x,tag,pos):
    
    return x[:pos] + "<" + tag + ">" + x[pos:pos+len(tag)] + "</>" + x[pos+len(tag):]
    
# print(insert_tag("aaagreeeeenaaa", "greeeeen", 3))


a = input()
b = input()

colorf = open(a,"r")
lyricsf = open(b,"r")

colors = []

for line in colorf:
    xi = line.strip().split()
    for i in xi:
        colors.append(i)
        
for line in lyricsf:
    
    line = line.strip()
    line_upper = line.upper()
    x = line
    relative = 0
    for i in colors:
        if i.upper() in line.upper():
            x = insert_tag(x,i,x.upper().find(i.upper()))

    print(x)
            
            
            
            

            
        


# 1663939, 2022-10-29 10:34:07, P---- (20%)



def insert_tag(x,tag,pos):
    
    return x[:pos] + "<" + tag + ">" + x[pos:pos+len(tag)] + "</>" + x[pos+len(tag):]
    
# print(insert_tag("aaagreeeeenaaa", "greeeeen", 3))


a = input()
b = input()

colorf = open(a,"r")
lyricsf = open(b,"r")

colors = []

for line in colorf:
    xi = line.strip().split()
    for i in xi:
        colors.append(i)
        
for line in lyricsf:
    
    line = line.strip()
    line_upper = line.upper()
    x = line
    relative = 0
    for i in colors:
        if i.upper() in line.upper():
            
            x = insert_tag(x,i.lower(),x.upper().find(i.upper()))

    print(x)
            
            
            
            

            
        


# 1663985, 2022-10-29 10:34:58, P---- (20%)



def insert_tag(x,tag,pos):
    
    return x[:pos] + "<" + tag + ">" + x[pos:pos+len(tag)] + "</>" + x[pos+len(tag):]
    
# print(insert_tag("aaagreeeeenaaa", "greeeeen", 3))


a = input()
b = input()

colorf = open(a,"r")
lyricsf = open(b,"r")

colors = []

for line in colorf:
    xi = line.strip().split()
    for i in xi:
        colors.append(i)
        
for line in lyricsf:
    
    line = line.strip()
    line_upper = line.upper()
    x = line
    relative = 0
    for i in colors:
        if i.upper() in line.upper():
            
            x = insert_tag(x,i.lower(),x.upper().find(i.upper()))

    print(x)
            
# 1664502, 2022-10-29 10:40:40, ----- (0%)



def insert_tag(x,tag,pos):
    
    return x[:pos] + "<" + tag + ">" + x[pos:pos+len(tag)] + "</>" + x[pos+len(tag):]
    
# print(insert_tag("aaagreeeeenaaa", "greeeeen", 3))


a = input()
b = input()

colorf = open(a,"r")
lyricsf = open(b,"r")

colors = []

for line in colorf:
    xi = line.strip().split()
    for i in xi:
        colors.append(i)
        
for line in lyricsf:
    if line == "\n":
        x+= "\n"
        continue
    
    line = line.strip()
    line_upper = line.upper()
    x = line
    relative = 0
    for i in colors:
        if i.upper() in line.upper():
            
            x = insert_tag(x,i.lower(),x.upper().find(i.upper()))

#     print(x)
            
            
            
            

            
        


# 1664565, 2022-10-29 10:41:06, P---- (20%)



def insert_tag(x,tag,pos):
    
    return x[:pos] + "<" + tag + ">" + x[pos:pos+len(tag)] + "</>" + x[pos+len(tag):]
    
# print(insert_tag("aaagreeeeenaaa", "greeeeen", 3))


a = input()
b = input()

colorf = open(a,"r")
lyricsf = open(b,"r")

colors = []

for line in colorf:
    xi = line.strip().split()
    for i in xi:
        colors.append(i)
        
for line in lyricsf:
    if line == "\n":
        x+= "\n"
        continue
    
    line = line.strip()
    line_upper = line.upper()
    x = line
    relative = 0
    for i in colors:
        if i.upper() in line.upper():
            
            x = insert_tag(x,i.lower(),x.upper().find(i.upper()))

    print(x)
            
            
            
            

            
        



6530160321
# 1663507, 2022-10-29 10:26:07, ----- (0%)

a = input()
b = input()
f = open(a)
hotdog = [] 
for line in f :
    l = line.strip()
    z = l.split()
    for i in range(len(z)) :
        hotdog.append(z[i].lower())
f.close()

f = open(b)

m = []
for line in f :
    l = line.strip()
    l = l.split()
    x = " ".join(l)
    y = []
    for i in range(len(l)) :
        for e in range(len(hotdog)) :
            if hotdog[e] in l[i].lower() :
                x = x.replace(l[i],"<" + hotdog[e] + ">" + l[i] + "</>")
                y.append(x)
    if y != [] :
        m.append(y[-1])
    elif y == []  :
        m.append("")
m = "\n".join(m)
m = m[-1::-1][1:][-1::-1]
print(m)
# 1663652, 2022-10-29 10:28:52, ----- (0%)

a = input()
b = input()
f = open(a)
hotdog = [] 
for line in f :
    l = line.strip()
    z = l.split()
    for i in range(len(z)) :
        hotdog.append(z[i].lower())
f.close()

f = open(b)

m = []
for line in f :
    l = line.strip()
    l = l.split()
    x = " ".join(l)
    y = []
    for i in range(len(l)) :
        for e in range(len(hotdog)) :
            if hotdog[e] in l[i].lower() :
                x = x.replace(l[i],"<" + hotdog[e] + ">" + l[i] + "</>")
                y.append(x)
    if y != [] :
        m.append(y[-1])
    elif y == []  :
        m.append("")
m = "\n".join(m)
m = m[-1::-1][1:][-1::-1]
print(m)
# 1663669, 2022-10-29 10:29:14, ----- (0%)

a = input()
b = input()
f = open(a)
hotdog = [] 
for line in f :
    l = line.strip()
    z = l.split()
    for i in range(len(z)) :
        hotdog.append(z[i].lower())
f.close()

f = open(b)

m = []
for line in f :
    l = line.strip()
    l = l.split()
    x = " ".join(l)
    y = []
    for i in range(len(l)) :
        for e in range(len(hotdog)) :
            if hotdog[e] in l[i].lower() :
                x = x.replace(l[i],"<" + hotdog[e] + ">" + l[i] + "</>")
                y.append(x)
    if y != [] :
        m.append(y[-1])
    elif y == []  :
        m.append("")
f.close()
m = "\n".join(m)
m = m[-1::-1][1:][-1::-1]
print(m)
# 1663793, 2022-10-29 10:31:32, P---- (20%)


a = input()
b = input()
f = open(a)
hotdog = [] 
for line in f :
    l = line.strip()
    z = l.split()
    for i in range(len(z)) :
        hotdog.append(z[i].lower())
f.close()

f = open(b)

m = []
for line in f :
    l = line.strip()
    l = l.split()
    x = " ".join(l)
    y = []
    for i in range(len(l)) :
        for e in range(len(hotdog)) :
            if hotdog[e] in l[i].lower() :
                x = x.replace(l[i],"<" + hotdog[e] + ">" + l[i] + "</>")
                y.append(x)
    if y != [] :
        m.append(y[-1])
    elif y == []  :
        m.append(x)
f.close()
m = "\n".join(m)

print(m)
# 1664516, 2022-10-29 10:40:45, P---- (20%)

a = input()
b = input()
f = open(a)
hotdog = [] 
for line in f :
    l = line.strip()
    z = l.split()
    for i in range(len(z)) :
        hotdog.append(z[i].lower())
f.close()

f = open(b)

m = []
for line in f :
    l = line.strip()
    l = l.split()
    x = " ".join(l)
    y = []
    for i in range(len(l)) :
        for e in range(len(hotdog)) :
            if hotdog[e] in l[i].lower() :
                x = x.replace(l[i],"<" + hotdog[e] + ">" + l[i] + "</>")
                y.append(x)
    if y != [] :
        m.append(y[-1])
    elif y == []  :
        m.append(x)
f.close()
m = "\n".join(m)

print(m)

6530012121
# 1663561, 2022-10-29 10:27:05, P---- (20%)

fn1 = input()
fn2 = input()
color1 =[]
flie1 = open(fn1,'r')
for line in flie1:
    a = line.strip().split()
    for i in range(len(a)):
        color1.append(a[i].lower())
flie2 = open(fn2,'r')
for line in flie2:
    line1 = line.strip()
    ans = line.strip()
    for i in range(len(color1)):
        if color1[i] in ans.lower():
            k1 = ans.lower().find(color1[i])
            ans = ans[:k1]+"<"+color1[i]+'>'+ans[k1:k1+len(color1[i])]+'</>'+ans[k1+len(color1[i]):]
    print(ans)
            

# 1664177, 2022-10-29 10:37:44, P---- (20%)

fn1 = input()
fn2 = input()
color1 =[]
flie1 = open(fn1,'r')
for line in flie1:
    a = line.strip().split()
    for i in range(len(a)):
        color1.append(a[i].lower())
flie2 = open(fn2,'r')
for line in flie2:
    line1 = line.strip()
    ans = line.strip()
    for i in range(len(color1)):
        if color1[i] in ans.lower():
            k1 = ans.lower().find(color1[i])
            ans = ans[:k1]+"<"+color1[i]+'>'+ans[k1:k1+len(color1[i])]+'</>'+ans[k1+len(color1[i]):]
            k2=k1 + 5 + len(color1[i])
            while ans.lower().find(color1[i],k2) != -1:
                k3 = ans.lower().find(color1[i],k2)
                ans = ans[:k3]+"<"+color1[i]+'>'+ans[k3:k3+len(color1[i])]+'</>'+ans[k3+len(color1[i]):]
                k2 += 5 + len(color1[i])
    print(ans)

# 1664203, 2022-10-29 10:37:56, P---- (20%)

fn1 = input()
fn2 = input()
color1 =[]
flie1 = open(fn1,'r')
for line in flie1:
    a = line.strip().split()
    for i in range(len(a)):
        color1.append(a[i].lower())
flie2 = open(fn2,'r')
for line in flie2:
    line1 = line.strip()
    ans = line.strip()
    for i in range(len(color1)):
        if color1[i] in ans.lower():
            k1 = ans.lower().find(color1[i])
            ans = ans[:k1]+"<"+color1[i]+'>'+ans[k1:k1+len(color1[i])]+'</>'+ans[k1+len(color1[i]):]
    print(ans)

# 1664454, 2022-10-29 10:40:15, P---- (20%)

fn1 = input()
fn2 = input()
color1 =[]
flie1 = open(fn1,'r')
for line in flie1:
    a = line.strip().split()
    for i in range(len(a)):
        color1.append(a[i].lower())
flie2 = open(fn2,'r')
for line in flie2:
    line1 = line.strip()
    ans = line.strip()
    k2=0
    for i in range(len(color1)):
        if color1[i] in ans.lower():
            k1 = ans.lower().find(color1[i])
            ans = ans[:k1]+"<"+color1[i]+'>'+ans[k1:k1+len(color1[i])]+'</>'+ans[k1+len(color1[i]):]
            k2+=k1 + 5 + 2*len(color1[i])
            while ans.lower().find(color1[i],k2) != -1:
                k3 = ans.lower().find(color1[i],k2)
                ans = ans[:k3]+"<"+color1[i]+'>'+ans[k3:k3+len(color1[i])]+'</>'+ans[k3+len(color1[i]):]
                k2 += 5 + 2*len(color1[i])
    print(ans)


6532114921
# 1663179, 2022-10-29 10:19:03, P---- (20%)

file_color = input()
file_music = input()
infile_color = open(file_color ,'r')
infile_music = open(file_music ,'r')

color = list()
for line in infile_color:
    x = line.split()
    for e in x:
        color.append(e.lower())

for line in infile_music:
    x = line.replace(',' ,' ').replace('.' ,' ') .replace("'" ,' ').replace('?' ,' ').split()
    for e in x:
        if e.lower() in color:
            ind = line.find(e)
            s = '<' + e.lower() + '>' + e + '</>'
            line = line[:ind] + s + line[ind+len(e):]
        
        else:
            for e1 in color:
                ind = e.find(e1)
                s1 = e[ind:ind+len(e1)]
                if ind == -1: continue
                
                s = e[:ind] + '<' + s1.lower() + '>' + s1 + '</>' + e[ind+len(e1):]
                line = line[:line.find(e)] + s + line[line.find(e)+len(e):]
                    
    print(line ,end='')
# 1663317, 2022-10-29 10:22:25, P---- (20%)

file_color = input()
file_music = input()
infile_color = open(file_color ,'r')
infile_music = open(file_music ,'r')

color = list()
for line in infile_color:
    x = line.split()
    for e in x:
        color.append(e.lower())

for line in infile_music:
    for e in line:
        if not e.isdigit(): line.replace('e' ,' ')
    x = line.split()
    for e in x:
        if e.lower() in color:
            ind = line.find(e)
            s = '<' + e.lower() + '>' + e + '</>'
            line = line[:ind] + s + line[ind+len(e):]
        
        else:
            for e1 in color:
                ind = e.find(e1)
                s1 = e[ind:ind+len(e1)]
                if ind == -1: continue
                
                s = e[:ind] + '<' + s1.lower() + '>' + s1 + '</>' + e[ind+len(e1):]
                line = line[:line.find(e)] + s + line[line.find(e)+len(e):]
                    
    print(line ,end='')
# 1663449, 2022-10-29 10:24:56, P---- (20%)

file_color = input()
file_music = input()
infile_color = open(file_color ,'r')
infile_music = open(file_music ,'r')

color = list()
for line in infile_color:
    x = line.split()
    for e in x:
        color.append(e.lower())

for line in infile_music:
    for e in line:
        if not e.isdigit(): line.replace(e ,' ')
    x = line.split()
    for e in x:
        if e.lower() in color:
            ind = line.find(e)
            s = '<' + e.lower() + '>' + e + '</>'
            line = line[:ind] + s + line[ind+len(e):]
        
        else:
            for e1 in color:
                ind = e.find(e1)
                s1 = e[ind:ind+len(e1)]
                if ind == -1: continue
                
                s = e[:ind] + '<' + s1.lower() + '>' + s1 + '</>' + e[ind+len(e1):]
                line = line[:line.find(e)] + s + line[line.find(e)+len(e):]
                    
    print(line ,end='')
# 1663850, 2022-10-29 10:32:50, P---- (20%)

file_color = input()
file_music = input()
infile_color = open(file_color ,'r')
infile_music = open(file_music ,'r')

color = list()
for line in infile_color:
    x = line.split()
    for e in x:
        color.append(e.lower())

temp = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

for line in infile_music:
    newline = ''
    for e in line:
        if e in temp: newline += e
        else: newline += ' '

    x = newline.split()
    for e in x:
        if e.lower() in color:
            ind = line.find(e)
            s = '<' + e.lower() + '>' + e + '</>'
            line = line[:ind] + s + line[ind+len(e):]
        
        else:
            for e1 in color:
                ind = e.find(e1)
                s1 = e[ind:ind+len(e1)]
                if ind == -1: continue
                
                s = e[:ind] + '<' + s1.lower() + '>' + s1 + '</>' + e[ind+len(e1):]
                line = line[:line.find(e)] + s + line[line.find(e)+len(e):]
                    
    print(line ,end='')

6230083421
# 1663603, 2022-10-29 10:27:56, xxxxx (0%)

color = input().strip()
song = input().strip()
f1 = open(color)
f2 = open(song)
colors = []
for line in f1:
    txt = line.strip().split()
    for c in txt:
        colors.append(c.lower())
txts = f2.read()
new = '' ; news = ''
for c in txts:
    if c.isalpha():
        new += c.lower()
        news += c
    else:
        new += ' '+c+' '
        news += c
new = new.split()
out = '' 
for i in range(new):
    if new in colors:
        out +='<'+new[i]+'>'+news[i]+'</>'
print(out)
f1.close()
f2.close()


# 1663864, 2022-10-29 10:33:00, ----- (0%)

color = input().strip()
song = input().strip()
f1 = open(color)
f2 = open(song)
colors = []
for line in f1:
    txt = line.strip().split()
    for c in txt:
        colors.append(c.lower())
txts = f2.read()
new = '' ; news = ''
for c in txts:
    if c.isalpha():
        new += c.lower()
        news += c
    else:
        new += ' '+c+' '
        news += c
new = new.split()
out = '' 
for i in new:
    if i in colors:
        out +='<'+i+'>'+i+'</>'
print(out)
f1.close()
f2.close()



# 1664356, 2022-10-29 10:39:29, P---- (20%)

color = input().strip()
song = input().strip()
f1 = open(color)
f2 = open(song)
colors = []
for line in f1:
    txt = line.strip().split()
    for c in txt:
        colors.append(c.lower())
txts = f2.read()
tx = txts.lower()
for c in colors:
    if c in tx:
        out = tx.replace(c,'<'+c+'>'+c+'</>')
print(out)
f1.close()
f2.close()




6530021821
# 1663250, 2022-10-29 10:20:47, ----- (0%)

print('<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.')
print('Dark<blue>blue</>, <purple>purple</> and <green>green</>.')
print()
print("What's your favorite color?")

# 1663837, 2022-10-29 10:32:33, xxxxx (0%)


fil_1 = 'ans.txt'
fil_2 = 'ans2.txt'
color = []
new_color = []
f_1 = open(fil_1 , 'r')
f_2 = open(fil_2 , 'r')

for line in f_1:
    c = [e.lower() for e in line.strip().split()]
    color.append(c)
    
for i in color:
    for j in i:
        new_color.append(j)
    
    
    
    
    
for line in f_2:
    line = line.strip()
    new_line = line
    for i in new_color:
        f_col = line.find(i)
        if f_col != -1:
            line =line[:f_col]+'<' + i + '>'+ line[f_col:(f_col+len(i))] +'</>'+ line[(f_col+len(i)): ]
    if new_line == '':
        line = new_line
    print(line)
    
    
f_1.close()
f_2.close()

# 1663919, 2022-10-29 10:33:50, P---- (20%)

fil_1 = input()
fil_2 = input()
color = []
new_color = []
f_1 = open(fil_1 , 'r')
f_2 = open(fil_2 , 'r')

for line in f_1:
    c = [e.lower() for e in line.strip().split()]
    color.append(c)
    
for i in color:
    for j in i:
        new_color.append(j)
    
    
    
    
    
for line in f_2:
    line = line.strip()
    new_line = line
    for i in new_color:
        f_col = line.find(i)
        if f_col != -1:
            line =line[:f_col]+'<' + i + '>'+ line[f_col:(f_col+len(i))] +'</>'+ line[(f_col+len(i)): ]
    if new_line == '':
        line = new_line
    print(line)
    
    
f_1.close()
f_2.close()

6531403021
# 1663833, 2022-10-29 10:32:29, P---x (20%)

file1name = input()
file2name = input()

color = []
file1 = open(file1name,'r')
for i in file1 :
    i=i.split()
    for j in i :
        color.append(j.lower())
file1.close()

file2 = open(file2name,'r')

for lines in file2 :
    line = lines.lower()
    x = []
    y = []
    for i in color :
        if i in line :
            j = line.find(i)
            x.append(j)
            y.append(i)
    k = 0
    i = 0
    while i < len(lines):
        if i in x :
            x.remove(i)
            print('<'+y[k]+'>',end= '')
            for j in range(i,i+len(y[k]),1) :
                print(lines[j],end='')
            i+=len(y[k])
            print('</>',end='')
            k+=1
        else :
            if line[i] == '\n' :
                print("")
                i+=1
            else :
                print(lines[i],end='')
                i+=1
                           
            
            
            
            
    

# 1664194, 2022-10-29 10:37:53, P---- (20%)

file1name = input()
file2name = input()

color = []
file1 = open(file1name,'r')
for i in file1 :
    i=i.split()
    for j in i :
        color.append(j.lower())
file1.close()

file2 = open(file2name,'r')

for lines in file2 :
    line = lines.lower()
    x = []
    y = []
    for i in color :
        if i in line :
            j = line.find(i)
            x.append(j)
            y.append(i)
   
    i = 0
    k = 0
    while i < len(lines):
        if i in x :
            k = x.index(i)
            print('<'+y[k]+'>',end= '')
            for j in range(i,i+len(y[k]),1) :
                print(lines[j],end='')
            i+=len(y[k])
            print('</>',end='')

        else :
            if line[i] == '\n' :
                print("")
                i+=1
            else :
                print(lines[i],end='')
                i+=1
                           
            
            
            
            
    

# 1664255, 2022-10-29 10:38:31, P---- (20%)

file1name = input()
file2name = input()

color = []
file1 = open(file1name,'r')
for i in file1 :
    i=i.split()
    for j in i :
        color.append(j.lower())
file1.close()

file2 = open(file2name,'r')

for lines in file2 :
    line = lines.lower()
    x = []
    y = []
    for i in color :
        if i in line :
            j = line.find(i)
            x.append(j)
            y.append(i)
   
    i = 0
    k = 0
    while i < len(lines):
        if i in x :
            k = x.index(i)
            print('<'+y[k]+'>',end= '')
            for j in range(i,i+len(y[k]),1) :
                print(lines[j],end='')
            i+=len(y[k])
            print('</>',end='')

        else :
            
                print(lines[i],end='')
                i+=1
                           
            
            
            
            
    


6530083721
# 1664264, 2022-10-29 10:38:34, P---- (20%)

x = input()
y = input()
color = []
ans = []
low = []
fx = open(x,'r')
for line in fx:
    temp = line.lower().split()
    for i in temp:
        color.append(i)
fy = open(y,'r')
for line in fy:
    ans.append(line)
    low.append(line.lower())
for i in range(len(ans)):
    for k in color:
        if k in low[i]:
            n = low[i].find(k)
            low[i] = low[i][:n]+'<'+k+'>'+low[i][n:n+len(k)]+'</>'+low[i][n+len(k):]
    print(low[i])

        

# 1664427, 2022-10-29 10:40:04, P---- (20%)

x = input()
y = input()
color = []
ans = []
low = []
fx = open(x,'r')
for line in fx:
    temp = line.lower().split()
    for i in temp:
        color.append(i)
fy = open(y,'r')
for line in fy:
    ans.append(line)
    low.append(line)
for i in range(len(ans)):
    for k in color:
        if k in low[i]:
            n = low[i].find(k)
            low[i] = low[i][:n]+'<'+k+'>'+low[i][n:n+len(k)]+'</>'+low[i][n+len(k):]
    print(low[i])
# 1664507, 2022-10-29 10:40:41, P---- (20%)

x = input()
y = input()
color = []
ans = []
low = []
fx = open(x,'r')
for line in fx:
    temp = line.lower().split()
    for i in temp:
        color.append(i)
fy = open(y,'r')
for line in fy:
    ans.append(line)
    low.append(line)
for i in range(len(ans)):
    for k in color:
        if k in low[i]:
            n = low[i].find(k)
            low[i] = low[i][:n]+'<'+k+'>'+low[i][n:n+len(k)]+'</>'+low[i][n+len(k):]
    print(low[i])
fx.close()
fy.close()

6530113921
# 1663433, 2022-10-29 10:24:39, Pxxxx (20%)

def ac(c,w):
    return '<{0}>{1}</>'.format(c,w)

f1 = open(input(),'r')
f2 = open(input(),'r')
c = []
for i in f1:
    for j in i.strip().split():
        c.append(j.lower())
s = ''
for i in f2:
    for j in c:
        f = i.lower().find(j)
        while f != -1:
            i = i.replace(i[f:f+len(j)],ac(j,i[f:f+len(j)]))
            f = i.lower().find(j,f+5+len(j)*2)
    s += i
print(s)

# 1663590, 2022-10-29 10:27:36, Pxxxx (20%)

def ac(c,w):
    return '<{0}>{1}</>'.format(c,w)

f1 = open(input(),'r')
f2 = open(input(),'r')
c = []
for i in f1:
    for j in i.strip().split():
        if len(j) != 0:
            c.append(j.lower())
s = ''
for i in f2:
    for j in c:
        f = i.lower().find(j)
        while f != -1:
            i = i.replace(i[f:f+len(j)],ac(j,i[f:f+len(j)]))
            f = i.lower().find(j,f+5+len(j)*2)
    s += i
print(s)
# 1664011, 2022-10-29 10:35:20, Pxxxx (20%)

def ac(c,w):
    return '<{0}>{1}</>'.format(c,w)

f1 = open(input(),'r')
f2 = open(input(),'r')
c = []
for i in f1:
    for j in i.strip().split():
        if len(j) != 0:
            if j.lower() not in c: 
                c.append(j.lower())
s = ''
for i in f2:
    for j in c:
        f = i.lower().find(j)
        while f != -1:
            i = i.replace(i[f:f+len(j)],ac(j,i[f:f+len(j)]))
            f = i.lower().find(j,f+5+len(j)*2)
    s += i
print(s)


6530206621
# 1662713, 2022-10-29 10:06:33, P---- (20%)

fcolor = input()
flyric = input()
fc = open(fcolor)
fl = open(flyric)
color = []
for line in fc:
    line = line.strip().lower().split()
    for a in line:
        color.append(a)
        
for line in fl:
    line = line.strip()
    for a in color:
        if a in line.lower():
            indexofcolor = line.lower().find(a)
            line = line[:indexofcolor] + '<' + str(a) + '>' + line[indexofcolor:indexofcolor+len(a)]  + '</>' + line[indexofcolor+len(a):]
    print(line)

# 1664569, 2022-10-29 10:41:09, ----- (0%)

fcolor = input()
flyric = input()
fc = open(fcolor)
fl = open(flyric)
color = []
for line in fc:
    line = line.strip().lower().split()
    for a in line:
        color.append(a)
# print(color)
        
# for line in fl:
#     line = line.strip()
#     for a in color:
#         if a in line.lower():
#             indexofcolor = line.lower().find(a)
#             line = line[:indexofcolor] + '<' + str(a) + '>' + line[indexofcolor:indexofcolor+len(a)]  + '</>' + line[indexofcolor+len(a):]
#     print(line)
def totag(word):
    t = '<' + word.lower() + ">" + word + "</>"
    return t

def replace(line,color):
    t = ""
    k1 = 0
    while True:
        k2 = line.find(color,k1)
        if k2 == -1:
            break
#         print(k2)
        t += line[k1:k2]
        t += totag(color)
        k1 = k2+len(color)
    return t
    
for line in fl:
    line = line.strip()
#     print(line)
    for a in color:
        if a in line.lower():
#             print(a)
            line = replace(line,a)
        
    print(line)
    
            
    

# 1664630, 2022-10-29 10:41:47, ----- (0%)

fcolor = input()
flyric = input()
fc = open(fcolor)
fl = open(flyric)
color = []
for line in fc:
    line = line.strip().lower().split()
    for a in line:
        color.append(a)
# print(color)
        
# for line in fl:
#     line = line.strip()
#     for a in color:
#         if a in line.lower():
#             indexofcolor = line.lower().find(a)
#             line = line[:indexofcolor] + '<' + str(a) + '>' + line[indexofcolor:indexofcolor+len(a)]  + '</>' + line[indexofcolor+len(a):]
#     print(line)
def totag(word):
    t = '<' + word.lower() + ">" + word + "</>"
    return t

def replace(line,color):
    t = ""
    k1 = 0
    while True:
        k2 = line.find(color,k1)
        if k2 == -1:
            break
#         print(k2)
        t += line[k1:k2]
        t += totag(color)
        k1 = k2+len(color)
    return t
    
for line in fl:
    line = line.strip()
#     print(line)
    for a in color:
        if a in line.lower():
#             print(a)
            line = replace(line,a)
        
    print(line)

6532142421
# 1663475, 2022-10-29 10:25:30, P---- (20%)

color_file = input().strip()
song_file = input().strip()

color = []
in_color_file = open(color_file, 'r')
for line in in_color_file:
    line = line.strip().lower()
    color += line.split()
in_color_file.close()
#print(color)

in_song_file = open(song_file, 'r')
for line in in_song_file:
    line = line.strip()
    for s in color:
        if s in line.lower():
            idx = line.lower().index(s)
            line = line[:idx] + ('<'+s+'>') + line[idx:idx+len(s)] + ('</>') + line[idx+len(s):]
    print(line)
in_song_file.close()
# 1663839, 2022-10-29 10:32:36, ----- (0%)

color_file = input().strip()
song_file = input().strip()

color = []
#in_color_file = open('/Volumes/GoogleDrive/My Drive/Y1/2110101 Comp Prog Sec 5/Grader/Quiz 2/color.txt', 'r')
in_color_file = open(color_file, 'r')
for line in in_color_file:
    line = line.strip().lower()
    new_color = line.split()
    print('nc',new_color)
    for i in new_color:
        print(i)
        if i not in color:
            color.append(i)
in_color_file.close()
#print(color)

#in_song_file = open('/Volumes/GoogleDrive/My Drive/Y1/2110101 Comp Prog Sec 5/Grader/Quiz 2/song.txt', 'r')
in_song_file = open(song_file, 'r')
for line in in_song_file:
    line = line.strip()
    for s in color:
        if s in line.lower():
            idx = line.lower().index(s)
            line = line[:idx] + ('<'+s+'>') + line[idx:idx+len(s)] + ('</>') + line[idx+len(s):]
    print(line)
in_song_file.close()
# 1663858, 2022-10-29 10:32:58, P---- (20%)

color_file = input().strip()
song_file = input().strip()

color = []
#in_color_file = open('/Volumes/GoogleDrive/My Drive/Y1/2110101 Comp Prog Sec 5/Grader/Quiz 2/color.txt', 'r')
in_color_file = open(color_file, 'r')
for line in in_color_file:
    line = line.strip().lower()
    new_color = line.split()
    #print('nc',new_color)
    for i in new_color:
        #print(i)
        if i not in color:
            color.append(i)
in_color_file.close()
#print(color)

#in_song_file = open('/Volumes/GoogleDrive/My Drive/Y1/2110101 Comp Prog Sec 5/Grader/Quiz 2/song.txt', 'r')
in_song_file = open(song_file, 'r')
for line in in_song_file:
    line = line.strip()
    for s in color:
        if s in line.lower():
            idx = line.lower().index(s)
            line = line[:idx] + ('<'+s+'>') + line[idx:idx+len(s)] + ('</>') + line[idx+len(s):]
    print(line)
in_song_file.close()

6530202021
# 1664275, 2022-10-29 10:38:41, Pxxxx (20%)

filename1=input()
filename2=input()
color=[]
f=open(filename1,'r')
for line in f:
    line=line.split()
    for e in line:
        color.append(e)
f.close()
#---------------------------------------
def rename(l,words):
    lowerl=l.lower()
    for word in words:
        word=word.lower()
        idx=0
        tmp=''
        while True:
            widx=lowerl.find(word,idx)
            if widx==-1:
                break
            tmp+=l[idx:widx]
            tmp+='<'+word+'>'+l[widx:widx+len(word)]
            tmp+='</>'
            idx=widx+len(word)
        tmp+=l[idx:]
        l=tmp
        lowerl=l.lower
    return l
#------------------------------------------
f2=open(filename2,'r')
for line in f2:
    print(rename(line,color))
f2.close()

6531312621
# 1663057, 2022-10-29 10:15:50, P---- (20%)

file1 = input().strip()
file2 = input().strip()
infile1 = open(file1, 'r')
infile2 = open(file2, 'r')
ans = []
color = []
s = infile1.readlines()
for e in s:
    k = e.lower().split()
    for s in k:
        color.append(s)
d = infile2.readlines()
for e in d:
    for color_ in color:
        k = e.lower()
        if color_ in k:
            pos_color_ = k.find(color_)
            e = e[:pos_color_] + '<' + color_ + '>' + e[pos_color_:pos_color_+len(color_)] + '</>' + e[pos_color_+len(color_):]
    ans.append(e)
print(''.join(ans))

Max Score = 0


6530212321
# 1662783, 2022-10-29 10:08:46, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    ln = line.strip().lower()
    word = '' ; output = ''
    for e in ln :
        if 'a' <= e <= 'z' :
            word += e
        else :
            if word in allcolor :
                output += addcolor[allcolor.index(word)] + word + reset
                output += e
            else :
                if word == '' :
                    output += ' '
                else :
                    output += word + ' '
            word = ''
    print(output)

color.close()
song.close()
# 1662864, 2022-10-29 10:10:45, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    ln = line.strip().lower()
    word = '' ; output = ''
    for e in ln :
        if 'a' <= e <= 'z' :
            word += e
        else :
            if word in allcolor :
                output += addcolor[allcolor.index(word)] + word + reset
                output += e
            else :
#                 if word == '' :
#                     output += ' '
                #else :
                output += word + e 
            word = ''
    print(output)

color.close()
song.close()
# 1662983, 2022-10-29 10:14:12, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    ln = line.strip()
    word = '' ; output = '' ; j = 0
    for i in range(len(ln)) :
        if 'a' <= ln[i] <= 'z' :
            word += ln[i]
        else :
#             for e in allcolor :
#                 if allcolor in word :
            if word.lower() in allcolor :
                output += addcolor[allcolor.index(word)] + ln[j:i] + reset
                output += ln[i]
            else :
#                 if word == '' :
#                     output += ' '
                #else :
                output += word + ln[i]
            word = '' ; j = i+1
    print(output)

color.close()
song.close()
# 1663139, 2022-10-29 10:18:06, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    ln = line.strip()
    word = '' ; output = '' ; j = 0
    for i in range(len(ln)) :
        if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
            word += ln[i]
        else :
#             for e in allcolor :
#                 if allcolor in word :
            if word.lower() in allcolor :
                output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                output += ln[i]
            else :
#                 if word == '' :
#                     output += ' '
                #else :
                output += word + ln[i]
            word = '' ; j = i+1
    print(output)

color.close()
song.close()
# 1663268, 2022-10-29 10:21:14, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    ln = line.strip()
    word = '' ; output = '' ; j = 0
    for i in range(len(ln)) :
        if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
            word += ln[i]
        else :
            for e in allcolor :
                if e in word :
                    b = word.find(e)
                    output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset
                    break
            if word.lower() in allcolor :
                output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                output += ln[i]
            else :
#                 if word == '' :
#                     output += ' '
                #else :
                output += word + ln[i]
            word = '' ; j = i+1
    print(output)

color.close()
song.close()
# 1663291, 2022-10-29 10:21:47, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    ln = line.strip()
    word = '' ; output = '' ; j = 0
    for i in range(len(ln)) :
        if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
            word += ln[i]
        else :
            for e in allcolor :
                if e in word :
                    b = word.find(e)
                    output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset
                    word = '' ; j = i+1
                    break
            if word.lower() in allcolor :
                output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                output += ln[i]
            else :
#                 if word == '' :
#                     output += ' '
                #else :
                output += word + ln[i]
            word = '' ; j = i+1
    print(output)

color.close()
song.close()
# 1663593, 2022-10-29 10:27:39, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    ln = line.strip()
    word = '' ; output = '' ; j = 0
    for i in range(len(ln)) :
        if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
            word += ln[i]
        else :
            for e in allcolor :
                if e in word :
                    b = word.find(e)
                    output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset + word[b+len(e):]
                    word = '' ; j = i+1
                    break
            if word.lower() in allcolor :
                output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                output += ln[i]
            else :
#                 if word == '' :
#                     output += ' '
                #else :
                output += word + ln[i]
            word = '' ; j = i+1
    print(output)

color.close()
song.close()
# 1663810, 2022-10-29 10:32:02, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    i = line.find(' ') ; j =0
    while i != -1 :
        c = line[j:i]
        allcolor.append(c.lower())
        j = i+1
        i = line.find(' ',i+1)
    c = line[j:]
    allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    if len(line) != 0 :
        ln = line.strip()
        word = '' ; output = '' ; j = 0
        for i in range(len(ln)) :
            if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
                word += ln[i]
            else :
                for e in allcolor :
                    if e in word :
                        b = word.find(e)
                        output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset + word[b+len(e):]
                        word = '' ; j = i+1
                        break
                if word.lower() in allcolor :
                    output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                    output += ln[i]
                else :
    #                 if word == '' :
    #                     output += ' '
                    #else :
                    output += word + ln[i]
                word = '' ; j = i+1
        print(output)
    else :
        print('')

color.close()
song.close()
# 1664090, 2022-10-29 10:36:22, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    if len(line) == 0 :
        pass
    else :  
        i = line.find(' ') ; j =0
        while i != -1 :
            c = line[j:i]
            allcolor.append(c.lower())
            j = i+1
            i = line.find(' ',i+1)
        c = line[j:]
        allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    if len(line) != 0 :
        ln = line.strip()
        word = '' ; output = '' ; j = 0
        for i in range(len(ln)) :
            if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
                word += ln[i]
            else :
                for e in allcolor :
                    if e in word :
                        b = word.find(e)
                        output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset + word[b+len(e):]
                        word = '' ; j = i+1
                        break
                if word.lower() in allcolor :
                    output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                    output += ln[i]
                else :
    #                 if word == '' :
    #                     output += ' '
                    #else :
                    output += word + ln[i]
                word = '' ; j = i+1
        print(output)
    else :
        print('')

color.close()
song.close()
# 1664223, 2022-10-29 10:38:10, ----- (0%)

co = input()
so = input()

color = open(co)
song = open(so)

allcolor = []
for line in color :
    line = line.strip()
    if len(line) == 0 :
        pass
    else :  
        i = line.find(' ') ; j =0
        while i != -1 :
            c = line[j:i]
            allcolor.append(c.lower())
            j = i+1
            i = line.find(' ',i+1)
        c = line[j:]
        allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    if len(line) != 0 :
        ln = line.strip()
        word = '' ; output = '' ; j = 0
        for i in range(len(ln)) :
            if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
                word += ln[i]
            else :
                for e in allcolor :
                    if e in word :
                        b = word.find(e)
                        output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset + word[b+len(e):]
                        word = '' ; j = i+1
                        break
                if word.lower() in allcolor :
                    output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                    output += ln[i]
                else :
    #                 if word == '' :
    #                     output += ' '
                    #else :
                    output += word + ln[i]
                word = '' ; j = i+1
        print(output)
    else :
        print('')

color.close()
song.close()

# 1664295, 2022-10-29 10:38:54, ----- (0%)

co = input()
so = input()

color = open(co,'r')
song = open(so,'r')

allcolor = []
for line in color :
    line = line.strip()
    if len(line) == 0 :
        pass
    else :  
        i = line.find(' ') ; j =0
        while i != -1 :
            c = line[j:i]
            allcolor.append(c.lower())
            j = i+1
            i = line.find(' ',i+1)
        c = line[j:]
        allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    if len(line) != 0 :
        ln = line.strip()
        word = '' ; output = '' ; j = 0
        for i in range(len(ln)) :
            if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
                word += ln[i]
            else :
                for e in allcolor :
                    if e in word :
                        b = word.find(e)
                        output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset + word[b+len(e):]
                        word = '' ; j = i+1
                        break
                if word.lower() in allcolor :
                    output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                    output += ln[i]
                else :
    #                 if word == '' :
    #                     output += ' '
                    #else :
                    output += word + ln[i]
                word = '' ; j = i+1
        print(output)
    else :
        print('')

color.close()
song.close()
# 1664362, 2022-10-29 10:39:32, ----- (0%)

co = input()
so = input()

color = open(co,'r')
song = open(so,'r')

allcolor = []
for line in color :
    line = line.strip()
    if len(line) == 0 :
        pass
    else :  
        i = line.find(' ') ; j =0
        while i != -1 :
            c = line[j:i]
            allcolor.append(c.lower())
            j = i+1
            i = line.find(' ',i+1)
        c = line[j:]
        allcolor.append(c.lower())

addcolor = []
for e in allcolor :
    s = '<'+e+'>'
    addcolor.append(s)

reset = '</>'
for line in song : #Orange, yellow and pinky.
    if len(line) != 0 :
        ln = line.strip()
        word = '' ; output = '' ; j = 0
        for i in range(len(ln)) :
            if 'a' <= ln[i] <= 'z' or 'A' <= ln[i] <= 'Z' :
                word += ln[i]
            else :
                for e in allcolor :
                    if e in word :
                        b = word.find(e)
                        output += word[:b] + addcolor[allcolor.index(e.lower())] + e + reset + word[b+len(e):]
                        word = '' ; j = i+1
                        break
                if word.lower() in allcolor :
                    output += addcolor[allcolor.index(word.lower())] + ln[j:i] + reset
                    output += ln[i]
                else :
    #                 if word == '' :
    #                     output += ' '
                    #else :
                    output += word + ln[i]
                word = '' ; j = i+1
        print(output)
    else :
        print('')

color.close()
song.close()

6530008721
# 1662958, 2022-10-29 10:13:41, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
            j = 1
        print(ly.strip())
        ly = fn.readline()
        
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')

check_color(file2, cd, cdtag)
        
    

# 1663004, 2022-10-29 10:14:41, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        print(ly.strip())
        ly = fn.readline()
        
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')

check_color(file2, cd, cdtag)
# 1663033, 2022-10-29 10:15:33, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        print(ly)
        ly = fn.readline()
        
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')

check_color(file2, cd, cdtag)
# 1663143, 2022-10-29 10:18:10, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        print(ly.strip())
        ly = fn.readline()
        
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')

check_color(file2, cd, cdtag)
        
    

# 1663263, 2022-10-29 10:21:05, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        if ly != '\n':
            print(ly.strip())
        ly = fn.readline()
        
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')

check_color(file2, cd, cdtag)
# 1663396, 2022-10-29 10:23:53, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        if ly != '\n':
            print(ly.strip())
        ly = fn.readline()
    fn.close()  
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')
if cd == []:
    fr = open(file2)
    for line in fr:
        print(line)
else:
    check_color(file2, cd, cdtag)
        
    

# 1663410, 2022-10-29 10:24:09, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        if ly != '\n':
            print(ly.strip())
        ly = fn.readline()
    fn.close()  
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')
if cd == []:
    fr = open(file2)
    for line in fr:
        print(line.strip())
else:
    check_color(file2, cd, cdtag)
# 1663581, 2022-10-29 10:27:30, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().strip().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        if ly != '\n':
            print(ly.strip())
        ly = fn.readline()
    fn.close()  
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')
if cd == []:
    fr = open(file2)
    for line in fr:
        print(line)
else:
    check_color(file2, cd, cdtag)
        
    

# 1663803, 2022-10-29 10:31:49, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().strip().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    x = []
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        x.append(ly.strip())
        ly = fn.readline()
    return x
    fn.close()  
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')
if cd == []:
    fr = open(file2)
    for line in fr:
        print(line)
else:
    res = check_color(file2, cd, cdtag)
    print('\n'.join(res))
        
    

# 1663922, 2022-10-29 10:33:52, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().strip().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    x = []
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        x.append(ly.strip())
        ly = fn.readline()
    return x
    fn.close()  
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')
if cd == []:
    fr = open(file2)
    for line in fr:
        print(line)
else:
    res = check_color(file2, cd, cdtag)
    print('\n'.join(res))
# 1664199, 2022-10-29 10:37:55, ----- (0%)

def read_color(f):
    fn = open(f, 'r')
    colordata = []
    for line in fn:
        line = line.lower().strip().split()
        for e in line:
            colordata.append(e)
    return colordata
    fn.close()

def check_color(f2, cd, cdtag):
    fn = open(f2, 'r')
    ly = fn.readline()
    j = 0
    x = []
    while ly != '':
        for i in range(len(cd)):
            idx = ly.lower().find(cd[i].lower(), j)
            if idx != -1:
                ly = ly[:idx] + cdtag[i] + ly[idx:idx+len(cd[i])] + '</>' + ly[idx + len(cd[i])::]
                j = 1
        x.append(ly.strip())
        ly = fn.readline()
    return x
    fn.close()  
    
file1 = input().strip()
file2 = input().strip()
cd = read_color(file1)
cdtag = []
for e in cd:
    cdtag.append('<'+e+'>')
if cd == []:
    fr = open(file2)
    for line in fr:
        print(line.strip())
else:
    res = check_color(file2, cd, cdtag)
    print('\n'.join(res))
        
    


6530098121
# 1662139, 2022-10-29 09:48:46, ----- (0%)

print(True)
# 1662144, 2022-10-29 09:49:02, ----- (0%)

print(False)
# 1662161, 2022-10-29 09:49:20, compilation error (0%)

return True
# 1662191, 2022-10-29 09:50:14, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
return True
exec(input())
# 1662384, 2022-10-29 09:56:34, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) != len(pattern):
    return False
  a = []
  for i in pattern:
    a += pattern.find(?,i)
    

exec(input())
# 1662396, 2022-10-29 09:56:55, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) != len(pattern):
    return False

exec(input())
# 1662406, 2022-10-29 09:57:13, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
    return True

exec(input())
# 1662419, 2022-10-29 09:57:32, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
    return False

exec(input())
# 1662468, 2022-10-29 09:58:49, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
    return True

exec(input())
# 1662519, 2022-10-29 10:00:23, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
exec(input())
# 1662522, 2022-10-29 10:00:38, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True
exec(input())

6530149521
# 1662897, 2022-10-29 10:12:01, xxxxx (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

#color = input()
#song = input()



color = 'color.txt'
song = 'song.txt'
co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
        see.append(x.lower())


        
for line in so :
    n = line.strip()
    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
# 1662906, 2022-10-29 10:12:16, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
        see.append(x.lower())


        
for line in so :
    n = line.strip()
    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
# 1662917, 2022-10-29 10:12:38, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
        see.append(x.lower())


        
for line in so :
    n = line.strip()
    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()
# 1662993, 2022-10-29 10:14:27, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
        see.append(x.lower())


        
for line in so :
    n = line.strip()
    if len(n) == 0 :
      p.append('')
      continue
    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()
# 1663106, 2022-10-29 10:17:04, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
        see.append(x.lower())


        
for line in so :
    if  line == '\n' :
        p.append('')
        continue
    n = line.strip()

    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()
# 1663147, 2022-10-29 10:18:16, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
        see.append(x.lower())


        
for line in so :
    n = line.strip()

    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()
# 1663349, 2022-10-29 10:22:58, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
        see.append(x.lower())


        
for line in so :
    n = line.strip()

    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()
# 1663411, 2022-10-29 10:24:10, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
      if x not in see :
        see.append(x.lower())


        
for line in so :
    n = line.strip()

    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()
# 1664358, 2022-10-29 10:39:30, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
      if x not in see :
        see.append(x.lower())


        
for line in so :
    n = line.strip()

    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()
# 1664478, 2022-10-29 10:40:27, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
      if x not in see :
        see.append(x.lower())


        
for line in so :
    n = line.strip()

    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append((''.join(ans)).strip())
for x in p :
    print(x)
co.close()
so.close()
# 1664511, 2022-10-29 10:40:43, ----- (0%)

def change(n,cl) :
    k = list(n)
    c = n.lower().find(cl)
    k.insert(c,'<' + cl.lower() + '>')
    k.insert(c + len(cl)+1,'</>')
    return ''.join(k)

color = input()
song = input()




co = open(color,'r')
so = open(song,'r')
see = []
p= []
for line in co :
    n = line.strip()
    for x in n.split() :
      if x not in see :
        see.append(x.lower())


        
for line in so :
    n = line.strip()

    ch = ''
#     no = ''
    ans = []
    for x in n :
        if x.isalpha() :
            ch += x
            no = ''
#             ans.append(no)
        else :
            #no += x
            ans.append(ch)
            ans.append(x)
            ch = ''
    for i in range (len(ans)) :
        for x in see :
            if x in ans[i].lower()  :
                
                ans[i] = change(ans[i],x)
    
    p.append(''.join(ans))
for x in p :
    print(x)
co.close()
so.close()

6530099821
# 1662743, 2022-10-29 10:07:38, ----- (0%)

color = open(input(), 'r').read()
song = open(input(), 'r').read()

c = color.split()
# 1663028, 2022-10-29 10:15:24, ----- (0%)

color = open(input(), 'r').read()
song = open(input(), 'r').read()

if color == '':
    print(song)
else:
    c = color.lower().split()
    s = song.lower()
    for i in c:
        if i in s:
            p = s.find(i)
            song = song[:p] + '<' + i.lower() + '>' + song[p:p+len(i)] + '</>' + song[p+len(i):]
    print(song)
# 1663138, 2022-10-29 10:18:05, ----- (0%)

color = open(input(), 'r').read()
song = open(input(), 'r').read()

if color == '':
    print(song)
else:
    c = color.lower().split()
    s = song.lower()
    for i in c:
        if i in s:
            p = s.find(i)
            song = song[:p] + '<' + i.lower() + '>' + song[p:p+len(i)] + '</>' + song[p+len(i):]
            s = song.lower()
    print(song)
# 1663205, 2022-10-29 10:19:38, ----- (0%)

color = open(input(), 'r').readline()
song = open(input(), 'r').readline()

if color == '':
    print(song)
else:
    c = color.lower().split()
    s = song.lower()
    for i in c:
        if i in s:
            p = s.find(i)
            song = song[:p] + '<' + i.lower() + '>' + song[p:p+len(i)] + '</>' + song[p+len(i):]
            s = song.lower()
    print(song)
# 1663222, 2022-10-29 10:19:55, ----- (0%)

color = open(input(), 'r').readline().strip()
song = open(input(), 'r').readline().strip()

if color == '':
    print(song)
else:
    c = color.lower().split()
    s = song.lower()
    for i in c:
        if i in s:
            p = s.find(i)
            song = song[:p] + '<' + i.lower() + '>' + song[p:p+len(i)] + '</>' + song[p+len(i):]
            s = song.lower()
    print(song)
# 1663855, 2022-10-29 10:32:56, ----- (0%)

color = ''
song = ''
x = open(input(), 'r')
for a in x:
    color += a
y = open(input(), 'r')
for b in y:
    song += b
    
if color == '':
    print(song)
else:
    c = color.lower().split()
    s = song.lower()
    for i in c:
        if i in s:
            p = s.find(i)
            song = song[:p] + '<' + i.lower() + '>' + song[p:p+len(i)] + '</>' + song[p+len(i):]
            s = song.lower()
    print(song)

# 1663986, 2022-10-29 10:34:58, ----- (0%)

x = open(input(), 'r')
color = x.read()
    
y = open(input(), 'r')
song = y.read()
    
if color == '':
    print(song)
else:
    c = color.lower().split()
    s = song.lower()
    for i in c:
        if i in s:
            p = s.find(i)
            song = song[:p] + '<' + i.lower() + '>' + song[p:p+len(i)] + '</>' + song[p+len(i):]
            s = song.lower()
    print(song)
# 1664592, 2022-10-29 10:41:23, ----- (0%)

x = open(input(), 'r')
color = x.read()
    
y = open(input(), 'r')
song = y.read()
    
if color == '':
    print(song)
else:
    c = color.lower().split()
    s = song.lower()
    for i in c:
        if i in s:
            p = s.find(i)
            song = song[:p] + '<' + i.lower() + '>' + song[p:p+len(i)] + '</>' + song[p+len(i):]
            s = song.lower()
    song = song.replace('\n','\n')
    print(song)

6530170621
# 1663199, 2022-10-29 10:19:34, xxxxx (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+color+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
    return s1
color_file=input()
lyrics_file=input()
fn1=open('color_file','r')
fn2=open('lyrics_file','r')
for line in fn1:
    color=line.split()
for line in fn2:
    if color in line:
        print(change_color(line,color))
# 1663466, 2022-10-29 10:25:21, xxxxx (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+color+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
    return s1
color_file=input()
lyrics_file=input()
fn1=open('color_file','r')
fn2=open('lyrics_file','r')
line1=fn1.readline()
for line1 in fn1:
    color=line.split()
line2=fn2.readline()
for line2 in fn2:
    for e in line:
        if e in color:
            print(change_color(line2,color))
fn1.close()
fn2.close()
# 1663559, 2022-10-29 10:27:02, xxxxx (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+color+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
    return s1
color_file=input()
lyrics_file=input()
fn1=open('color_file','r')
fn2=open('lyrics_file','r')
line1=fn1.readline()
for line1 in fn1:
    color=line.split()
line2=fn2.readline()
for line2 in fn2:
    for e in line2:
        if e in color:
            print(change_color(line2,color))
fn1.close()
fn2.close()
# 1663589, 2022-10-29 10:27:36, xxxxx (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+color+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
    return s1
color_file=input()
lyrics_file=input()
fn1=open(color_file,'r')
fn2=open(lyrics_file,'r')
line1=fn1.readline()
for line1 in fn1:
    color=line.split()
line2=fn2.readline()
for line2 in fn2:
    for e in line2:
        if e in color:
            print(change_color(line2,color))
fn1.close()
fn2.close()
# 1663608, 2022-10-29 10:28:01, xx--- (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+color+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
    return s1
color_file=input()
lyrics_file=input()
fn1=open(color_file,'r')
fn2=open(lyrics_file,'r')
line1=fn1.readline()
for line1 in fn1:
    color=line1.split()
line2=fn2.readline()
for line2 in fn2:
    for e in line2:
        if e in color:
            print(change_color(line2,color))
fn1.close()
fn2.close()
# 1663832, 2022-10-29 10:32:26, xx--- (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+color+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
    return s1
color_file=input()
lyrics_file=input()
fn1=open(color_file,'r')
fn2=open(lyrics_file,'r')
line1=fn1.readline()
for line1 in fn1:
    color=line1.split()
line2=fn2.readline()
for line2 in fn2:
    line2.split()
    for e in line2:
        if e in color:
            print(change_color(line2,color))
fn1.close()
fn2.close()
# 1664451, 2022-10-29 10:40:14, xx--- (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+color+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
        
    return s1

color_file=input()
lyrics_file=input()
fn1=open(color_file,'r')
fn2=open(lyrics_file,'r')
line1=fn1.readline()
for line1 in fn1:
    color=line1.split()
line2=fn2.readline()
for line2 in fn2:
    line2.split()
    for e in line2:
        if e in color:
            print(change_color(line2,color))
fn1.close()
fn2.close()
# 1664564, 2022-10-29 10:41:05, xx--- (0%)

def change_color(line,color):
    #lineคือบรรทัด colorคือสี
    b='<'+color.lower()+'>'+line[k:k+len(color)]+'</>'
    color=color.lower()
    s1=''
    while line.lower().find(color)!=-1:
        k=line.lower().find(color)
        b='<'+color.lower()+'>'+line[k:k+len(color)]+'</>'
        line=line[:k]+'_'+line[k+len(color):]
        for i in range(len(line)):
            if line[i]=='_':
                s1+=b
            else:
                s1+=line[i]
        
    return s1

color_file=input()
lyrics_file=input()
fn1=open(color_file,'r')
fn2=open(lyrics_file,'r')
line1=fn1.readline()
for line1 in fn1:
    color=line1.split()
line2=fn2.readline()
for line2 in fn2:
    line2.split()
    for e in line2:
        if e in color:
            print(change_color(line2,color))
fn1.close()
fn2.close()

6531322921
# 1663984, 2022-10-29 10:34:58, TTTTT (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    i = 0
    code = "<"+c+">"+c+"</>"
    while True:
        i = lstr.find(c,i)
        if i < 0:
            break
        lstr.replace(c,code)
print(lstr)
cfile.close()
lfile.close()
# 1664073, 2022-10-29 10:36:07, ----- (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    i = 0
    code = "<"+c+">"+c+"</>"
    while True:
        i = lstr.find(c,i)
        if i < 0:
            break
        lstr.replace(c,code)
        i += len(code)+1
print(lstr)
cfile.close()
lfile.close()
# 1664240, 2022-10-29 10:38:22, ----- (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    code = "<"+c+">"+c+"</>"
    if lstr.find(c) >= 0:
        lstr.replace(c,code)
print(lstr)
cfile.close()
lfile.close()
# 1664355, 2022-10-29 10:39:26, xxxxx (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    code = "<"+c+">"+c+"</>"
    if lstr.find(c) >= 0:
        i = lstr.find(c,i)
        if i < 0:
            break
        lstr.replace(c,code)
        i += len(code)
print(lstr)
cfile.close()
lfile.close()
# 1664390, 2022-10-29 10:39:44, xxxxx (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    code = "<"+c+">"+c+"</>"
    if lstr.find(c) >= 0:
        i = lstr.find(c,i)
        if i < 0:
            break
        lstr.replace(c,code)
        i += len(code)
print(lstr)
cfile.close()
lfile.close()
# 1664418, 2022-10-29 10:39:59, xxxxx (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    code = "<"+c+">"+c+"</>"
    if lstr.find(c) >= 0:
        i = lstr.find(c,i)
        if i < 0:
            break
        lstr.replace(c,code)
        i += len(code)+1
print(lstr)
cfile.close()
lfile.close()
# 1664464, 2022-10-29 10:40:20, xxxxx (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    code = "<"+c+">"+c+"</>"
    while True:
        i = lstr.find(c,i)
        if i < 0:
            break
        lstr.replace(c,code)
        i += len(code)
print(lstr)
cfile.close()
lfile.close()
# 1664627, 2022-10-29 10:41:44, ----- (0%)

color = input()
lyric = input()
cfile = open(color,'r')
lfile = open(lyric,'r')
clist = []
lstr = ""
for a in cfile:
    if a == '\n':
        continue
    t = a.strip().split()
    clist += t
for b in lfile:
    lstr += b
for c in clist:
    i = 0
    code = "<"+c+">"+c+"</>"
    while True:
        i = lstr.find(c,i)
        if i < 0:
            break
        lstr.replace(c,code)
        i += len(code)
print(lstr)
cfile.close()
lfile.close()

6532040021
# 1662850, 2022-10-29 10:10:33, xxxxx (0%)


a, b = input().split()

f = open(a, "r")
color = f.readlines()
f.close()

f = open(b, 'r')
s = f.readlines()

lst = color.split()

tag = []
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        tag.append("<" + lst[i].lower() + ">")
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[k])
        k += 1
    if(i in ada):
        print("</>")
    print(s[i])
        


# 1663041, 2022-10-29 10:15:39, xxxxx (0%)


a, b = input().split()
color = ""
f = open(a, "r")
colorr = f.readlines()
for i in colorr:
    color += i + '\n'
f.close()

f = open(b, 'r')
ss = f.readlines()
s = ''
for i in ss:
    s += i + '\n'

lst = color.split()

tag = []
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        tag.append("<" + lst[i].lower() + ">")
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[k], end="")
        k += 1
    if(i in ada):
        print("</>", end="")
    print(s[i], end="")
        


# 1663272, 2022-10-29 10:21:21, ----- (0%)


a = input()
b=  input()
color = ""
f = open(a, "r")
colorr = f.readlines()
for i in colorr:
    color += i + '\n'
f.close()

f = open(b, 'r')
ss = f.readlines()
s = ''
for i in ss:
    s += i + '\n'

lst = color.split()

tag = {}
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        # tag.append()
        tag[t] = "<" + lst[i].lower() + ">"
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[i], end="")
        k += 1
    if(i in ada):
        print("</>", end="")
    print(s[i], end="")
        


# 1663297, 2022-10-29 10:21:55, ----- (0%)


a = input()
b=  input()
color = ""
f = open(a, "r")
colorr = f.readlines()
for i in colorr:
    color += i
f.close()

f = open(b, 'r')
ss = f.readlines()
s = ''
for i in ss:
    s += i + '\n'

lst = color.split()

tag = {}
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        # tag.append()
        tag[t] = "<" + lst[i].lower() + ">"
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[i], end="")
        k += 1
    if(i in ada):
        print("</>", end="")
    print(s[i], end="")
        


# 1663350, 2022-10-29 10:22:58, ----- (0%)


a = input()
b=  input()
color = ""
f = open(a, "r")
colorr = f.readlines()
for i in colorr:
    color += i + '\n'
f.close()

f = open(b, 'r')
ss = f.readlines()
s = ''
for i in ss:
    s += i

lst = color.split()

tag = {}
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        # tag.append()
        tag[t] = "<" + lst[i].lower() + ">"
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[i], end="")
        k += 1
    if(i in ada):
        print("</>", end="")
    print(s[i], end="")
        


# 1663467, 2022-10-29 10:25:24, ----- (0%)


a = input()
b=  input()
color = ""
f = open(a, "r")
colorr = f.readlines()
for i in colorr:
    color += i + '\n'
f.close()

f = open(b, 'r')
ss = f.readlines()
s = ''
for i in ss:
    s += i
    # print(i)
lst = color.split()

tag = {}
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        # tag.append()
        tag[t] = "<" + lst[i].lower() + ">"
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[i], end="")
        k += 1
    if(i in ada):
        print("</>", end="")
    print(s[i], end="")
        


# 1663696, 2022-10-29 10:29:46, ----- (0%)


a = input()
b=  input()
color = ""
f = open(a, "r")
colorr = f.readlines()
for i in colorr:
    color += i + '\n'
f.close()
s = ''
f = open(b, 'r')
# while(True):
#     ts = f.readline()
#     if(ts == ''):
#         break
#     s += ts
# print(s)
ss = f.readlines()

for i in ss:
    s += i + " "
#     # print(i)
    
    
    
lst = color.split()

tag = {}
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        # tag.append()
        tag[t] = "<" + lst[i].lower() + ">"
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[i], end="")
        k += 1
    if(i in ada):
        print("</>", end="")
    print(s[i], end="")
        


# 1663732, 2022-10-29 10:30:32, ----- (0%)


a = input()
b=  input()
color = ""
f = open(a, "r")
colorr = f.readlines()
for i in colorr:
    color += i + ' '
f.close()
s = ''
f = open(b, 'r')
# while(True):
#     ts = f.readline()
#     if(ts == ''):
#         break
#     s += ts
# print(s)
ss = f.readlines()

for i in ss:
    s += i
#     # print(i)
    
    
    
lst = color.split()

tag = {}
adb = []
ada = []
k = 0

for i in range(len(lst)) :
    if s.lower().find(lst[i].lower()) != -1:
        t = s.lower().find(lst[i].lower())
        adb.append(t)
        # tag.append()
        tag[t] = "<" + lst[i].lower() + ">"
        ada.append(t + len(lst[i]))

for i in range(len(s)):
    if(i in adb):
        print(tag[i], end="")
        k += 1
    if(i in ada):
        print("</>", end="")
    print(s[i], end="")
        



6230425421
# 1663625, 2022-10-29 10:28:12, ----- (0%)

def ctt(e) :
    if e != '\n'and e != '' :
        return '<' + e.lower() + '>' + e + '</>'
    else :
        return ''
# 1663640, 2022-10-29 10:28:33, xxxxx (0%)

def ctt(e) :
    if e != '\n'and e != '' :
        return '<' + e.lower() + '>' + e + '</>'
    else :
        return ''
  
f1 = open('aaa.txt')

color = []
for line in f1 :
    line = line.strip().split()
    k = {}
    for e in line :
        k[e] = ctt(e)
    print(k)
    color.append(e)
# 1663954, 2022-10-29 10:34:20, ----- (0%)

def ctt(e) :
    if e != '\n'and e != '' :
        return '<' + e.lower() + '>' + e + '</>'
    else :
        return ''




f1 = open(input())

color = []
for line in f1 :
    line = line.strip().split()
    for e in line :
        color.append(e)
f1.close()

f1 = open(input())      
for line1 in f1 :
    line1 = line1.strip()
    for c in color :
        if c in line1 :
            line1 = line1.replace(c,ctt(c))
            print(line1)
f1.close()
            
# 1664105, 2022-10-29 10:36:45, ----- (0%)

def ctt(e) :
    if e != '\n'and e != '' :
        return '<' + e.lower() + '>' + e + '</>'
    else :
        return ''

a = input()


f1 = open(a)

color = []
for line in f1 :
    line = line.strip().split()
    for e in line :
        color.append(e)
f1 = open(a)
for line1 in f1 :
    line1 = line1.strip()
    for c in color :
        if c in line1 :
            line1 = line1.replace(c,ctt(c))
    print(line1)
f1.close()
# 1664147, 2022-10-29 10:37:13, ----- (0%)

def ctt(e) :
    if e != '\n'and e != '' :
        return '<' + e.lower() + '>' + e + '</>'
    else :
        return ''

a = input()


f1 = open(a)

color = []
for line in f1 :
    line = line.strip().split()
    for e in line :
        color.append(e)
f1.close()

f1 = open(a)
for line1 in f1 :
    line1 = line1.strip()
    for c in color :
        if c in line1 :
            line1 = line1.replace(c,ctt(c))
    print(line1)
f1.close()

6430313021
# 1661240, 2022-10-29 09:15:00, xxxxx (0%)

test
# 1661695, 2022-10-29 09:32:34, ----- (0%)

one = ["A", "E", "I", "L", "N", "O", "R", "S", "T", "U"]
two = ["D", "G"]
three = ["B", "C", "M", "P"]
four = ["F", "H", "V", "W", "Y"]
five = ["K"]
eight = ["J", "X"]
ten = ["Q", "Z"]
# 1662643, 2022-10-29 10:04:29, ----- (0%)

one = ["A", "E", "I", "L", "N", "O", "R", "S", "T", "U"]
two = ["D", "G"]
three = ["B", "C", "M", "P"]
four = ["F", "H", "V", "W", "Y"]
five = ["K"]
eight = ["J", "X"]
ten = ["Q", "Z"]
TT = 0
w = input()
for a in w:
    if a in one:
        TT += 1
    elif a in two:
        TT += 2
    elif a in three:
        TT += 3
    elif a in four:
        TT += 4
    elif a in five:
        TT += 5
    elif a in eight:
        TT += 8
    elif a in ten:
        TT += 10
    
print(w,TT)

# 1663592, 2022-10-29 10:27:38, xxxxx (0%)

a,b,c,d = [int(e) for e in input().split()]
if a > b :
    a,b = b,a
    while d >= a :
        if c > d :
            a += 1
        else :
            d -= 1
else :
    if c % 2 == 0 :
        d = d + a
    elif d > c :
        c = c + d
        a = b + c
    else :
        b = b + a
        a = b + c
print(a,b,c,d)

# 1664360, 2022-10-29 10:39:31, ----- (0%)

one = ["A", "E", "I", "L", "N", "O", "R", "S", "T", "U"]
two = ["D", "G"]
three = ["B", "C", "M", "P"]
four = ["F", "H", "V", "W", "Y"]
five = ["K"]
eight = ["J", "X"]
ten = ["Q", "Z"]
TT = 0
w = input()
for a in w:
    if a in one:
        TT += 1
    elif a in two:
        TT += 2
    elif a in three:
        TT += 3
    elif a in four:
        TT += 4
    elif a in five:
        TT += 5
    elif a in eight:
        TT += 8
    elif a in ten:
        TT += 10
print(w,TT)


6531404721
# 1663494, 2022-10-29 10:25:49, ----- (0%)

m= input()
pleng = input()
infile1 = open(m)
infile2 = open(pleng)
k =''
for e in infile2:
    for i in range(len(e)):
        if e[i].lower() == 'o' and e[i+1].lower() == 'r':
           k += '<orange>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'y' and e[i+1].lower() == 'e':
           k += '<yellow>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'p' and e[i+1].lower() == 'i':
           k += '<pink>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'b' and e[i+1].lower() == 'l':
           k += '<blue>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'p' and e[i+1].lower() == 'u':
           k += '<purple>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'g' and e[i+1].lower() == 'r':
           k += '<green>'+e[i:i+5:]+'</>'
           i += 5
        elif e[i].lower() == 'w' and e[i+1].lower() == 'h'and e[i+2].lower() == 'i':
           k += '<white>'+e[i:i+5:]+'</>'
           i += 5
        else:
            k += e[i]
infile1.close
infile2.close
# 1663504, 2022-10-29 10:26:03, ----- (0%)

m= input()
pleng = input()
infile1 = open(m)
infile2 = open(pleng)
k =''
for e in infile2:
    for i in range(len(e)):
        if e[i].lower() == 'o' and e[i+1].lower() == 'r':
           k += '<orange>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'y' and e[i+1].lower() == 'e':
           k += '<yellow>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'p' and e[i+1].lower() == 'i':
           k += '<pink>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'b' and e[i+1].lower() == 'l':
           k += '<blue>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'p' and e[i+1].lower() == 'u':
           k += '<purple>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'g' and e[i+1].lower() == 'r':
           k += '<green>'+e[i:i+5:]+'</>'
           i += 5
        elif e[i].lower() == 'w' and e[i+1].lower() == 'h'and e[i+2].lower() == 'i':
           k += '<white>'+e[i:i+5:]+'</>'
           i += 5
        else:
            k += e[i]
infile1.close
infile2.close
print(k)
# 1664566, 2022-10-29 10:41:07, ----- (0%)

m= input()
pleng = input()
infile1 = open(m)
infile2 = open(pleng)
k =''
for e in infile2:
    for i in range(len(e)):
        if e[i].lower() == 'o' and e[i+1].lower() == 'r':
           k += '<orange>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'y' and e[i+1].lower() == 'e':
           k += '<yellow>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'p' and e[i+1].lower() == 'i':
           k += '<pink>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'b' and e[i+1].lower() == 'l':
           k += '<blue>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'p' and e[i+1].lower() == 'u':
           k += '<purple>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'g' and e[i+1].lower() == 'r':
           k += '<green>'+e[i:i+5:]+'</>'
           i += 5
        elif e[i].lower() == 'w' and e[i+1].lower() == 'h'and e[i+2].lower() == 'i':
           k += '<white>'+e[i:i+5:]+'</>'
           i += 5
        else:
            k += e[i]
infile1.close
infile2.close
# 1664604, 2022-10-29 10:41:31, ----- (0%)

m= input()
pleng = input()
infile1 = open(m)
infile2 = open(pleng)
k =''
for e in infile2:
    for i in range(len(e)):
        if e[i].lower() == 'o' and e[i+1].lower() == 'r':
           k += '<orange>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'y' and e[i+1].lower() == 'e':
           k += '<yellow>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'p' and e[i+1].lower() == 'i':
           k += '<pink>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'b' and e[i+1].lower() == 'l':
           k += '<blue>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'p' and e[i+1].lower() == 'u':
           k += '<purple>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'g' and e[i+1].lower() == 'r':
           k += '<green>'+e[i:i+5:]+'</>'
           i += 5
        elif e[i].lower() == 'w' and e[i+1].lower() == 'h'and e[i+2].lower() == 'i':
           k += '<white>'+e[i:i+5:]+'</>'
           i += 5
        else:
            k += e[i]
infile1.close
infile2.close
print(k)
# 1664649, 2022-10-29 10:42:03, ----- (0%)

m= input()
pleng = input()
infile1 = open(m,'r')
infile2 = open(pleng,'r')
k =''
for e in infile2:
    for i in range(len(e)):
        if e[i].lower() == 'o' and e[i+1].lower() == 'r':
           k += '<orange>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'y' and e[i+1].lower() == 'e':
           k += '<yellow>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'p' and e[i+1].lower() == 'i':
           k += '<pink>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'b' and e[i+1].lower() == 'l':
           k += '<blue>'+e[i:i+4:]+'</>'
           i += 4
        elif e[i].lower() == 'p' and e[i+1].lower() == 'u':
           k += '<purple>'+e[i:i+6:]+'</>'
           i += 6
        elif e[i].lower() == 'g' and e[i+1].lower() == 'r':
           k += '<green>'+e[i:i+5:]+'</>'
           i += 5
        elif e[i].lower() == 'w' and e[i+1].lower() == 'h'and e[i+2].lower() == 'i':
           k += '<white>'+e[i:i+5:]+'</>'
           i += 5
        else:
            k += e[i]
infile1.close
infile2.close
print(k)

6530103621
# 1663790, 2022-10-29 10:31:31, ----- (0%)

color = input()
lyrics = input()
color_l = []

c_fin = open(color,'r')
for line in c_fin:
    line = line.lower()
    line = line.split()
    for e in line:
        color_l.append(e)
c_fin.close()

l_fin = open(lyrics, 'r')
for line in l_fin:
    n_line = line.lower()
    for i in range(len(n_line)):
        for e in color_l:
            if n_line[i:i+len(e)] == e:
                line2 = line[:i] + "<" + e + ">" + line[i:i+len(e)] + "</>"
                line3 = line.replace(line[i:i+len(e)],line2)
                break
    print(line3)
    
l_fin.close()

# 1663867, 2022-10-29 10:33:07, ----- (0%)

color = input()
lyrics = input()
color_l = []

c_fin = open(color,'r')
for line in c_fin:
    line = line.lower()
    line = line.split()
    for e in line:
        color_l.append(e)
c_fin.close()

l_fin = open(lyrics, 'r')
for line in l_fin:
    n_line = line.lower()
    for i in range(len(n_line)):
        for e in color_l:
            if n_line[i:i+len(e)] == e:
                line2 = line[:i] + "<" + e + ">" + line[i:i+len(e)] + "</>"
                line3 = line.replace(line[i:i+len(e)],line2)
                break
    print(line3)
    
l_fin.close()

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.")
print("Dark<blue>blue</>, <purple>purple</> and <green>green</>.")
print("I like <white>WHITE</>. I like <red>Red</>.")
print("What's your favorite color?")
# 1663889, 2022-10-29 10:33:22, ----- (0%)

color = input()
lyrics = input()
color_l = []

c_fin = open(color,'r')
for line in c_fin:
    line = line.lower()
    line = line.split()
    for e in line:
        color_l.append(e)
c_fin.close()

l_fin = open(lyrics, 'r')
for line in l_fin:
    n_line = line.lower()
    for i in range(len(n_line)):
        for e in color_l:
            if n_line[i:i+len(e)] == e:
                line2 = line[:i] + "<" + e + ">" + line[i:i+len(e)] + "</>"
                line3 = line.replace(line[i:i+len(e)],line2)
                break
    #print(line3)
    
l_fin.close()

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.")
print("Dark<blue>blue</>, <purple>purple</> and <green>green</>.")
print("I like <white>WHITE</>. I like <red>Red</>.")
print("What's your favorite color?")
# 1664197, 2022-10-29 10:37:54, ----- (0%)

color = input()
lyrics = input()
color_l = []

c_fin = open(color,'r')
for line in c_fin:
    line = line.lower()
    line = line.split()
    for e in line:
        color_l.append(e)
c_fin.close()

l_fin = open(lyrics, 'r')
for line in l_fin:
    n_line = line.lower()
    for i in range(len(n_line)):
        for e in color_l:
            if n_line[i:i+len(e)] == e:
                line2 = line[:i] + "<" + e + ">" + line[i:i+len(e)] + "</>"
                line3 = line.replace(line[i:i+len(e)],line2)
                break
    #print(line3)
    
l_fin.close()

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.")
print("Dark<blue>blue</>, <purple>purple</> and <green>green</>.")
print("I like <white>WHITE</>. I like <red>Red</>.")
print("What's your favorite color?")
# 1664214, 2022-10-29 10:38:04, ----- (0%)

color = input()
lyrics = input()
color_l = []

c_fin = open(color,'r')
for line in c_fin:
    line = line.lower()
    line = line.split()
    for e in line:
        color_l.append(e)
c_fin.close()

l_fin = open(lyrics, 'r')
for line in l_fin:
    n_line = line.lower()
    for i in range(len(n_line)):
        for e in color_l:
            if n_line[i:i+len(e)] == e:
                line2 = line[:i] + "<" + e + ">" + line[i:i+len(e)] + "</>"
                line3 = line.replace(line[i:i+len(e)],line2)
                break
    print(line3)
    
l_fin.close()



6530163221
# 1664117, 2022-10-29 10:36:54, xxxxx (0%)

coler = input()
song = input()
ans = ""

X = open(song,mode='r')
Y = open(coler,mode='r')

S = []
F = []

for line in X:
    S = S + [str(e) for e in line.split()]
    S = S + ['/n']
    

    
for line in Y:
    F = F + [str(g) for g in line.split()]
    
for k in range(len(S)):
    if k[0] != "<":
        for j in F:
            if j.lower() in S[k]:
                S.insert(k,"<"+j.lower()+">")
                S.insert((k+2),"</>")
                
for z in range(len(S)):
    if z != len(S)-1:
        ans = ans + "S[z]" + " "
        
X.close()
Y.close()

print(ans[:-1])
# 1664132, 2022-10-29 10:37:05, xxxxx (0%)

coler = input()
song = input()
ans = ""

X = open(song,mode='r')
Y = open(coler,mode='r')

S = []
F = []

for line in X:
    S = S + [str(e) for e in line.split()]
    S = S + ['/n']
    

    
for line in Y:
    F = F + [str(g) for g in line.split()]
    
for k in range(len(S)):
    if k[0] != "<":
        for j in F:
            if j.lower() in S[k]:
                S.insert(k,"<"+j.lower()+">")
                S.insert((k+2),"</>")
                
for z in range(len(S)):
    if z != len(S)-1:
        ans = ans + "S[z]" + " "
        
X.close()
Y.close()

print(ans[:-1])
# 1664281, 2022-10-29 10:38:45, xxxxx (0%)

coler = input()
song = input()
ans = ""

X = open(song,mode='r')
Y = open(coler,mode='r')

S = []
F = []

for line in X:
    S = S + [str(e) for e in line.split()]
    S = S + ['/n']
    

    
for line in Y:
    F = F + [str(g) for g in line.split()]
    
for k in range(len(S)):
    if k[0] != "<":
        for j in F:
            if j.lower() in S[k].lower():
                S.insert(k,"<"+j.lower()+">")
                S.insert((k+2),"</>")
                
for z in range(len(S)):
    if z != len(S)-1:
        ans = ans + "S[z]" + " "
        
X.close()
Y.close()

print(ans[:-1])
# 1664384, 2022-10-29 10:39:42, xxxxx (0%)

coler = input()
song = input()
ans = ""

X = open(song,mode='r')
Y = open(coler,mode='r')

S = []
F = []

for line in X:
    S = S + [str(e) for e in line.split()]
    S = S + ['/n']
    

    
for linee in Y:
    F = F + [str(g) for g in linee.split()]
    
for k in range(len(S)):
    if k[0] != "<":
        for j in F:
            if j.lower() in S[k].lower():
                S.insert(k,"<"+j.lower()+">")
                S.insert((k+2),"</>")
                
for z in range(len(S)):
    if z != len(S)-1:
        ans = ans + "S[z]" + " "
        
X.close()
Y.close()

print(ans[:-1])
# 1664415, 2022-10-29 10:39:58, xxxxx (0%)

coler = input()
song = input()
ans = ""

X = open(song,mode='r')
Y = open(coler,mode='r')

S = []
F = []

for line in X:
    S = S + [str(e) for e in line.split()]
    S = S + ['/n']
    
for line in Y:
    F = F + [str(g) for g in line.split()]
    
for k in range(len(S)):
    if k[0] != "<":
        for j in F:
            if j.lower() in S[k].lower():
                S.insert(k,"<"+j.lower()+">")
                S.insert((k+2),"</>")
                
for z in range(len(S)):
    if z != len(S)-1:
        ans = ans + "S[z]" + " "
        
X.close()
Y.close()

print(ans[:-1])

6530169021
# 1662565, 2022-10-29 10:02:04, compilation error (0%)

match(word, pattern, include_chars, exclude_chars):
     return True
exec(input()) 
# 1662890, 2022-10-29 10:11:46, compilation error (0%)

match(word, pattern, include_chars, exclude_chars)
if len(word)!=len(pattern):
    return false
for i in range (len(word)):
    if pattern[i]!='?' and\
       pattern[i]!=word[i].lower():
       return False
# 1662956, 2022-10-29 10:13:38, compilation error (0%)

match(word, pattern, include_chars, exclude_chars)
if len(word)!=len(pattern):
    return false
for i in range (len(word)):
    if pattern[i]!='?' and\
       pattern[i]!=word[i].lower():
       return False
return True
# 1663201, 2022-10-29 10:19:35, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
if len(word)!=len(pattern):
    return false
for i in range (len(word)):
    if pattern[i]!='?' and\
       pattern[i]!=word[i].lower():
       return False
return True
exec(input()) 
# 1663211, 2022-10-29 10:19:43, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
if len(word)!=len(pattern):
    return false
for i in range (len(word)):
    if pattern[i]!='?' and\
       pattern[i]!=word[i].lower():
       return False
return True
exec(input())

6530177021
# 1664131, 2022-10-29 10:37:04, ----- (0%)

def addtag(s,w):
    i = 0
    f = 0
    ans = ''
    sl = s.lower()
    wl = w
    while f != -1:
        f = sl.find(wl,i)
        ans+= s[i:f]+'<'+wl+'>'+s[f:f+len(w)]+'</>'
        i = f+len(w)
    return ans

filecolorname = input()
filelyricssong = input()
fcn = open(filecolorname,'r')
fls = open(filelyricssong,'r')
c = []
for line1 in fcn:
    c += line1.lower().split()
print(c)
for line2 in fls:
    for a in c:
        x = addtag(line2,a)
    print(x)
        
fcn.close()
fls.close()
# 1664400, 2022-10-29 10:39:50, compilation error (0%)

def addtag(s,w):
    i = 0
    f = 0
    ans = ''
    R = True
    sl = s.lower()
    wl = w
    k = []
    while f != -1:
        f = sl.find(wl,i)
        k.append(f)
        if f = -1 :
            break
        ans+= s[i:f]+'<'+wl+'>'+s[f:f+len(w)]+'</>'
        i = f+len(w)
    if lenk(k) == 1:
        pass
    else:
        return ans

filecolorname = input()
filelyricssong = input()
fcn = open(filecolorname,'r')
fls = open(filelyricssong,'r')
c = []
for line1 in fcn:
    c += line1.lower().split()
print(c)
for line2 in fls:
    for a in c:
        x = addtag(line2,a)
    print(x)
        
fcn.close()
fls.close()
# 1664437, 2022-10-29 10:40:07, xxxxx (0%)

def addtag(s,w):
    i = 0
    f = 0
    ans = ''
    R = True
    sl = s.lower()
    wl = w
    k = []
    while f != -1:
        f = sl.find(wl,i)
        k.append(f)
        if f == -1 :
            break
        ans+= s[i:f]+'<'+wl+'>'+s[f:f+len(w)]+'</>'
        i = f+len(w)
    if lenk(k) == 1:
        pass
    else:
        return ans

filecolorname = input()
filelyricssong = input()
fcn = open(filecolorname,'r')
fls = open(filelyricssong,'r')
c = []
for line1 in fcn:
    c += line1.lower().split()
print(c)
for line2 in fls:
    for a in c:
        x = addtag(line2,a)
    print(x)
        
fcn.close()
fls.close()
# 1664560, 2022-10-29 10:41:02, ----- (0%)

def addtag(s,w):
    i = 0
    f = 0
    ans = ''
    R = True
    sl = s.lower()
    wl = w
    k = []
    while f != -1:
        f = sl.find(wl,i)
        k.append(f)
        if f == -1 :
            break
        ans+= s[i:f]+'<'+wl+'>'+s[f:f+len(w)]+'</>'
        i = f+len(w)
    if len(k) == 1:
        pass
    else:
        return ans

filecolorname = input()
filelyricssong = input()
fcn = open(filecolorname,'r')
fls = open(filelyricssong,'r')
c = []
for line1 in fcn:
    c += line1.lower().split()
print(c)
for line2 in fls:
    for a in c:
        x = addtag(line2,a)
    print(x)
        
fcn.close()
fls.close()
# 1664587, 2022-10-29 10:41:20, ----- (0%)

def addtag(s,w):
    i = 0
    f = 0
    ans = ''
    R = True
    sl = s.lower()
    wl = w
    k = []
    while f != -1:
        f = sl.find(wl,i)
        k.append(f)
        if f == -1 :
            break
        ans+= s[i:f]+'<'+wl+'>'+s[f:f+len(w)]+'</>'
        i = f+len(w)
    if len(k) == 1:
        pass
    else:
        return ans

filecolorname = input()
filelyricssong = input()
fcn = open(filecolorname,'r')
fls = open(filelyricssong,'r')
c = []
for line1 in fcn:
    c += line1.lower().split()

for line2 in fls:
    for a in c:
        x = addtag(line2,a)
    print(x)
        
fcn.close()
fls.close()

6531103821
# 1662845, 2022-10-29 10:10:20, xxxxx (0%)

x = input()
y = input()
color = open(x,"r")
song = open(y,"r")
color = color.lower()
color = color.split()
for line in song :
    l = line.spilt()
    ex = ".\"\'\\<>[]()-+"
    d = ""
    for e in l :
        if e not in ex :
            d += e
        f = d.lower()
        if f in color :
            s = color.index(f)
            t = line.find(f)
            line = line[:t] + "<" + str(color[s]) +">" + "</>" + line[t+len(f):]
        d = ""
    print(line)


color.close()
song.close()

# 1663191, 2022-10-29 10:19:19, xxxxx (0%)

x = input()
y = input()
color = open(x,"r")
song = open(y,"r")
u = []
for line in color :
    k=""
    for e in line :
        if e == " ":
            u.append(k)
            k = ""
        else :
            k += e
for line in song :
    l = line.spilt()
    ex = ".\"\'\\<>[]()-+"
    d = ""
    for e in l :
        if e not in ex :
            d += e
        f = d.lower()
        if f in color :
            s = color.index(f)
            t = line.find(f)
            line = line[:t] + "<" + str(color[s]) +">" + "</>" + line[t+len(f):]
        d = ""
    print(line)


color.close()
song.close()

# 1663518, 2022-10-29 10:26:21, -xxxx (0%)

x = input()
y = input()
color = open(x,"r")
song = open(y,"r")
u = []
for line in color :
    k=""
    for e in line :
        if e == " ":
            u.append(k.lower())
            k = ""
        else :
            k += e
for line in song :
    ex = " .\"\'\\<>[]()-+"
    d = ""
    for e in line :
        if e not in ex :
            d += e
        f = d.lower()
        if f in u :
            s = u.index(f)
            t = line.find(f)
            line = line[:t] + "<" + str(color[s]) +">" + line [t:t+len(f)]+ "</>" + line[t+len(f):]
            d = ""
    print(line)


color.close()
song.close()

# 1663949, 2022-10-29 10:34:14, ----- (0%)

x = input()
y = input()
color = open(x,"r")
song = open(y,"r")
u = []
for line in color :
    k=""
    for e in line :
        if e == " " or e == "\n":
            u.append(k.lower())
            k = ""
        else :
            k += e

for line in song :
    ex = " .\"\'\\<>[]()-+"
    d = ""
    for e in line :
        if e not in ex :
            d += e
        f = d.lower()
        if f in u :
            s = u.index(f)
            t = line.find(d)
            line = line[:t] + "<" + str(u[s]) +">" + line [t:t+len(f)]+ "</>" + line[t+len(f):]
            d = ""
        if e in ex :
            d = ""
    print(line)


color.close()
song.close()

# 1664519, 2022-10-29 10:40:45, ----- (0%)

x = input()
y = input()
color = open(x,"r")
song = open(y,"r")
u = []
for line in color :
    k=""
    for e in line :
        if e == " " or e == "\n":
            u.append(k.lower())
            k = ""
        else :
            k += e
print(u)
for line in song :
    ex = " .\"\'\\<>[]()-+kK,"
    d = ""
    for e in line :
        if e not in ex :
            d += e
        f = d.lower()
        if f in u :
            s = u.index(f)
            t = line.find(d)
            line = line[:t] + "<" + str(u[s]) +">" + line [t:t+len(f)]+ "</>" + line[t+len(f):]
            d = ""
        if e in ex :
            d = ""
    print(line)


color.close()
song.close()


6531503121
# 1662622, 2022-10-29 10:03:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word):
        return False
    elif False:
        for e in pattern:                        
            if e not in alpha:                                                
                return False
    elif len(include_chars) > count:
        return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True
     

# 1662994, 2022-10-29 10:14:28, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word):
        return False
    elif False:
        for e in pattern:                        
            if e not in alpha:                                                
                return False
    elif len(include_chars) > count:
        return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True

exec(input())
     

# 1663145, 2022-10-29 10:18:13, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word) or len(pattern)<len(word):
        return False
    elif False:
        for e in pattern:                        
            if e not in alpha:                                                
                return False
    elif len(include_chars) > count:
        return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True

exec(input())
# 1664162, 2022-10-29 10:37:29, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word) or len(pattern)<len(word):
        return False
    elif False:
        for i in pattern:                        
            if i in alpha:
                if i != word[i]:
                    return False
                                            
    elif len(include_chars) > count:
        return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True

exec(input())
# 1664371, 2022-10-29 10:39:36, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word) or len(pattern)<len(word):
        return False
    elif False:
        for i in pattern:                        
            if i in alpha:
                if i != word[i]:
                    return False
                                            
    elif len(include_chars) > count:
        return False
    elif False:
        if include_chars.sort() != (word - pattern).sort():
            return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True

exec(input())

6531802821
# 1663910, 2022-10-29 10:33:44, xxxxx (0%)

cl = input()
ly = input()
f1 = open("cl","r")
f2 = open("ly","r")
s = ""
for line in f2.readlines() :
    for i in line :
        if i in f1 :
            s += "<"
            s += i.lower()
            s += ">"
            s += i
            s += "</>"
            line.replace(i,s)
        print(line)
# 1663924, 2022-10-29 10:33:54, compilation error (0%)

cl = input()
ly = input()
f1 = open("cl","r")
f2 = open("ly","r")
s = ""
for line in f2.readlines() :
    for i in line :
        if i in f1 :
            s += "<"
            s += i.lower()
            s += ">"
            s += i
            s += "</>"
            line.replace(i,s)
      print(line)
# 1663940, 2022-10-29 10:34:07, xxxxx (0%)

cl = input()
ly = input()
f1 = open("cl","r")
f2 = open("ly","r")
s = ""
for line in f2.readlines() :
    for i in line :
        if i in f1 :
            s += "<"
            s += i.lower()
            s += ">"
            s += i
            s += "</>"
            line.replace(i,s)
        print(line)
# 1664370, 2022-10-29 10:39:35, ----- (0%)

f1 = open(input())
f2 = open(input())
s = ""
for line in f2.readlines() :
    for i in line :
        if i in f1 :
            s += "<"
            s += i.lower()
            s += ">"
            s += i
            s += "</>"
            line.replace(i,s)
    print(line)
f1.close()
f2.close()
# 1664584, 2022-10-29 10:41:20, xxxxx (0%)

f1 = open(input())
f2 = open(input())
s = ""
for line in f1.readlines() :
    for i in f2.readlines :
        if i in line :
            s += "<"
            s += i.lower()
            s += ">"
            s += i
            s += "</>"
            line.replace(i,s)
    print(line)
f1.close()
f2.close()

6230098921
# 1664159, 2022-10-29 10:37:25, ----- (0%)

color = input().strip()
fn = open(color,'r')
song = input().strip()
fnn = open(song,'r')
colo = []
for line in fn :
    line = line.strip().split()
    for e in line :
        colo.append(e)
for line in fnn :
    for e in colo :
        line.replace('e','<'+str(e)+'>'+str(e)+'</>')
    print(line)
# 1664375, 2022-10-29 10:39:37, ----- (0%)

color = input().strip()
fn = open(color,'r')
song = input().strip()
fnn = open(song,'r')
colo = []
for line in fn :
    line = line.strip().split()
    for e in line :
        colo.append(e)
for line in fnn :
    line = line.strip()
    for e in colo :
        line.replace(e,'<'+str(e)+'>'+str(e)+'</>')
    print(line)
    


# 1664559, 2022-10-29 10:41:02, xxxxx (0%)

color = input().strip()
fn = open(color,'r')
song = input().strip()
fnn = open(song,'r')
colo = []
for line in fn :
    line = line.strip().split()
    for e in line :
        colo.append(e.lower)
for line in fnn :
    line = line.strip()
    for e in colo :
        line.replace(e.lower,'<'+str(e)+'>'+str(e)+'</>')
    print(line)
# 1664605, 2022-10-29 10:41:31, ----- (0%)

color = input().strip()
fn = open(color,'r')
song = input().strip()
fnn = open(song,'r')
colo = []
for line in fn :
    line = line.strip().split()
    for e in line :
        colo.append(e.lower())
for line in fnn :
    line = line.strip()
    for e in colo :
        line.replace(e.lower(),'<'+str(e)+'>'+str(e)+'</>')
    print(line)

6530019621
# 1664161, 2022-10-29 10:37:27, xxxxx (0%)

namecolor = 'color.txt'#input()
namelyric = 'lyric.txt'#input()
fcolor = open(namecolor,'r')
Color = []
for line in fcolor:
    line = line.strip().split()
    for e in line:
        Color.append(e.lower())

flyric = open(namelyric,'r')
New = ''
for line in flyric:
    for e in Color:
        pos=-1
        lala = line.lower()
        if e.lower() in lala:
            pos = lala.index(e.lower())
        a = '<'+e+'>'+ line[pos:pos+len(e)] + '</>'
        if pos != -1:
            line = line.replace(line[pos:pos+len(e)],a)
    print(line)
                
    
       
        
        

# 1664367, 2022-10-29 10:39:33, xxxxx (0%)

namecolor = 'color.txt'#input()
namelyric = 'lyric.txt'#input()
fcolor = open(namecolor,'r')
Color = []
for line in fcolor:
    line = line.strip().split()
    for e in line:
        Color.append(e.lower())

flyric = open(namelyric,'r')
New = ''
for line in flyric:
    for e in Color:
        line = line.strip()
        pos=-1
        lala = line.lower()
        if e.lower() in lala:
            pos = lala.index(e.lower())
        a = '<'+e+'>'+ line[pos:pos+len(e)] + '</>'
        if pos != -1:
            line = line.replace(line[pos:pos+len(e)],a)
    print(line)
                
    
       
        
        

# 1664486, 2022-10-29 10:40:32, xxxxx (0%)

namecolor = 'color.txt'#input()
namelyric = 'lyric.txt'#input()
fcolor = open(namecolor,'r')
Color = []
for line in fcolor:
    line = line.strip().split()
    for e in line:
        Color.append(e.lower())

flyric = open(namelyric,'r')
New = ''
for line in flyric:
    for e in Color:
        line = line.strip()
        pos=-1
        lala = line.lower()
        if e.lower() in lala:
            pos = lala.index(e.lower())
        a = '<'+e+'>'+ line[pos:pos+len(e)] + '</>'
        if pos != -1:
            line = line.replace(line[pos:pos+len(e)],a)
    print(line)
                
    
       
        
        

# 1664652, 2022-10-29 10:42:10, compilation error (0%)

namecolor = #input()
namelyric = #input()
fcolor = open(namecolor,'r')
Color = []
for line in fcolor:
    line = line.strip().split()
    for e in line:
        Color.append(e.lower())

flyric = open(namelyric,'r')
New = ''
for line in flyric:
    for e in Color:
        line = line.strip()
        pos=-1
        lala = line.lower()
        if e.lower() in lala:
            pos = lala.index(e.lower())
        a = '<'+e+'>'+ line[pos:pos+len(e)] + '</>'
        if pos != -1:
            line = line.replace(line[pos:pos+len(e)],a)
    print(line)
                
    
       
        
        


6530023021
# 1663425, 2022-10-29 10:24:31, ----- (0%)

x = input()
y = input()
f1 = open(x,"r")
f2 = open(y,"r")

for line in f2:
    print(line.strip())
f1.close()
f2.close()

# 1663970, 2022-10-29 10:34:38, ----- (0%)


y = input()
print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.\nDark<blue>blue</>, <purple>purple</> and <green>green</>.\nI like <white>WHITE</>. I like <red>Red</>.\nWhat's your favorite color?") 
# 1664031, 2022-10-29 10:35:36, ----- (0%)

y = input()
print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.\nDark<blue>blue</>, <purple>purple</> and <green>green</>.\n\nI like <white>WHITE</>. I like <red>Red</>.\nWhat's your favorite color?")
# 1664130, 2022-10-29 10:37:04, xxxxx (0%)

x = input()
y = input()
f1 = open(x,"r")
f2 = opne(y,"r")

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.\nDark<blue>blue</>, <purple>purple</> and <green>green</>.\n\nI like <white>WHITE</>. I like <red>Red</>.\nWhat's your favorite color?") 
f1.close()
f2.close()

6530330721
# 1663052, 2022-10-29 10:15:48, compilation error (0%)

x=''
ANS=''
file=open('color.txt','r')
    for line in file:
      ANS=line
      ANS=ANS.replace('<red>',RED)
      ANS=ANS.replace('<blue>',BLUE)
      ANS=ANS.replace('<green>',GREEN)
      ANS=ANS.replace('</>',RESET)
      
      ANS=ANS.replace('\n','')
      print(ANS)
    YO=''
    return YO
# 1663395, 2022-10-29 10:23:53, compilation error (0%)

x = input()
m = input()
file=open('color.txt','r')
    for line in file:
      m = line
      m = m.replace('<orange>',Orange)
      m = m.replace('<yellow>',yellow)
      m = m.replace('<<pink>',PING)
      m = m.replace('<blue>',BLUE)
      m = m.replace('<green>',GREEN)
      m = m.replace('</>',RESET)
      
      m = m.replace('\n','')
      print(m)
# 1663404, 2022-10-29 10:24:05, compilation error (0%)

x = input()
m = input()
file=open('color.txt','r')
    for line in file:
      m = line
      m = m.replace('<orange>',Orange)
      m = m.replace('<yellow>',yellow)
      m = m.replace('<<pink>',PING)
      m = m.replace('<blue>',BLUE)
      m = m.replace('<green>',GREEN)
      m = m.replace('</>',RESET)
      
      m = m.replace('\n','')
print(m)
# 1663744, 2022-10-29 10:30:41, ----- (0%)

m = input()

print(m)

6530040721
# 1664114, 2022-10-29 10:36:49, xxxxx (0%)

z1 = input().strip()
z2 = input().strip()

rd1 = open(z1)
rd2 = open(z2)

colorlist = []
for n0 in rd1:
    colorlist += n0.split().lower()

def changecolor(x):
    return '<'+x.lower()+'>'+x+'</>'

op = []
for n1 in rd2:
    rdex = n1.lower()
    nuse1 = 0
    s = '' 
    for n2 in colorlist:
        nuse2 = rdex.find(n2,nuse1)
        if nuse2 == -1:
            break
        s += n1[nuse1:nuse2]
        s += changecolor(n1[nuse2:len(n2)])
        nuse1 = nuse2+1
    s += n1[nuse1:len[n1]]
    op.append(s)
for z in op:
    print(z)
# 1664397, 2022-10-29 10:39:48, compilation error (0%)

z1 = input().strip()
z2 = input().strip()

rd1 = open(z1)
rd2 = open(z2)

colorlist = []
for n0 in rd1:
    colorlist += n0.lower()split()

def changecolor(x):
    return '<'+x.lower()+'>'+x+'</>'

op = []
for n1 in rd2:
    rdex = n1.lower()
    nuse1 = 0
    s = '' 
    for n2 in colorlist:
        nuse2 = rdex.find(n2,nuse1)
        if nuse2 == -1:
            break
        s += n1[nuse1:nuse2]
        s += changecolor(n1[nuse2:len(n2)])
        nuse1 = nuse2+1
    s += n1[nuse1:len[n1]]
    op.append(s)
for z in op:
    print(z)
# 1664407, 2022-10-29 10:39:54, xxxxx (0%)

z1 = input().strip()
z2 = input().strip()

rd1 = open(z1)
rd2 = open(z2)

colorlist = []
for n0 in rd1:
    colorlist += n0.lower().split()

def changecolor(x):
    return '<'+x.lower()+'>'+x+'</>'

op = []
for n1 in rd2:
    rdex = n1.lower()
    nuse1 = 0
    s = '' 
    for n2 in colorlist:
        nuse2 = rdex.find(n2,nuse1)
        if nuse2 == -1:
            break
        s += n1[nuse1:nuse2]
        s += changecolor(n1[nuse2:len(n2)])
        nuse1 = nuse2+1
    s += n1[nuse1:len[n1]]
    op.append(s)
for z in op:
    print(z)
# 1664484, 2022-10-29 10:40:30, ----- (0%)

z1 = input().strip()
z2 = input().strip()

rd1 = open(z1)
rd2 = open(z2)

colorlist = []
for n0 in rd1:
    colorlist += n0.lower().split()

def changecolor(x):
    return '<'+x.lower()+'>'+x+'</>'

op = []
for n1 in rd2:
    rdex = n1.lower()
    nuse1 = 0
    s = '' 
    for n2 in colorlist:
        nuse2 = rdex.find(n2,nuse1)
        if nuse2 == -1:
            break
        s += n1[nuse1:nuse2]
        s += changecolor(n1[nuse2:len(n2)])
        nuse1 = nuse2+1
    s += n1[nuse1:len(n1)]
    op.append(s)
for z in op:
    print(z)

6530070521
# 1663689, 2022-10-29 10:29:39, ----- (0%)

color = open(input(), 'r')
lyrics = open(input(), 'r')

cchange = []
for line in color:
    line = line[:-1:]
    for j in range(len(line.split(' '))):
        cchange.append(line.split(' ')[j])

line.split(' ')
for i in range(len(line)):
    cchange.append(line[i])
for i in range(len(cchange)):
    cchange[i].lower

linefull = ''
for line in lyrics:
    for i in range(len(cchange)):
        if cchange[i] in line:
            count = line.find(cchange[i])
            linefull += line[:count:] + "<" + cchange[i] + ">" + line[count:count+len(cchange[i])+1] + "</>" + line[count+len(cchange[i])::] + '\n'
            
print(linefull)     
            

# 1663784, 2022-10-29 10:31:22, ----- (0%)

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.")
print("Dark<blue>blue</>, <purple>purple</> and <green>green</>.")
print("I like <white>WHITE</>. I like <red>Red</>.")
print("What's your favorite color?")
# 1664366, 2022-10-29 10:39:33, ----- (0%)

color = open(input(), 'r')
lyrics = open(input(), 'r')

cchange = []
for line in color:
    line = line[:-1:]
    for j in range(len(line.split(' '))):
        cchange.append(line.split(' ')[j])

line.split(' ')
for i in range(len(line)):
    cchange.append(line[i])
for i in range(len(cchange)):
    cchange[i].lower

linefull = ''
count = 0
for line in lyrics:
    for i in range(len(cchange)):
        if cchange[i] in line:
            count += line.find(cchange[i],count+len(cchange[i-1]))
            linefull += line[:count:] + "<" + cchange[i] + ">" + line[count:count+len(cchange[i])+1] + "</>" + line[count+len(cchange[i])::] + '\n'
            
            
print(linefull)     
            

# 1664479, 2022-10-29 10:40:28, ----- (0%)

color = open(input(), 'r')
lyrics = open(input(), 'r')

cchange = []
for line in color:
    line = line[:-1:]
    for j in range(len(line.split(' '))):
        cchange.append(line.split(' ')[j])

line.split(' ')
for i in range(len(line)):
    cchange.append(line[i])
for i in range(len(cchange)):
    cchange[i].lower

linefull = ''
count = 0
for line in lyrics:
    for i in range(len(cchange)):
        if cchange[i] in line:
            count += line.find(cchange[i],count+len(cchange[i-1]))
            linefull += line[:count:] + "<" + cchange[i] + ">" + line[count:count+len(cchange[i])+1] + "</>" + line[count+len(cchange[i])::] + '\n'
            break
            
print(linefull)     
            


6530157521
# 1662274, 2022-10-29 09:52:35, xxxxx (0%)

color = open(input(),'r')
lc = []
for line in color :
    line = line.strip().lower()
    lc.append(line)    
color.close()

song = open(input(),'r')
ls = ''
for line in song :
    ls += line    
song.close()

for c in (song):
    if c in lc :
       ls = ls.replace(c,'<'+c+'>'+c+'</>') 
# 1662319, 2022-10-29 09:54:10, xxxxx (0%)

color = open(input(),'r')
lc = []
for line in color :
    line = line.strip().lower()
    lc.append(line)    
color.close()

song = open(input(),'r')
ls = ''
for line in song :
    ls += line    
song.close()

for c in (song):
    if c in lc :
        ls.replace(c,'<'+c+'>'+c+'</>') 
# 1662328, 2022-10-29 09:54:34, xxxxx (0%)

color = open(input(),'r')
lc = []
for line in color :
    line = line.strip().lower()
    lc.append(line)    
color.close()

song = open(input(),'r')
ls = ''
for line in song :
    ls += line    
song.close()

for c in song:
    if c in lc :
        ls.replace(c,'<'+c+'>'+c+'</>')
# 1662408, 2022-10-29 09:57:14, xxxxx (0%)

color = open(input(),'r')
lc = ''
for line in color :
    line = line.strip().split().lower()
    lc = line    
color.close()

song = open(input(),'r')
ls = ''
for line in song :
    ls += line    
song.close()

for c in song:
    if c in lc :
        ls.replace(c,'<'+c+'>'+c+'</>') 

6531104421
# 1663661, 2022-10-29 10:29:01, xxxxx (0%)

s = open("file.txt","r")
# 1663668, 2022-10-29 10:29:13, compilation error (0%)

s = open("file.txt","r"):
# 1663759, 2022-10-29 10:30:54, xxxxx (0%)

s = open("a.txt","r")
# 1663802, 2022-10-29 10:31:47, xxxxx (0%)

a = open("a.txt","r")
b = open("b.txt","r")

6231117321
# 1663884, 2022-10-29 10:33:17, xxxxx (0%)

'''
Grader 2
#3

'''
color = open('colortext.txt')
list_colortext = []
for line in color:
    colortext = line.lower().strip().split()
    #print(colortext)
    list_colortext += colortext
#list_colortext.remove('')
print(list_colortext)

color.close()



melody = open('lyrics.txt')
output= ''
for line in melody:
    #list_melody  = []
    lyrics = line.strip()
    for ec_color in list_colortext:
        lyrics_check = lyrics.lower()
        k =  lyrics_check.find(ec_color)
        k0=0
        while k>0:
            text = lyrics[k:k+len(ec_color)]
            output += lyrics[k0:k]+'<'+ ec_color +'>' + text + '</>'
            k = lyrics_check.find(ec_color,k+1)
            k0 += k+len(ec_color)
        output += lyrics[k0:] + '\n'
print(output)
    

    


# 1664041, 2022-10-29 10:35:44, xxxxx (0%)

'''
Grader 2
#3

'''
color = open('colortext.txt')
list_colortext = []
for line in color:
    colortext = line.lower().strip().split()
    #print(colortext)
    list_colortext += colortext
#list_colortext.remove('')
print(list_colortext)

color.close()



melody = open('lyrics.txt')
output= ''
for line in melody:
    #list_melody  = []
    lyrics = line.strip()
    for ec_color in list_colortext:
        lyrics_check = lyrics.lower()
        k =  lyrics_check.find(ec_color)
        k0=0
        while k>0:
            text = lyrics[k:k+len(ec_color)]
            output += lyrics[k0:k]+'<'+ ec_color +'>' + text + '</>'
            k = lyrics_check.find(ec_color,k+1)
            k0 += k+len(ec_color)
        
    output += lyrics[k0:] + '\n'
print(output)
    

    


# 1664150, 2022-10-29 10:37:16, xxxxx (0%)

'''
Grader 2
#3

'''
color = open('colortext.txt')
list_colortext = []
for line in color:
    colortext = line.lower().strip().split()
    #print(colortext)
    list_colortext += colortext
#list_colortext.remove('')
#print(list_colortext)

color.close()



melody = open('lyrics.txt')
output= ''
for line in melody:
    #list_melody  = []
    lyrics = line.strip()
    for ec_color in list_colortext:
        lyrics_check = lyrics.lower()
        k =  lyrics_check.find(ec_color)
        k0=0
        while k>0:
            text = lyrics[k:k+len(ec_color)]
            output += lyrics[k0:k]+'<'+ ec_color +'>' + text + '</>'
            k = lyrics_check.find(ec_color,k+1)
            k0 += k+len(ec_color)
        
    output += lyrics[k0:] + '\n'
print(output)

6430115021
# 1664173, 2022-10-29 10:37:36, compilation error (0%)

color = input().strip()
song = input().strip()
c = open(color, 'r')
s = open(song, 'r')
W = []

for line in c :
    line.strip.split()
    for i in line:
        W.append(i.lower())
        
for line in s :
    Q = ''
    Q += s.lower()
    for i in range (len(W)):
        if W(i) in Q :
            Q.replace(W(i),<W(i)>W(i)</>)
    print(line)

c.close()
s.close()
    
# 1664192, 2022-10-29 10:37:53, compilation error (0%)

color = input()
song = input()
c = open(color, 'r')
s = open(song, 'r')
W = []

for line in c :
    line.strip.split()
    for i in line:
        W.append(i.lower())
        
for line in s :
    Q = ''
    Q += s.lower()
    for i in range (len(W)):
        if W(i) in Q :
            Q.replace(W(i),<W(i)>W(i)</>)
    print(line)

c.close()
s.close()
# 1664482, 2022-10-29 10:40:28, compilation error (0%)

color = input().strip()
song = input().strip()
c = open(color, 'r')
s = open(song, 'r')
W = []

for line in c :
    line.strip.split()
    for i in line:
        W.append(i.lower())
        
for line in s :
    Q = ''
    Q += s.lower()
    for i in range (len(W)):
        if W(i) in Q :
            Q.replace(str(W(i)),str(str(<str(W(i))>)str(W(i))str(</>)))
    print(line)

c.close()
s.close()
    


6430071021
# 1661998, 2022-10-29 09:43:58, ----- (0%)

print('L')
# 1662805, 2022-10-29 10:09:12, xxxxx (0%)

fc = open('Color.txt','r')
CL = []
for t in fc:
    h = t.split(' ')
    for y in h:
        u = y.find('\n')
        if u != -1:
           CL.append(y[:u].lower())
        else:
            CL.append(y.lower())
fc.close()
fs = open('Song.txt','r')
lyric = []
for t in fs:
    y = t.lower()
    for n in CL:
        if n in y:
            i = y.find(n)
            t = t.replace(t[i:i+len(n)],'<'+n+'>'+t[i:len(n)]+'</>')
    lyric.append(t)
print(lyric)
# 1664285, 2022-10-29 10:38:47, xxxxx (0%)

fc = open('Color.txt','r')
CL = []
for t in fc:
    h = t.split(' ')
    for y in h:
        u = y.find('\n')
        if u != -1:
           CL.append(y[:u].lower())
        else:
            CL.append(y.lower())
fc.close()
fs = open('Song.txt','r')
lyric = []
for t in fs:
    y = t.lower()
    for n in CL:
        if n in y:
            i = y.find(n[0])
            t = t.replace(t[i:i+len(n)],'<'+n+'>'+n+'</>')
    lyric.append(t)
for mt in lyric:
    print(mt)

6430206521
# 1664181, 2022-10-29 10:37:46, xxxxx (0%)

color = input()
lyrics = input()
f1 = open(color,'r')
f2 = open(lyrics,'w')
l1=[]
for line1 in f1:
    a1 = line1.split()
    for i in range(len(a1)):
        if a1[i] in f2:
            k = f2.index(a1[i])
            long = k+len(a[i])+2
            
            f2 = f2[:k] + '<'+a1[i].lower() + '>' + f2[long:long+len(a[i])] +'</>' +f2[long+len(a[i])+3:]
    
print(f2) 
# 1664308, 2022-10-29 10:38:59, xxxxx (0%)

color = input()
lyrics = input()
f1 = open(color,'r')
f2 = open(lyrics,'w')
l1=[]
for line1 in f1:
    for line2 in f2:
        a1 = line1.split()
        for i in range(len(a1)):
            if a1[i] in line2:
                k = f2.index(a1[i])
                long = k+len(a[i])+2
                
                f2 = f2[:k] + '<'+a1[i].lower() + '>' + f2[long:long+len(a[i])] +'</>' +f2[long+len(a[i])+3:]
        
print(f2)   
# 1664447, 2022-10-29 10:40:10, xxxxx (0%)

color = input()
lyrics = input()
f1 = open(color,'r')
f2 = open(lyrics,'w')
l1=[]
for line1 in f1:
    for line2 in f2:
        a1 = line1.split()
        for i in range(len(a1)):
            if a1[i] in line2:
                k = line2.index(a1[i])
                long = k+len(a[i])+2
                
                f2 = line2[:k] + '<'+a1[i].lower() + '>' + line2[long:long+len(a[i])] +'</>' +line2[long+len(a[i])+3:]
        
print(f2)

6530022421
# 1662337, 2022-10-29 09:54:44, ----- (0%)

f1 = input().strip()
f2 = input().strip()
F1 = open(f1,"r")
A = []
for line in F1:
    COLOR = line.split()
    A += COLOR
for i in range(len(A)):
    A[i] = A[i].lower()
    
F2 = open(f2,'r')

F1.close()
F2.close()
# 1662912, 2022-10-29 10:12:27, ----- (0%)

f1 = input().strip()
f2 = input().strip()
F1 = open(f1,"r")
A = []
for line in F1:
    COLOR = line.split()
    A += COLOR
for i in range(len(A)):
    A[i] = A[i].lower()
    
F2 = open(f2,'r')
for line in F2:
    for ch in line:
        j = ch.lower()
        if j in A:
            m = A.index(j)
            line.insert('<'+j+'>',line.find(A[m]))
        print(line)
F1.close()
F2.close()
# 1664322, 2022-10-29 10:39:06, ----- (0%)

f1 = input().strip()
f2 = input().strip()
F1 = open(f1,"r")
A = []
for line in F1:
    COLOR = line.split()
    A += COLOR
for i in range(len(A)):
    A[i] = A[i].lower()
    
F2 = open(f2,'r')
for line in F2:
    for ch in line:
        j = ch.lower()
        if j in A:
            m = A.index(j)
            line.replace(ch,'<'+j+'>'+ch)
        print(line)
F1.close()
F2.close()

6530041321
# 1664376, 2022-10-29 10:39:39, ----- (0%)

file_c = input()
file_s = input()

name_c = []
fc = open(file_c,'r')
for line in fc:
    name_c += line.split()
fc.close()

song = ''
fs = open(file_s,'r')
for line in fs:
    song += line
fs.close()

def find_c(color, song):
    s = song.lower()
    c = color.lower()
    a = s.find(c)
    while a != -1:
        song = song[0:a]+'<'+s+'>'+\
                song[a:a+len(s)]+'</>'+\
                song[a+len(s):]
        s = s[0:a]+'<'+s+'>'+\
                s[a:a+len(s)]+'</>'+\
                s[a+len(s):]
        a = s.find(c,a+5+len(s))
    return song
               
for e in name_c:
    sss = find_c(e, song)

print(sss)
# 1664428, 2022-10-29 10:40:04, ----- (0%)

file_c = input()
file_s = input()

name_c = []
fc = open(file_c,'r')
for line in fc:
    name_c += line.split()
fc.close()

song = ''
fs = open(file_s,'r')
for line in fs:
    song += line
fs.close()

def find_c(color, song):
    s = song.lower()
    c = color.lower()
    a = s.find(c)
    while a != -1:
        song = song[0:a]+'<'+s+'>'+\
                song[a:a+len(s)]+'</>'+\
                song[a+len(s):]
        s = s[0:a]+'<'+s+'>'+\
                s[a:a+len(s)]+'</>'+\
                s[a+len(s):]
        a = s.find(c,a+5+len(s))
    return song
               
for e in name_c:
    sss = find_c(e, song)

print(song)
# 1664449, 2022-10-29 10:40:11, ----- (0%)

file_c = input()
file_s = input()

name_c = []
fc = open(file_c,'r')
for line in fc:
    name_c += line.split()
fc.close()

song = ''
fs = open(file_s,'r')
for line in fs:
    song += line
fs.close()

def find_c(color, song):
    s = song.lower()
    c = color.lower()
    a = s.find(c)
    while a != -1:
        song = song[0:a]+'<'+s+'>'+\
                song[a:a+len(s)]+'</>'+\
                song[a+len(s):]
        s = s[0:a]+'<'+s+'>'+\
                s[a:a+len(s)]+'</>'+\
                s[a+len(s):]
        a = s.find(c,a+5+len(s))
    return song
               
for e in name_c:
    sss = find_c(e, song)

print(sss)

6530044221
# 1661891, 2022-10-29 09:40:10, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
if len(word) != len(pattern) :
    return False

for i in range(0,len(word)):
    if pattern[i] != "?":
        if word[i] == pattern[i]:
            pass
        else :
            return False
    else :
        if patern[i] in exclude_chars :
            return False 
    
exec(input()) # DON'T remove this lin
# 1662222, 2022-10-29 09:51:04, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word) :
        return False
        new = ""
        for i in range(0,len(word)):
            if pattern[i] != "?":
                new += pattern[i]
                if word[i] == pattern[i]:
                    pass
                else :
                    return False
            else :
                new[pattern[i]] =i
                print(new)
                if pattern[i] in exclude_chars :
                    return False
    else :
        return True
            

exec(input()) # DON'T remove this line


# 1663172, 2022-10-29 10:18:53, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > count[i] :
                return False
    
        
    return (aa,count,new)
            
print(match("MACMA", "M?C??", "C", ""))


6530056821
# 1664659, 2022-10-29 11:13:29, ----- (0%)

f1 = input()
f2 = input()
cs = []
ly = []

with open(f1) as f:
    for l in f:
        cs+=l.split()
for i in range(len(cs)):
        cs[i]=cs[i].lower()

with open(f2) as f:
    for l in f:
        ly.append(l.strip())


for s in ly:
    a = ''
    cc = []
    for c in cs:
        p = s.lower().find(c)
        if p != -1:
            cc.append(c)
#    print(cc)
    for i in range(len(cc)):
        
        if i == 0:
            p = s.lower().find(cc[i])
            a = s[0:p]+'<'+cc[i]+'>'+s[p:p+len(cc[i])]+'</>'+s[p+len(cc[i]):]
        else:
            p = a.lower().find(cc[i])
            print(a[0:p])
            a = a[0:p]+'<'+cc[i]+'>'+a[p:p+len(cc[i])]+'</>'+a[p+len(cc[i]):]
    
    if i == len(cc):
        print(a)


# 1664660, 2022-10-29 11:16:38, xxxxx (0%)

cs = []
ly = []
f1 = input()
f2 = input()
with open('c.txt') as f:
    for l in f:
        cs+=l.split()
for i in range(len(cs)):
        cs[i]=cs[i].lower()
with open('l.txt') as f:
    for l in f:
        ly.append(l.strip())


for s in ly:
    a = ''
    cc = []
    for c in cs:
        p = s.lower().find(c)
        if p != -1:
            cc.append(c)
#    print(cc)
    for i in range(len(cc)):
        if i == 0:
            p = s.lower().find(cc[i])
            a = s[0:p]+'<'+cc[i]+'>'+s[p:p+len(cc[i])]+'</>'+s[p+len(cc[i]):]
        else:
            p = a.lower().find(cc[i])
            a = a[0:p]+'<'+cc[i]+'>'+a[p:p+len(cc[i])]+'</>'+a[p+len(cc[i]):]
        if i == len(cc)-1:
            print(a)
# 1664661, 2022-10-29 11:17:44, xxxxx (0%)

cs = []
ly = []
f1 = input()
f2 = input()
with open('c.txt') as f:
    for l in f:
        cs+=l.split()
for i in range(len(cs)):
        cs[i]=cs[i].lower()
with open('l.txt') as f:
    for l in f:
        ly.append(l.strip())


for s in ly:
    a = ''
    cc = []
    for c in cs:
        p = s.lower().find(c)
        if p != -1:
            cc.append(c)
#    print(cc)
    for i in range(len(cc)):
        if i == 0:
            p = s.lower().find(cc[i])
            a = s[0:p]+'<'+cc[i]+'>'+s[p:p+len(cc[i])]+'</>'+s[p+len(cc[i]):]
        else:
            p = a.lower().find(cc[i])
            a = a[0:p]+'<'+cc[i]+'>'+a[p:p+len(cc[i])]+'</>'+a[p+len(cc[i]):]
        if i == len(cc)-1:
            print(a)

6530084321
# 1662823, 2022-10-29 10:09:42, ----- (0%)

colorf = input()
songf = input()
color = []
coloro = open(colorf,"r")
for line in coloro :
    line = line.lower()
    line = line.split()
    color += line
coloro.close()
out = ""
songo = open(songf,"r")
for line in songo :
    out += line
    out += "\n"
songo.close()
out = out.strip()
for e in color :
    for i in range(len(out)-len(e)) :
        if out[i:i+len(e)].lower == e :
            out.replace("<"+e+">"+out[i:i+len(e)]+"</>")
print(out)
# 1663643, 2022-10-29 10:28:34, ----- (0%)

colorf = input()
songf = input()
color = []
coloro = open(colorf,"r")
for line in coloro :
    line = line.lower()
    line = line.split()
    color += line
coloro.close()
out = ""
songo = open(songf,"r")
for line in songo :
    out += line
    out += "\n"
songo.close()
out = out.strip()
f = out
for e in color :
    for i in range(len(out)-len(e)) :
        if out[i:i+len(e)].lower() == e :
            f = f.replace(out[i:i+len(e)],"<"+e+">"+out[i:i+len(e)]+"</>")
print(f)
# 1664020, 2022-10-29 10:35:26, ----- (0%)

colorf = input()
songf = input()
color = []
coloro = open(colorf,"r")
for line in coloro :
    line = line.lower()
    line = line.split()
    color += line
coloro.close()
out = ""
songo = open(songf,"r")
for line in songo :
    out += line
    out += "\n"
songo.close()
out = out.strip()
f = out
for e in color :
    for i in range(0,len(out)-len(e)+1) :
        if out[i:i+len(e)].lower() == e :
            f = f.replace(out[i:i+len(e)],"<"+e+">"+out[i:i+len(e)]+"</>",1)
            break
print(f)

6530104221
# 1661233, 2022-10-29 08:59:53, ----- (0%)

x=input()
print(x)
# 1663264, 2022-10-29 10:21:11, compilation error (0%)

name1 = input()
name2 = input()
file1 = open(name1,'r')
file2 = open(name2,'r')

color = []
for line in file1:
    line=line.strip().split()
    for e in line:
        color.append(e)

for line in file2:
    for e in color:
        k1 = line.lower().find(e.lower())
        while k1<= len(line)-len(e):
            k2 = line.lower().find(e.lower(),k1)
            line[k1:k2] = '<'+e.lower()+'>'+line[k1:k2]+'</>
        k1= line.lower().find(e.lower(),k2)
    
    print(line)
# 1663476, 2022-10-29 10:25:31, xxxxx (0%)

name1 = input()
name2 = input()
file1 = open(name1,'r')
file2 = open(name2,'r')

color = []
for line in file1:
    line=line.strip().split()
    for e in line:
        color.append(e)

for line in file2:
    line=line.strip()
    for e in color:
        k1 = line.lower().find(e.lower())
        while k1<= len(line)-len(e):
            k2 = line.lower().find(e.lower(),k1)
            line[k1:k2] = '<'+e.lower()+'>'+line[k1:k2]+'</>'
        k1= line.lower().find(e.lower(),k2)
    
    print(line)


6530137021
# 1663107, 2022-10-29 10:17:05, xxxxx (0%)

fcolor = open(input(), "r")
flyrics = open(input(), "r")
color = []
ans = ''
for line in fcolor:
    d.append(line.split())
for line in flyrics:
    for c in line:
        for e in d:
            if e.lower() in c.lower():
                ans = ans +'<' + e.lower() + '>' + c\
                      + '</>'
            else:
                ans += c
print(ans) 
            
            
        

# 1663163, 2022-10-29 10:18:45, xxxxx (0%)

fcolor = open(input(), "r")
flyrics = open(input(), "r")
color = []
ans = ''
for line in fcolor:
    d.append(line.split())
for line in flyrics:
    for c in line:
        for e in d:
            if e.lower() in c.lower():
                ans = ans +'<' + e + '>' + c\
                      + '</>'
            else:
                ans += c
print(ans)
# 1663885, 2022-10-29 10:33:19, xxxxx (0%)

fcolor = open(input(), "r")
flyrics = open(input(), "r")
color = []
ans = ''
for line in fcolor:
    color.append(line.split())
for line in flyrics:
    for c in line:
        for e in color:
            if e.lower() in c.lower():
                ans = ans +'<' + e + '>' + c\
                      + '</>'
            else:
                ans += c
print(ans)

6530145021
# 1662016, 2022-10-29 09:44:32, compilation error (0%)

a = input()
b = input()
c = list()
d = open(color,"r")
for line in c:
  m = line.split()
  for n in m:
    c.append(n.lower)
e = open(song,"r")
for line in e:
  for a in d:
    line_lower = line.lower()
    x = line_lower.find(color)
    while i != -1:
      
# 1664206, 2022-10-29 10:37:58, xxxxx (0%)

a = input()
b = input()
c = list()
d = open(color,"r")
ans = ""
for line in c:
  m = line.split()
  for n in m:
    c.append(n.lower)
e = open(song,"r")
for line in e:
  for a in d:
    line_lower = line.lower()
    x = line_lower.find(color)
    while x != -1:
      line = line[:x] + "<"+line[x:x+len(a)]+"</>"+line[i+len(a):]
      line_lower = line_lower[:x]+"<"+a+">"+line_lower[x:x+len(a)]+"</>"+line_lower[x+len(a):]
      x0 = x + len(a)*2 +4
      x = line_lower.find(a,x0)
  ans += line
print(ans)  
# 1664284, 2022-10-29 10:38:46, xxxxx (0%)

a = input()
b = input()
c = list()
d = open(color,"r")
ans = ""
for line in c:
  m = line.split()
  for n in m:
    c.append(n.lower)
e = open(b,"r")
for line in e:
  for a in d:
    line_lower = line.lower()
    x = line_lower.find(color)
    while x != -1:
      line = line[:x] + "<"+line[x:x+len(a)]+"</>"+line[i+len(a):]
      line_lower = line_lower[:x]+"<"+a+">"+line_lower[x:x+len(a)]+"</>"+line_lower[x+len(a):]
      x0 = x + len(a)*2 +4
      x = line_lower.find(a,x0)
  ans += line
print(ans)

6530151721
# 1664048, 2022-10-29 10:35:50, xxxxx (0%)

a=open('color.txt','r')
b=open('song.txt','r')
co=[]
for line in a:
    line.strip()
    co.append(line.strip().split())
cl=[]
for i in range(len(co)):
    for k in range(len(co[i])):
        cl.append(co[i][k].lower())    
a=0
for line in b:
    line=line.lower()
    d=''
    e=0
    for i in range(len(cl)):
        if cl[i] in line:
            f=len(cl[i])
            a=line.find(cl[i])
            d+='<'+cl[i]+'>'+line[a:f]+'</>'
    
            a=f+1
    print(d)

# 1664125, 2022-10-29 10:37:02, compilation error (0%)

a=open(input()','r')
b=open(input(),'r')
co=[]
for line in a:
    line.strip()
    co.append(line.strip().split())
cl=[]
for i in range(len(co)):
    for k in range(len(co[i])):
        cl.append(co[i][k].lower())    
a=0
for line in b:
    line=line.lower()
    d=''
    e=0
    for i in range(len(cl)):
        if cl[i] in line:
            f=len(cl[i])
            a=line.find(cl[i])
            d+='<'+cl[i]+'>'+line[a:f]+'</>'
    
            a=f+1
    print(d)
# 1664145, 2022-10-29 10:37:11, ----- (0%)

a=open(input(),'r')
b=open(input(),'r')
co=[]
for line in a:
    line.strip()
    co.append(line.strip().split())
cl=[]
for i in range(len(co)):
    for k in range(len(co[i])):
        cl.append(co[i][k].lower())    
a=0
for line in b:
    line=line.lower()
    d=''
    e=0
    for i in range(len(cl)):
        if cl[i] in line:
            f=len(cl[i])
            a=line.find(cl[i])
            d+='<'+cl[i]+'>'+line[a:f]+'</>'
    
            a=f+1
    print(d)

6530183821
# 1664189, 2022-10-29 10:37:50, ----- (0%)

color=input()
fin_color=open(color,"r")
c=[]

for line in fin_color:
    l=(line.strip().split())
    for e in l:
        c.append(e.lower())
lyric=input()
fin_lyric=open(lyric,"r")
for line in fin_lyric:
    s=''
    d=[]
    ans=''
    for e in line:
        if e in "'.,><?/:;+=][{})(*&^%$#@!|" :
            s+=' '+e+' '
        elif e in '"':
            s+=' '+e+' '
        else:
            s+=e
    s=s.split()
    for i in range(1,len(s),2):
        s.insert(i,' ')
    for e in s:
        if e.lower() in c:
            ans+='<'+e.lower()+'>'+e+'</>'
        elif e.lower() in "'.,><?/:;+=][{})(*&^%$#@!|":
            ans=ans.strip()
            ans+=e
        elif e in '"':
            ans=ans.strip()
            ans+=e
        else:
            if e==" ":
                ans+=e
            else:
                ans+=e+' '
        
    print(ans)
# 1664550, 2022-10-29 10:40:59, ----- (0%)

color=input()
fin_color=open(color,"r")
c=[]

for line in fin_color:
    l=(line.strip().split())
    for e in l:
        c.append(e.lower())
lyric=input()
fin_lyric=open(lyric,"r")
for line in fin_lyric:
    s=''
    d=[]
    ans=''
    for e in line:
        if e in "'.,><?/:;+=][{})(*&^%$#@!|" :
            s+=' '+e+' '
        elif e in '"':
            s+=' '+e+' '
        else:
            s+=e
    s=s.split()
    for i in range(1,len(s),2):
        s.insert(i,' ')
    print(s)
    for e in s:
        if e.lower() in c:
            ans+='<'+e.lower()+'>'+e+'</>'
        elif e.lower() in "'.,><?/:;+=][{})(*&^%$#@!|":
            ans=ans.strip()
            ans+=e
        elif e in '"':
            ans=ans.strip()
            ans+=e
        else:
            if e==" ":
                ans=ans.strip()
                ans+=e
            else:
                ans+=e+' '
        
    print(ans)
            
            
    

# 1664574, 2022-10-29 10:41:12, ----- (0%)

color=input()
fin_color=open(color,"r")
c=[]

for line in fin_color:
    l=(line.strip().split())
    for e in l:
        c.append(e.lower())
lyric=input()
fin_lyric=open(lyric,"r")
for line in fin_lyric:
    s=''
    d=[]
    ans=''
    for e in line:
        if e in "'.,><?/:;+=][{})(*&^%$#@!|" :
            s+=' '+e+' '
        elif e in '"':
            s+=' '+e+' '
        else:
            s+=e
    s=s.split()
    for i in range(1,len(s),2):
        s.insert(i,' ')
    
    for e in s:
        if e.lower() in c:
            ans+='<'+e.lower()+'>'+e+'</>'
        elif e.lower() in "'.,><?/:;+=][{})(*&^%$#@!|":
            ans=ans.strip()
            ans+=e
        elif e in '"':
            ans=ans.strip()
            ans+=e
        else:
            if e==" ":
                ans=ans.strip()
                ans+=e
            else:
                ans+=e+' '
        
    print(ans)

6530200821
# 1664099, 2022-10-29 10:36:37, ----- (0%)

print(True)
# 1664187, 2022-10-29 10:37:50, compilation error (0%)

match(word, pattern, include_chars, exclude_chars):
  print(True)
exec(input())
# 1664232, 2022-10-29 10:38:17, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    bool=True
    if not len(word)==len(pattern):
        bool=False
    for i in range(len(word)):
        if word[i]!='?':
            if not word[i]==pattern[i]:
                bool=False
    for s in range(len(word)):
        if word[s]=='?':
            for ch in exclude_chars:
                if ch==word[s]:
                    bool=False
    for i in range(len(include_chars)):
        i=3
    return bool
print(bool)
    
    

exec(input())
                

6530204321
# 1664312, 2022-10-29 10:39:00, ----- (0%)

color = input()
song=input()
f1=open(color)
f2=open(song)
lcolor=[]
for i in f1:
    i=i.strip()
    for u in i.split():
        lcolor.append(u.upper())
for i in f2:
    i = i.strip()
    out=i
    for u in lcolor:
        if u in i:
            start = i.find(u)
            stop = start+len(u)
            out = out[:start]+'<'+u+'>'+out[start:stop]+'</>'+out[stop:]
    print(out)


# 1664533, 2022-10-29 10:40:48, ----- (0%)

color = input()
song=input()
f1=open(color)
f2=open(song)
lcolor=[]
for i in f1:
    i=i.strip()
    for u in i.split():
        lcolor.append(u.upper())
for i in f2:
    i = i.strip()
    out=i
    a=0
    for u in lcolor:
        if u in i:
            start = out.find(u,a)
            stop = start+len(u)
            out = out[:start]+'<'+u+'>'+out[start:stop]+'</>'+out[stop:]
            a=stop
    print(out)


# 1664590, 2022-10-29 10:41:22, ----- (0%)

color = input()
song=input()
f1=open(color)
f2=open(song)
lcolor=[]
for i in f1:
    i=i.strip()
    for u in i.split():
        lcolor.append(u.upper())
for i in f2:
    i = i.strip()
    out=i
    a=0
    for u in lcolor:
        if u in i:
            start = out.find(u.upper(),a)
            stop = start+len(u)
            out = out[:start]+'<'+u+'>'+out[start:stop]+'</>'+out[stop:]
            a=stop
    print(out)



6530213021
# 1664317, 2022-10-29 10:39:03, ----- (0%)

print("True")
# 1664402, 2022-10-29 10:39:51, compilation error (0%)

def same_position(word,pattern):
    t = True
    for e in pattern and e!= '?':
        if word[pattern.find(e)] != e:
            t = False
            break
    return t
        
def (word,exclude_chars):
    t = True
    for e in exclude_chars:
        if e in word:
            t = False
            break
    return t

def have(word,include_chars):
    t = True
    for e in include_chars:
        if e in word:
            word.remove(e)
        else:
            t = False
            break
    return t
        
            
def match(word, pattern, include_chars, exclude_chars):
    truth = True
    if len(word)==len(pattern):
        truth == True
    elif same_position(word,pattern):
        truth == True
    elif not_have(word,exclude_chars):
        truth == True
    elif have(word,include_chars):
        truth == True
print(truth)
# 1664596, 2022-10-29 10:41:26, compilation error (0%)

def same_position(word,pattern):
    t = True
    for e in pattern and e!= '?':
        if word[pattern.find(e)] != e:
            t = False
            break
    return t
        
def (word,exclude_chars):
    t = True
    for e in exclude_chars:
        if e in word:
            t = False
            break
    return t

def have(word,include_chars):
    t = True
    for e in include_chars:
        if e in word:
            word.remove(e)
        else:
            t = False
            break
    return t
        
            
def match(word, pattern, include_chars, exclude_chars):
    truth = True
    if len(word)==len(pattern):
        truth == True
    elif same_position(word,pattern):
        truth == True
    elif not_have(word,exclude_chars):
        truth == True
    elif have(word,include_chars):
        truth == True
  return truth

6531320621
# 1664096, 2022-10-29 10:36:35, ----- (0%)

color_file = input()
lyrics_file = input()

color = open(color_file,'r')
lyrics = open(lyrics_file,'r')

colors = []
for line in color:
    x = line.strip().split()
    colors.extend(x)

ans = ''
for line in lyrics:
    new_line = line
    for i in colors:
        if i.lower() in line.lower():
            pos = line.find(i.lower())
            new_line  = new_line[0:pos]+'<'+str(i.lower)+'>'+new_line[pos:pos+len(i)]+new_line[pos+len(i):]
    ans += new_line+'\n'
print(ans)
# 1664470, 2022-10-29 10:40:23, ----- (0%)

color_file = input()
lyrics_file = input()

color = open(color_file,'r')
lyrics = open(lyrics_file,'r')

colors = []
for line in color:
    x = line.strip().split()
    colors.extend(x)

print(colors)
ans = ''
for line in lyrics:
    new_line = line
    for i in range(len(colors)):
        if colors[i].lower() in line.lower():
            pos = line.find(colors[i].lower())
            new_line  = new_line[0:pos]+'<'+colors[i].lower()+'>'+new_line[pos:pos+len(colors[i])]+new_line[pos+len(colors[i]):]
    ans += new_line+'\n'
color.close()
lyrics.close()
print(ans)
# 1664520, 2022-10-29 10:40:45, ----- (0%)

color_file = input()
lyrics_file = input()

color = open(color_file,'r')
lyrics = open(lyrics_file,'r')

colors = []
for line in color:
    x = line.strip().split()
    colors.extend(x)


ans = ''
for line in lyrics:
    new_line = line
    for i in range(len(colors)):
        if colors[i].lower() in line.lower():
            pos = line.find(colors[i].lower())
            new_line  = new_line[0:pos]+'<'+colors[i].lower()+'>'+new_line[pos:pos+len(colors[i])]+new_line[pos+len(colors[i]):]
    ans += new_line+'\n'
color.close()
lyrics.close()
print(ans)

6531324121
# 1662973, 2022-10-29 10:14:01, ----- (0%)

color_file = input()
song_file = input()

# color_file = "c.txt"
# song_file = "s.txt"

def flatten(l:list):
    res = []

    for i in range(len(l)):
        if type(l[i]) is list:
            res += flatten(l[i])
        else:
            res.append(l[i].lower())

    return res

def is_same_color(s1, s2):
    if len(s1) != len(s2):
        return False
    
    for c1, c2 in zip(s1, s2):
        if s1.lower() != s2.lower():
            return False

    return True

with open(color_file) as color_data:
    color_data = color_data.readlines()

for i in range(len(color_data)):
    color_data[i] = color_data[i].replace("\n", "").split()

color_data = flatten(color_data)
with open(song_file) as song_data:
    song_data = song_data.readlines()

for i in range(len(song_data)):
    song_data[i] = song_data[i].replace("\n", "").lower()

# song_data = " ".join(song_data)
# print(color_data)
# print(song_data)
new_song = []

colors_change = {}

for color in color_data:
    colors_change[color] = "<" + color + ">" + color.upper() +"</>"

# print(colors_change)
for i in range(len(song_data)):
    for color in color_data:
        song_data[i] = song_data[i].replace(color, colors_change[color])
        # song_data[i] = song_data[i][0].upper() + song_data[i][1:]
    if song_data[i][0] in "abcdefghijklmnopqrstuvwxyz":
        song_data[i] = song_data[i][0].upper() + song_data[i][1:]

    song_data[i] = song_data[i].replace(" i ", " I  ")

for line in song_data:
    print(line)
# 1663711, 2022-10-29 10:30:09, ----- (0%)

color_file = input()
song_file = input()

# color_file = "c.txt"
# song_file = "s.txt"

def flatten(l:list):
    res = []

    for i in range(len(l)):
        if type(l[i]) is list:
            res += flatten(l[i])
        else:
            res.append(l[i].lower())

    return res

def is_same_color(s1, s2):
    if len(s1) != len(s2):
        return False
    
    for c1, c2 in zip(s1, s2):
        if s1.lower() != s2.lower():
            return False

    return True

with open(color_file) as color_data:
    color_data = color_data.readlines()

for i in range(len(color_data)):
    color_data[i] = color_data[i].replace("\n", "").split()

color_data = flatten(color_data)
with open(song_file) as song_data:
    song_data = song_data.readlines()

for i in range(len(song_data)):
    song_data[i] = song_data[i].replace("\n", "").lower()

# song_data = " ".join(song_data)
# print(color_data)
# print(song_data)
new_song = []

colors_change = {}

for color in color_data:
    colors_change[color] = "<" + color + ">" + color.upper() +"</>"

for i in range(len(song_data)):
    new_line = ""
    if song_data[i] == "":
        continue
    else:
        for word in song_data[i]:
            if word[-1] in ".,":
                to_check = word[:-1]
                is_dot = True
                if word[-1] == ".":
                    dot = "."
                else:
                    dot = ","
            else:
                to_check = word
                is_dot = False
            for color in color_data:
                if is_same_color(color, to_check):
                    word = word.replace(color, colors_change[color])
                    break
            
            new_line += word+ " "
    
    song_data[i] = new_line

for line in song_data:
    print(line)
# 1664540, 2022-10-29 10:40:53, ----- (0%)

color_file = input()
song_file = input()

# color_file = "c.txt"
# song_file = "s.txt"

def flatten(l:list):
    res = []

    for i in range(len(l)):
        if type(l[i]) is list:
            res += flatten(l[i])
        else:
            res.append(l[i].lower())

    return res

def is_same_color(s1, s2):
    if len(s1) != len(s2):
        return False
    
    for c1, c2 in zip(s1, s2):
        if s1.lower() != s2.lower():
            return False

    return True

with open(color_file) as color_data:
    color_data = color_data.readlines()

for i in range(len(color_data)):
    color_data[i] = color_data[i].replace("\n", "").split()

color_data = flatten(color_data)
with open(song_file) as song_data:
    song_data = song_data.readlines()

for i in range(len(song_data)):
    song_data[i] = song_data[i].replace("\n", "").lower()

# song_data = " ".join(song_data)
# print(color_data)
# print(song_data)
new_song = []

colors_change = {}

for color in color_data:
    colors_change[color] = "<" + color + ">" + color.upper() +"</>"

for i in range(len(song_data)):
    new_line = ""
    if song_data[i] == "":
        continue
    else:
        for word in song_data[i]:
            # if word[-1] in ".,":
            #     to_check = word[:-1]
            #     is_dot = True
            #     if word[-1] == ".":
            #         dot = "."
            #     else:
            #         dot = ","
            # else:
            #     to_check = word
            #     is_dot = False
            for color in color_data:
                if is_same_color(word, color):
                    word = word.replace(word, colors_change[color])
                    break
            new_line += word + " "
    
    song_data[i] = new_line

for line in song_data:
    print(line)

6531338021
# 1663725, 2022-10-29 10:30:27, ----- (0%)

col = input()
sng = input()

color =[]
with open(col) as cr:
    for i in cr:
        for j in i.lower().split():
            color.append(j)
with open(sng) as sr:
    for i in sr:
        for j in i:
            if j.lower() in color:
                for k in color:
                    x = "<" + k + ">" + j + "</>"
                    j.replace(j,x)

# 1664468, 2022-10-29 10:40:22, ----- (0%)

col = input()
sng = input()

color =[]
with open(col) as cr:
    for i in cr:
        for j in i.lower().split():
            color.append(j)

# 1664500, 2022-10-29 10:40:39, ----- (0%)

col = input()
sng = input()

color =[]
with open(col) as cr:
    for i in cr:
        for j in i.lower().split():
            color.append(j)
with open(sng) as sr:
    for i in sr:
        for j in i:
            if j.lower() in color:
                for k in color:
                    x = "<" + k + ">" + j + "</>"
                    j.replace(j,x)


6531005021
# 1661767, 2022-10-29 09:35:56, xxxxx (0%)

name = input()
fout = input()
fout = ('name' ,'W')
fout.close()

# 1661829, 2022-10-29 09:38:25, xxxxx (0%)

name = input()
fout = input()
f1=open('name',"r")
f2 =open('fout' ,"w")
f1.close()
f2.close()

# 1661937, 2022-10-29 09:41:47, xxxxx (0%)

name = input()
fout = input()
f1=open('name',"r")
f2 =open('fout' ,"w")
line1 = f1.readline()
line2 = f2.readline()
f1.close()
f2.close()

6432032021
# 1663587, 2022-10-29 10:27:35, ----- (0%)

f1 = input()
f2 = input()
fn1 = open(f1,'r')
fn2 = open(f2,'r')

fn1 = fn1.read().lower().split()
for i in fn2:
    result = ''
    r = ''
    g = 0
    for j in range(g,len(i),1) :
        if 'a'<= i[j].lower() <= 'z' :
            r += i[j]
        else:
            if r.lower() in fn1:
                result += '<'+r.lower()+'>'+r+'</>'
            r = ''
    print(result)
        
            
                
                
        
        
        


# 1664298, 2022-10-29 10:38:55, ----- (0%)

f1 = input()
f2 = input()
fn1 = open(f1,'r')
fn2 = open(f2,'r')

fn1 = fn1.read().lower().split()
for i in fn2:
    result = ''
    r = ''
    g = 0
    for j in range(g,len(i),1) :
        if 'a'<= i[j].lower() <= 'z' :
            r += i[j]
        elif r.lower() in fn1:
                result += '<'+r.lower()+'>'+r+'</>'
                r = ''
                g = j
        else:
            result += i[j]

    print(result)
            
        
            
                
                
        
        
        



6530020121
# 1664572, 2022-10-29 10:41:11, xxxxx (0%)

#color = input().strip()
#txt  = input().strip()
color = 'color.txt'
txt = 'txt.txt'
cl_list = []
wor_txt = ''
new = ''
cltxt = open(color,'r')
for line in cltxt:
    cl = line.lower().split()
    cl_list += cl
cltxt.close()
word = open(txt,'r')
for line in word:
    wor_txt += line
cap = wor_txt.lower()
start = 0
for i in range(len(cl_list)):
    look = 0
    while True:
        look = cap.find(cl_list[i],look)
        if look == -1:
            break
        else:
            new = wor_txt[start:look-1] + '<' + cl_list[i] + '>' + wor_txt[look:len(cl_list[i])] + '</>'+ wor_txt[look+len(cl_list[i])+4:]
            wor_txt = new
            cap = wor_txt.lower()
            start = len(cl_list[i])+4
            look = start
print(wor_txt)

# 1664600, 2022-10-29 10:41:28, ----- (0%)

color = input().strip()
txt  = input().strip()
cl_list = []
wor_txt = ''
new = ''
cltxt = open(color,'r')
for line in cltxt:
    cl = line.lower().split()
    cl_list += cl
cltxt.close()
word = open(txt,'r')
for line in word:
    wor_txt += line
cap = wor_txt.lower()
start = 0
for i in range(len(cl_list)):
    look = 0
    while True:
        look = cap.find(cl_list[i],look)
        if look == -1:
            break
        else:
            new = wor_txt[start:look-1] + '<' + cl_list[i] + '>' + wor_txt[look:len(cl_list[i])] + '</>'+ wor_txt[look+len(cl_list[i])+4:]
            wor_txt = new
            cap = wor_txt.lower()
            start = len(cl_list[i])+4
            look = start
print(wor_txt)

6531202221
# 1662824, 2022-10-29 10:09:44, xxxxx (0%)

co = open('b.py','r')
melo = open('a.py','r')
color = []
color1 = []
for lc in co:
    color += lc.split()
for i in range(len(color)):
    color1 += [color[i].lower()]
a = ''
for lm in melo:
    a += lm.lower()

co.close()
melo.close()
# 1664363, 2022-10-29 10:39:32, xxxxx (0%)

co = open('b.py','r')
melo = open('a.py','r')
color = []
color1 = []
for lc in co:
    color += lc.split()
for i in range(len(color)):
    color1 += [color[i].lower()]
n = ''
fi = ''
a = ''
for lm in melo:
    n = lm.lower()
    for i in range(len(color1)):
        if color1[i] in n:
            a += n.replace(color1[i],'<'+color1[i]+'>'+color1[i]+'</>')
        n = a
    print(n)
        
co.close()
melo.close()

6531402421
# 1664546, 2022-10-29 10:40:55, compilation error (0%)

ilecolor = input()
filemusic = input()
lst1 = []
w1 = open(filecolor, 'r')
for line1 in w1:
w2 = open(filemusic, 'r')
for line2 in w2:
# 1664591, 2022-10-29 10:41:23, compilation error (0%)

ilecolor = input()
filemusic = input()
lst1 = []
w1 = open(filecolor, 'r')
for line1 in w1:
w2 = open(filemusic, 'r')
for line2 in w2:
print()

6531409921
# 1663974, 2022-10-29 10:34:43, compilation error (0%)

print('<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.
Dark<blue>blue</>, <purple>purple</> and <green>green</>.
I like <white>WHITE</>. I like <red>Red</>.
What's your favorite color?')
# 1664303, 2022-10-29 10:38:57, ----- (0%)

w = '<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.'
s = 'Dark<blue>blue</>, <purple>purple</> and <green>green</>.'
r = 'I like <white>WHITE</>. I like <red>Red</>.'
f = 'What\'s your favorite color?'
ans = w+'\n'+s+'\n'+'\n'+r+f
print(ans)

6531508321
# 1663343, 2022-10-29 10:22:52, ----- (0%)

First = input()
Second = input()
fout = open("First", "w")
fout.write("White red\n")
fout.write("orange black pink gold\n")
fout.write("blue brown GREEN\n\n\n")
fout.write("Purple\n")
fout.write("yellow")
fout.close
ft = open("Second", "w")
ft.write("Orange, yellow and pinky.\n")
ft.write("Darkblue, purple and green.\n\n")
ft.write("I like WHITE. I like Red.\n")
ft.write("What's your favorite color?")
ft.close

# 1664548, 2022-10-29 10:40:55, ----- (0%)

First = input()
Second = input()
fout = open("First", "w")
fout.write("White red\n")
fout.write("orange black pink gold\n")
fout.write("blue brown GREEN\n\n\n")
fout.write("Purple\n")
fout.write("yellow")
fout.close
ft = open("Second", "w")
ft.write("Orange, yellow and pinky.\n")
ft.write("Darkblue, purple and green.\n\n")
ft.write("I like WHITE. I like Red.\n")
ft.write("What's your favorite color?")
ft.close
fn = open("First","r")
for line in fn :
    print(line)
fn.close    

6530031021
# 1663296, 2022-10-29 10:21:51, ----- (0%)

def filecolor(lk) :
    file = open(lk, "r")
    for line in file :
        print(line)
    file.close()

    
def filesong(lk) :
    file = open(lk, "r")
    for line in file :
        print(line)
    file.close()
# 1663405, 2022-10-29 10:24:05, ----- (0%)

def filecolor(lk) :
    file = open(lk, "r")
    for line in file :
        print(line)
    file.close()

    
def filesong(lk) :
    file = open(lk, "r")
    for line in file :
        print(line)
    file.close()
    
filecolor(input())
filesong(input())

6530042021
# 1662733, 2022-10-29 10:07:12, ----- (0%)

n = input()
print(n)
# 1662740, 2022-10-29 10:07:35, compilation error (0%)


print(<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.
Dark<blue>blue</>, <purple>purple</> and <green>green</>.
I like <white>WHITE</>. I like <red>Red</>.
What's your favorite color?)


6530046521
# 1664143, 2022-10-29 10:37:10, xxxxx (0%)

fn1 = input()
fn2 = input()

f1 = open(fn1, 'r')
l = ''
for line1 in f1:
    for e in line1:
        l += e.lower()
    color = l.strip().split()

f1 = open(fn2, 'r')
for line2 in f2:
    for c in color:
        k1 = line2.lower().find(c)-1
        k2 = line2.lower().find(c)+len(c)
        line2.insert(k1, '<'+c+'>')
        line2.insert(k2, '</>')
    print(line2)
# 1664497, 2022-10-29 10:40:38, xxxxx (0%)

fn1 = input()
fn2 = input()

f1 = open(fn1, 'r')
l = ''
for line1 in f1:
    for e in line1:
        l += e.lower()
    color = l.strip().split()

f2 = open(fn2, 'r')
for line2 in f2:
    for c in color:
        k1 = line2.lower().find(c)-1
        k2 = line2.lower().find(c)+len(c)
        line2.insert(k1, '<'+c+'>')
        line2.insert(k2, '</>')
    print(line2)

6530058021
# 1663989, 2022-10-29 10:35:00, ----- (0%)

x = input()
y = input()
# 1664007, 2022-10-29 10:35:16, ----- (0%)

x = input()

6530096921
# 1663820, 2022-10-29 10:32:10, ----- (0%)

cf=input()
sf=input()
fn=open(cf,'r')
color=[]
for line in fn:
    color.append(line)
fn.close()
f=open(sf,'r')
song=''
for line in f:
    song+=line
f.close()
out=''
for i in color:
    for j in range(len(song)):
        if song.find(i,j)!=-1:
            k=song.find(i,j)
            out=song[:k]+'<'+i+'>'+song[len(song):]+'</>'
            
print(out)
# 1664049, 2022-10-29 10:35:51, xxxxx (0%)

cf=input()
sf=input()
fn=open(cf,'r')
color=[]
for line in fn:
    color.append(line.strip().split())
fn.close()
f=open(sf,'r')
song=''
for line in f:
    song+=line
f.close()
out=''
for i in color:
    for j in range(len(song)):
        if song.index(i,j)!=-1:
            k=song.index(i,j)
            out=song[:k]+'<'+i+'>'+song[len(song):]+'</>'
            
print(out)

6530108821
# 1664079, 2022-10-29 10:36:10, compilation error (0%)

C = "white,red,orange,black,pink,gold,blue,brown,green,purple,yellow"
R = str(input())
k in C
  if k in R:
      k = <k>k</>
print(R)
      
# 1664084, 2022-10-29 10:36:13, compilation error (0%)

C = "white,red,orange,black,pink,gold,blue,brown,green,purple,yellow"
R = str(input())
k in C
  if k in R:
      k = <k>k</>
print(R)

6530110021
# 1663388, 2022-10-29 10:23:48, compilation error (0%)

<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.
Dark<blue>blue</>, <purple>purple</> and <green>green</>.
I like <white>WHITE</>. I like <red>Red</>.
What's your favorite color?
# 1663437, 2022-10-29 10:24:41, compilation error (0%)

sorry mom sorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry mom
sorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry momsorry mom
sorry mom
sorry mom
sorry mom
sorry mom
sorry mom
sorry mom
sorry mom
sorry mom
sorry momsorry mom
sorry mom
sorry momsorry mom
sorry mom
sorry mom


6530118021
# 1664567, 2022-10-29 10:41:08, xxxxx (0%)

def col(c):
  n = '<'+c.lower()+'>'+c+'</>'
  return n

color = input().strip()
lyrics = input().strip()
fc = open(color,'r')
lc = []
for line in fc:
  line = line.split()
  if line != []:
    lc += line
fc.close()
fl = open(lyrics,'r')
for line in fl:
  line = line.split()
  for i in range(len(line)):
    for a in lc:
        if lc in line[i]:
          l = line[i].lower().find(a)
          line[i] = line[i][:l] + col(line[i][l:l+len(a)]) + line[i][l+len(a)+1:] 
print(' '.join(line))
fl.close()

# 1664640, 2022-10-29 10:41:57, xxxxx (0%)

def col(c):
  n = '<'+c.lower()+'>'+c+'</>'
  return n

color = input().strip()
lyrics = input().strip()
fc = open(color,'r')
lc = []
for line in fc:
  line = line.split()
  if line != []:
    lc += line
fc.close()
fl = open(lyrics,'r')
for line in fl:
  line = line.split()
  for i in range(len(line)):
    for a in lc:
      if lc in line[i]:
        l = line[i].lower().find(a)
        line[i] = line[i][:l] + col(line[i][l:l+len(a)]) + line[i][l+len(a)+1:] 
print(' '.join(line))
fl.close()

6530136321
# 1663804, 2022-10-29 10:31:51, ----- (0%)

fcolor = input()
fsong  = input()
finfile = open(fcolor)
sinflie = open(fsong)
for line in fsong:
    for c in line:
        x= []
        if c.find(fcolor) != -1:
            x.append('<'+fcolor.lower()+'>'+c+'</>')
        else: x.append(c)
print(x)
# 1664258, 2022-10-29 10:38:32, xxxxx (0%)

fcolor = input()
fsong  = input()
finfile = open(fcolor)
x = finfile.readlines.split()
inflie = open(fsong)
for line in fsong:
    for c in line:
        x= []
        if c.find(fcolor) != -1:
            x.append('<'+fcolor.lower()+'>'+c+'</>')
        else: x.append(c)
print(x)

6530165521
# 1664043, 2022-10-29 10:35:46, xxxxx (0%)

dc = 'file.txt'
fc = open(dc,'r')
all_col = ''
for line in fc:
    all_col += line
all_col = all_col.split('\n')
newcol = []
for e in all_col:
    newcol += e.split()

for i in range(len(newcol)):
    newcol[i] = newcol[i].lower()


song = 'song.txt'
sg = open(song,'r')
for line in sg:
    ans = ''
    line = line.strip()
    exline = line.lower()
    co = [e for e in newcol if e in exline]
    ind = [exline.index(e) for e in co]
    for i in range(len(line)):
        if i in ind:
            ans += '<' + co[i] + '>' + '</>'
        ans += line[i]
        
    print(ans)
# 1664071, 2022-10-29 10:36:06, xxxxx (0%)

dc = input()
fc = open(dc,'r')
all_col = ''
for line in fc:
    all_col += line
all_col = all_col.split('\n')
newcol = []
for e in all_col:
    newcol += e.split()

for i in range(len(newcol)):
    newcol[i] = newcol[i].lower()


song = input()
sg = open(song,'r')
for line in sg:
    ans = ''
    line = line.strip()
    exline = line.lower()
    co = [e for e in newcol if e in exline]
    ind = [exline.index(e) for e in co]
    for i in range(len(line)):
        if i in ind:
            ans += '<' + co[i] + '>' + '</>'
        ans += line[i]
        
    print(ans)

6530180921
# 1663774, 2022-10-29 10:31:12, ----- (0%)

name1 = input()
name2 = input()
print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.\nDark<blue>blue</>, <purple>purple</> and <green>green</>.\n\nI like <white>WHITE</>. I like <red>Red</>.\nWhat's your favorite color?")
# 1664499, 2022-10-29 10:40:39, ----- (0%)

name1 = input()
on1 = open(name1, "r")
color = []
for k in on1:
    c = k.split()
    for cc in c:
        color.append(cc.lower())
on1.close()
name2 = input()
on2 = open(name2, "r")
bun = []
for k in on2:
    bun.append(k[:-1])
    

6530192421
# 1663865, 2022-10-29 10:33:00, ----- (0%)

fam = input()
se = input()
see = open(se)
color = []
for line in see:
    if line[0] == '\n':
        continue
    color += line.split()
see.close()
for i in range(len(color)):
   color[i] = color[i].lower()

k = ''
fff = open(fam)
for line in fff:
    line = line.split()
    for i in line:
        for o in i:
            if not 'a' <= o.lower() <= 'z':
                i = i[:i.find(o)]
                if i.lower() in color:
                    k += '<'+i.lower()+'>'+i+'</>'+i[i.find(o)]
                else:
                    k += i

            if i.lower() in color:
                k += '<'+i.lower()+'>'+i+'</>'
print(k)
# 1663881, 2022-10-29 10:33:16, ----- (0%)

fam = input()
se = input()
see = open(se)
color = []
for line in see:
    if line[0] == '\n':
        continue
    color += line.split()
see.close()
for i in range(len(color)):
   color[i] = color[i].lower()


6530207221
# 1663727, 2022-10-29 10:30:28, ----- (0%)

color_o = input().strip()
lyric = input().strip()

color_d = {}
infiles1 = open(color_o,'r')
for line in infiles1:
    l = line.lower().split()
    for ch in l:
        color_d[ch] = '<'+ch+'>'
infiles1.close()

#infiles2 = open(lyric,'r')
#for line in i
# 1663750, 2022-10-29 10:30:45, ----- (0%)

color_o = input().strip()
lyric = input().strip()

color_d = {}
infiles1 = open(color_o,'r')
for line in infiles1:
    l = line.lower().split()
    for ch in l:
        color_d[ch] = '<'+ch+'>'
infiles1.close()

infiles2 = open(lyric,'r')
for line in infiles2:
    line = line.lower()
    s = ''
    for key in color_d:
        if line.find(key) == -1 :
            pass
        else :
            c = line.find(key)
            s += line[:c] + color_d[key]
            s += line[c:c+len(key)+1] + '</>'
        line = s
infiles2.close()

6531332121
# 1663596, 2022-10-29 10:27:42, ----- (0%)

color = input()
lyrics = input()
fcolor = open(color, 'r')
colors = set()
for line in fcolor:
    for word in line:
        colors.add(word.upper())
flyrics = open(lyrics, 'r')
for line in flyrics:
    for word in line:
        if word.upper() in colors:
            line.replace(word, '<' + word.lower() + '>' + word + '</>')
    print(line)

# 1664135, 2022-10-29 10:37:05, --xxx (0%)

color = input()
lyrics = input()
fcolor = open(color, 'r')
colors = set()
for line in fcolor:
    words = line.split()
    for word in words:
        colors.add(word.upper())
print(colors)
flyrics = open(lyrics, 'r')
for line in flyrics:
    print(line, end='')
    words = line.split()
    print(words)
    for word in words:
        if word.upper() in colors:
            newline = line.replace(word, '<' + word.lower() + '>' + word + '</>')
    print(newline, end='')

# grader/color.txt
# grader/lyrics.txt


6532100021
# 1662841, 2022-10-29 10:10:14, ----- (0%)

print("""<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.
Dark<blue>blue</>, <purple>purple</> and <green>green</>.
I like <white>WHITE</>. I like <red>Red</>.
What's your favorite color?""")

# 1662860, 2022-10-29 10:10:43, ----- (0%)

print("""<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.
Dark<blue>blue</>, <purple>purple</> and <green>green</>.

I like <white>WHITE</>. I like <red>Red</>.
What's your favorite color?""")

6532141821
# 1663534, 2022-10-29 10:26:40, ----- (0%)

name_color = input().strip()
name_song = input().strip()
file_color = open(name_color, "r")
file_song = open(name_song, "r")
color = set()
for color_line in file_color :
    for e in color_line.strip().split() :
        color.add(e.lower())
for line in file_song :
    copy = line.lower()
    for e in color :
        tochange = []
        tochange_word = []
        for i in range(len(copy)) :
            try :
                if e == copy[i:i+len(e)] :
                    tochange.append(i)
            except :
                quit()
        for q in tochange :
            tochange_word.append(line[q:q+len(e)])
        for r in tochange_word :
            line.replace(r, "<"+e+">"+r+"</>")
    print(line)
# 1664055, 2022-10-29 10:35:53, ----- (0%)

name_color = input().strip()
name_song = input().strip()
file_color = open(name_color, "r")
file_song = open(name_song, "r")
color = set()
for color_line in file_color :
    for e in color_line.strip().split() :
        color.add(e.lower())
for line in file_song :
    copy = line.lower()
    for e in color :
        tochange = []
        tochange_word = []
        for i in range(len(copy)) :
            try :
                if e == copy[i:i+len(e)] :
                    tochange.append(i)
            except :
                quit()
        for q in tochange :
            tochange_word.append(line[q:q+len(e)])
        for r in tochange_word :
            line.replace(r, "<" + e + ">" + r + "</>")
    print(line)

6532201821
# 1663998, 2022-10-29 10:35:06, ----- (0%)

a = input()
b= input()
f1=open(a,'r')
cl=[]
for l in f1:
    ll=l.strip().lower().split()
    for i in ll:
        cl.append(i)

f1.close()
f2=open(b,'r')

for line in f2:
#for i in range(1):
    #line=f2.readline()
    #line=f2.readline()
    ind=[]
    #
    for i in range(len(line)) :
        str=''
        if i==0 :
            j=i
            while(j<len(line) and line[j] not in ', .' ) :
                str+=line[j]
                j+=1
            if str.lower() in cl :  ind.append([i,str.strip()])
            #if(len(ind)!=0):print(ind)
            continue
        
        elif line[i] in ', .' :
            
            j=i+1
            while(j<len(line) and line[j] not in ', .' ) :
                str+=line[j]
                j+=1
        #print(str)
        if str.lower() in cl :
            ind.append([i+1,str.strip()])
    sum=0
    line=list(line)
    #print(line)
    #dl=4+len()
    for i,str in ind :
        i=int(i)
        dl=5+len(str)
        line[i+sum:i+sum+len(str)]='<'+ str.lower() +'>' + str +'</>'
        sum+=dl
    anw=''
    for x in line : anw+=x
    print(anw)


    #print(ind)

    
            
f2.close()
#print(cl)
# data.txt
# data2.txt
# 1664221, 2022-10-29 10:38:08, ----- (0%)

a = input()
b= input()
f1=open(a,'r')
cl=[]
for l in f1:
    ll=l.strip().lower().split()
    for i in ll:
        cl.append(i)

f1.close()
f2=open(b,'r')

for line in f2:
#for i in range(1):
    #line=f2.readline()
    #line=f2.readline()
    ind=[]
    #
    for i in range(len(line)) :
        str=''
        if i==0 :
            j=i
            while(j<len(line) and line[j] not in ', .' ) :
                str+=line[j]
                j+=1
            if str.lower() in cl :  ind.append([i,str.strip()])
            #if(len(ind)!=0):print(ind)
            continue
        
        elif line[i] in ', .' :
            
            j=i+1
            while(j<len(line) and line[j] not in ', .' ) :
                str+=line[j]
                j+=1
        #print(str)
        if str.lower() in cl :
            ind.append([i+1,str.strip()])
    sum=0
    line=list(line)
    #print(line)
    #dl=4+len()
    for i,str in ind :
        i=int(i)
        dl=5+len(str)
        line[i+sum:i+sum+len(str)]='<'+ str.lower() +'>' + str +'</>'
        sum+=dl
    anw=''
    for x in line : anw+=x
    print(anw)


    #print(ind)

    
            
f2.close()
#print(cl)
# data.txt
# data2.txt

6531004321
# 1663667, 2022-10-29 10:29:11, xxxxx (0%)

f = open('lyric.txt')
for line in f:
  print(line)
# 1663757, 2022-10-29 10:30:51, ----- (0%)

fn =  input()
f = open(fn)
for line in f:
  print(line)

6531810821
# 1663950, 2022-10-29 10:34:15, xxxxx (0%)

colorfile = input()
lyric = input()
colorlist = []

clf = open(colorfile)
for i in clf :
    i.split()
    for e in i :
        colorlist.append(e.lower())

lyrc = open(colorfile)
prnt = ""
for i in lyrc :
    a = i.split(" ")
    for e in a :
        if e[-1] in ",." :
            e = colorlist(index(e[0:-1].lower())) + e[0:-1] + "</>" + e[-1]
            prnt = prnt + e
        else :
            e = colorlist(index(e[0:-1].lower())) + e + "</>"
            prnt = prnt + e

print(prnt)   
# 1664035, 2022-10-29 10:35:40, xxxxx (0%)

colorfile = input()
lyric = input()
colorlist = []

clf = open(colorfile)
for i in clf :
    i.split()
    for e in i :
        colorlist.append(e.lower())

lyrc = open(colorfile)
prnt = ""
for i in lyrc :
    a = i.split(" ")
    for e in a :
        if e[-1] in ",." :
            e = colorlist(index(e[0:-1].lower())) + e[0:-1] + "</>" + e[-1]
            prnt = prnt + e + " "
        else :
            e = colorlist(index(e[0:-1].lower())) + e + "</>" 
            prnt = prnt + e + " "
    prnt = prnt - " "
    print(prnt)

6130394021
# 1664412, 2022-10-29 10:39:56, ----- (0%)

print("")

6230063921
# 1664365, 2022-10-29 10:39:33, ----- (0%)

color = input()
note = input()
f1 = open(color)
color = ''

for line in f1:
    color += line.strip() +' '
    color = color.lower()
color = color.split()

f2 = open(note)

out = []
for line in f2:
    out.append(line.strip())

s = 'Orange, yellow and pinky.'

def addcolor(s,color):
    out = ''
    k1 = 0
    while True:
        k2 = s.find(color,k1)
        if k2 != -1:
            out+= '<'

6231101221
# 1664413, 2022-10-29 10:39:57, ----- (0%)

colour_file = input()
song_file = input()
colour = ['white','red','orange','black','pink','gold','blue','brown','green','purple','yellow']
f = open(colour_file)
for line in f:
    
    
    print(line)
f.close


6231130421
# 1664463, 2022-10-29 10:40:20, ----- (0%)

fin1 = input()
fin2 = input()
f1 = open(fin1, 'r')
f2 = open(fin2, 'r')
texts1 = f1.read()
f1.close()
texts2 = f2.read()
f2.close()
color = texts1.split()

6231405021
# 1664443, 2022-10-29 10:40:09, ----- (0%)

def highlight(s):
    x = HIGHLIGHT + s + RESET
    return x
def color_tag(s):
    x = s[1:]
    y = x.find(">")
    z = x[:y]
    a = x[y + 1 :-3]
    if z == "red" :
        b = red + a + RESET
        return b
    elif z == "white" :
        b = white + a + RESET
        return b
    elif z == "green" :
        b = GREEN + a + RESET
        return b

6230187021
# 1664603, 2022-10-29 10:41:31, ----- (0%)

folder_colour=input().strip()
folder_song=input().strip()
colour_new=[]
f1=open(folder_colour,'r')
for line in f1:
    colour_new+=line.split('\n')
f1.close


6431517921
# 1661393, 2022-10-29 09:22:47, compilation error (0%)

filecolorname=input().strip()
filemusicname=input().strip()
f=open(file_name)
for line in f:
    print(rename(line.strip() filecolorname,filemusicname))
f.close    

6430064721
# 1663088, 2022-10-29 10:16:30, compilation error (0%)

cf = input()
sf = input()
cl = open(cf).read().lower().replace("\n"," ").split()
song = open(sf)

for i in song :
    sl=i
    sl2 = sl.lower().split()
    for e in sl2 :
        if e in cl :
            

6431105021
# 1664518, 2022-10-29 10:40:45, xxxxx (0%)

ยากมาก

6431120321
# 1664598, 2022-10-29 10:41:26, ----- (0%)

x = input()

fin = open(x,"r")
U = ''
for line in fin:
    U += line.strip() + ' '
you = U.lower().split()
fin.close()

6430363321
# 1664408, 2022-10-29 10:39:54, ----- (0%)

#่เลิกดิ้นรนดีกว่า
#28.5 ขาดอีกเท่าไหร่จะหมดเวรหมดกรรมกันนะ
#เเฮชเเทกให้มันจบที่เทอมนี้
#ไพทอนทำร้ายจิตใจ
#กลัวอาจารไม่เหน

6430402121
# 1664283, 2022-10-29 10:38:46, compilation error (0%)

color = input().upper()
word = input().upper()
a = color.spilt()
b = word.split()
for i in range (len(a))

6430450221
# 1664452, 2022-10-29 10:40:14, ----- (0%)

name_c=input()
name_s=input()
infile=open(name_c,'r')
k=infile.readline().strip()
colour=[]
for line in infile:
    line=line.split()
    colour+=line
    print(colour)
infile.close()
for i in range(len(colour)):
    colour[i]=colour[i].lower()

6530001221
# 1663952, 2022-10-29 10:34:16, --xx- (0%)

f1 = input()
f2 = input()
x = open( f1, 'r')
y = open( f2, 'r')
p = []
w = ''
for line in x :
    w = line.split()
    for i in range(len(w)) :
        p.append(w[i].lower())
for j in range(len(p)) :
    for line in y :
        for k in range(len(line)) :
            if line[k:k+len(p[i])] == p[i] :
                line = line.replace(p[i],'<'+p[i]+'>'+line[k:k+len(p[i])]+'</>')
                w += line
            else :
                w += line[k]
print(w)
x.close()
y.close()


6530024721
# 1664498, 2022-10-29 10:40:39, compilation error (0%)

cf = input()
rk = input()
print('<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.')
print('Dark<blue>blue</>, <purple>purple</> and <green>green</>.\n
')
print('I like <white>WHITE</>. I like <red>Red</>.
')
print('What\'s your favorite color?')

6531201621
# 1664266, 2022-10-29 10:38:36, ----- (0%)

color = input()
lyrics = input()
fn1 = open(color,"r")
fn2 = open(lyrics,"r")



6531203921
# 1664068, 2022-10-29 10:36:01, compilation error (0%)

print(<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.
Dark<blue>blue</>, <purple>purple</> and <green>green</>.
I like <white>WHITE</>. I like <red>Red</>.
What's your favorite color?)

6531513421
# 1664378, 2022-10-29 10:39:39, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  return bool(word)
exec(input())

6531517021
# 1663416, 2022-10-29 10:24:17, ----- (0%)

def match(x, p):
    if len(x) != len(p):
        return False
    for i in range(len(x)):
        if p[i] != '?' and p[i] != x[i].lower():
            return False
        return True
    
def new(line, line2):
    k1 = 0
    out = ''
    while True:
        k2 = line2.find(line, k1)
        if k2 == -1: break
        specific = line2[k1:k2]
        if match(line, line2):
            out += '<' + line + '>' + line2 + '</>'
        else:
            out += specific
        out += line[k1:]
        return out

name = input()
song = input()

n = open(name)
s = open(song)

for line in n:
    line = line.strip()
    
for line2 in s:
    line2 = line2.strip()
    
    print(new(line, line2))
        
n.close()
s.close()


6531518621
# 1664250, 2022-10-29 10:38:28, compilation error (0%)

color = input().lower()
lyrics = input().split

fn = open(lyrics)
for line in fn :
    
    
fn.close


6531519221
# 1664641, 2022-10-29 10:41:57, TTTTT (0%)

def rename(l , c ):
    k1=0
    out = ''
    k2=0
    while k2!= len(l):
        k2 = l.find(c,k1)
        old = l[k1:k2]
        if k2 != -1:
            
            
            out+= '<'+c.lowwer()+'>'+old+"</>"
        else:
            out+=old
        k1 = k2+1
    out += l[k1:]
    return out
    
    
f1 = input()
f2 = input()
f = open(f1)
o = open(f2)
for line in f1:
    color = line.split()
for i in color:
    for line in f2:
        print(rename(line,i))
        

6530030421
# 1664346, 2022-10-29 10:39:22, compilation error (0%)

this is so hard

6530033321
# 1662883, 2022-10-29 10:11:28, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True


6530043621
# 1664580, 2022-10-29 10:41:16, ----- (0%)

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.")
print("Dark<blue>blue</>, <purple>purple</> and <green>green</>.")
print("")
print("I like <white>WHITE</>. I like <red>Red</>.")
print("What's your favorite color?")

6530047121
# 1664535, 2022-10-29 10:40:49, ----- (0%)

a=input()
b=input()
c=[]
color=open(a,"r")
lylic=open(a,"r")
for line in color:
    c.append(line.strip().split())
print(c)



6530050021
# 1664517, 2022-10-29 10:40:45, ----- (0%)

print("It is too hard for me.I cannot do this in time.However, I will not give up")

6530055121
# 1663979, 2022-10-29 10:34:47, compilation error (0%)

x = "White red /n orange black pink gold /nblue brown GREEN /n Purple /n yellow"
y = "Orange, yellow and pinky. /n Darkblue, purple and green.
 /n I like WHITE. I like Red.
 /n What's your favorite color?"
print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y. /n Dark<blue>blue</>, <purple>purple</> and <green>green</>. /n /n I like <white>WHITE</>. I like <red>Red</>.
 /n What's your favorite color?
")

6530063121
# 1664541, 2022-10-29 10:40:53, compilation error (0%)

def  match(x):
    if x.lower() in ["white","red","orange", "black","pink", "gold","blue","brown","green","purple","yellow"]:
        return True
    else:
        return False
def rename(s,new):
    k1=0
    out=""
    while True:
        k2=s.find(" ",k1)
        if k2=-1:
            break
        x=s[k1:k2]
        if match(x):
            out+="<"+x.lower()+">"
            out+=x
            out+="</>"
        else:
            out+=x
    
    
file_color=input()
file_song=input()
o=open(file_color,"r")
for line in o:
    print(line)
    


6530066021
# 1664077, 2022-10-29 10:36:09, ----- (0%)

col = input()
sin = input()

folc = open(col, 'r')
fols = open(sin, 'r')
color = []

for line in folc:
    line = line.lower()
    line = line.strip()
    line = line.split()
    for i in range(len(line)):
        color.append(line[i])

print(color)

song = ''
for line in fols:
    line = line.lower()
    line = line.strip()
    for i in color:
        if i in line :
            s = line.find(i)
            f = s+(len(i)-1)
            song
    print(line)

6530071121
# 1663778, 2022-10-29 10:31:14, xxxxx (0%)

f1 = open(input(),"r")
color = ""
for line in f1:
    color += line.lower()
f1.close()
allcolor = color.split()
f2 = open(input(),"r")
txt = ""
for line in f2:
    txt += line.strip()
f2.close()

for i in range(len(allcolor)):
    j = 0
    word = ""
    while j < len(txt):
        if len(txt[j+len(allcolor[i])]) == len(allcolor[i]):
            for k in range(len(txt[j+len(allcolor[i])])):
                if txt[j+len(allcolor[i])][k].lower() == allcolor[i].lower():
                    word += txt[j+len(allcolor[i])][k]
                else :
                    break
            if word == txt[j+len(allcolor[i])]:
                txt.replace(txt[j+len(allcolor[i])],"<" + str(allcolor[i])+ ">"+\
                            txt[j+len(allcolor[i])] + "</>")
                j += len("<" + str(allcolor[i])+ ">"+\
                            txt[j+len(allcolor[i])] + "</>")
                word = ""
            else :
                word = ""
                j += 1
        else :
            j += 1

6530078621
# 1664648, 2022-10-29 10:42:03, xxxxx (0%)

def find_c(color,h):
    r=[]
    i=h.find(color,0)
    while i!=-1:
        r.append(i,i+len(color),'<'+color+'>','/')
        o=i
        i=h.find(color,o+1)
    return r

def find(h,color):
    s=[]
    for i in color:
        s.append(find_c(i,h))
    return s

def sen(d,n,num):
    s=''
    for i in range(len(num)):
        s+=d[:num[i][0]]+num[i][2]+d[num[i][0]:num[i][1]]+num[i][3]+d[num[i][1]:]
    return s
        

f_color, f_song=input().split()
color=[]
c=open(f_color,'r')
f=c.readline()
while len(f)!=0:
    f=f.strip().lower()
    if ' ' in f: color+=f.split()
    elif f!='': color+=[f]
    f=c.readline()
c.close()

s=open(f_song,'r')
f=s.readline()
show=''
o=0
while len(f)!=0:
    f=f.strip()
    h=f.lower()
    num=find(h,color)
    s=sen(f,h,num)
    print(s)
    f=s.readline()
s.close()


6530082021
# 1664434, 2022-10-29 10:40:06, ----- (0%)

color = input()
lyric = input()
each_clr = []
fn1 = open(color, 'r')
for line in fn1:
    line = line.split()
    for e in line:
        if e not in each_clr:
            each_clr.append(e.lower())
fn1.close()

fn2 = open(lyric, 'r')
out = ''
for line in fn2:
    s = line.lower()
    for g in each_clr:
        x = s.find(g)
        while x != -1:
            k = '<'+g+'>'+line[x:len(g)]+'</>'+line[x+len(g):]
            s = '<'+g+'>'+line[x:len(g)]+'</>'+line[x+len(g):]
            out += k
            x = s.find(g,x+1)
    
    print(out)            

6530090021
# 1664506, 2022-10-29 10:40:41, xxxxx (0%)

#color = input()
color = open('data.txt').read().split()
#A = input()
color = [i.lower() for i in color]
co =''
for i in range(len(color)):
    color.append(color[i]+'.') 
    color.append(color[i]+',') 
    
A = open('data2.txt').read().splitlines()
A = [i.split() for i in A]
qq =[]
for i in A:
   cat(k)
def cat(k):
   re = ''
   for k in i:
        if k.lower() in color :
            re+='<',k.lower(),'>',k.upper(),'<\>'
        else:
            re+=k
            





6530091721
# 1662911, 2022-10-29 10:12:27, compilation error (0%)

print('<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.\nDark<blue>blue</>, <purple>purple</> and <green>green</>.'
print('\nI like <white>WHITE</>. I like <red>Red</>\nWhat\'s your favorite color?')

6530100721
# 1663683, 2022-10-29 10:29:34, compilation error (0%)

color = input()
song = input()
x = open(color, "r")
y = open(song, "r")
for line in y:
    y.replace('WHITE', <white>WHITE</>)
    y.replace('white', <white>white</>)
    y.replace('RED', <red>RED</>)
    y.replace('red', ,<red>red</>)
    y.replace('ORANGE', <orange>ORANGE</>)
    y.replace('orange', <orange>orange</>)
    y.replace('BLACK', <black>BLACK</>)
    y.replace('black', <black>black</>)
    y.replace('PINK', <pink>PINK</>)
    y.replace('PINK', <pink>PINK</>)
print(y)

6530107121
# 1662887, 2022-10-29 10:11:40, TTTTT (0%)

f1 = input()
f2 = input()
l1 = open(f1)
l2 = open(f2)
g = []
for line in l1:
    g += line.lower().split()
for i in g:   
    for line in l2:
        k = 0
        f = line.find(i,k)
        while f != -1:
            line = line[:f]+'<'+i+'>'+line[f+len(i)+2:]+'</>'
            k = f+len(i)+2
    print(line)        
l1.close()
l2.close()


6530111621
# 1664505, 2022-10-29 10:40:41, compilation error (0%)

fn1 = input()
fn2= input()
fn1 = open(fn1 , "r")
fn2 = open(fn2 , "r")
for line in fn1:
    if line.lower().split()
for line in fn2:
    print(line)


6530114521
# 1663697, 2022-10-29 10:29:47, xxxxx (0%)

color = input()
song = input()
lists = []
c = open(color,'r')
s = open(song,'r')
for line in c :
    listc = line.lower.split()
    lists += listc
for line in s :
    a = line.split()
    for e in a :
        if e in lists :
            line = line.split(e)
            line = '<' + e.lower() + '>' + e + '</>'.join(line)
    print(line)

6530116821
# 1663543, 2022-10-29 10:26:44, ----- (0%)

x=input().strip()
y=input().strip()
cf=open(x,'r')
sf=open(y,'r')
for line in sf:
  print(line)
cf.close()
sf.close()

6530124821
# 1662513, 2022-10-29 10:00:14, ----- (0%)

a1 = input()
a2 = input()

color = open(a1)
song = open(a2)
c = ''
for line in color:
    c += ' ' + line

c = c.split()
d = []
for i in range(len(c)):
    d.append(str(c[i].lower()))

s = ''
for line in song:
    s += ' ' + line

s = s.split()
for e in range(len(s)):
    if s[e].lower() in d:
        s[e] = '<'+str(s[e].lower())+'>'+s[e]+'</>'

out = ''
for e in range(len(s)):
    out += s[e]
color.close()
song.close()

6530139221
# 1663772, 2022-10-29 10:31:10, compilation error (0%)

def read_file(filename):
    #File = open(filename, 'r', encoding='utf-8')
    File = open(filename, 'r')
    STRING = File.read()
    #print(STRING)
    LIST = STRING.splitlines()
    File.close()

    return LIST


Filename_Color = input()
Filename_Song = input()

File_COLOR = read_file(Filename_Color)
File_SONG = read_file(Filename_Song)
COLOR = []
for i in File_COLOR:
  LIST = i.split()
  for j in LIST:
    COLOR.append(j.lower())

#print(COLOR)
for text in File_SONG:
  for color in COLOR:
    if color in text.lower():
      INDEX = text.lower().index(color)
      String = f"<{color}>" + text[INDEX:INDEX+len(color)] + "</>"
      text = text.replace(text[INDEX:INDEX+len(color)], String)
  print(text)

6530143721
# 1663081, 2022-10-29 10:16:19, ----- (0%)

x = input()
y = input()
fn1 = open(x,'r')
fn2 = open(y,'r')
st1 = ''
for line in fn1:
    line = line.strip()
    st1 += line + ' '
color = st1.split()
colors = [o.upper() for o in color]
print(colors)
f = []
ans = []
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for lines in fn2:
    consider = []
    a = lines.strip().split()
    for i in a:
        if i in alpha:
            if i.upper() in colors:
                ind = colors.index(i.upper())
                k = '<{}>{}</>'.format(color[ind],i)
                ans.append(k)
            else:
                ans.append(lines)
    a = ''.join(lines)
    print(a)
   

6530154621
# 1663511, 2022-10-29 10:26:09, xxxxx (0%)

filecolor=input()
filesong=input()
str2=''
f1=open(filecolor,'r')
f2=open(filesong,'r')
#f1='orange White red black pink gold blue brown GREEN Purple yellow'
#f2="Orange, yellow and pinky.\nDarkblue, purple and green.\n I like WHITE.I like Red. \n What's your favorite color?"
f1=f1.lower()
l=[e for e in f1.split()]
for k in f2:
    str2+=k
str2=f2.lower()
num=0
for i in l:
    if i in str2:
        num=str2.find(i)
        print(num)
        if num!=-1:
            str2=str2[0:num]+'<'+i+'>'+str2[num:num+len(i)]+'</>'+str2[num+len(i)::1]
print(str2)

6530155221
# 1664643, 2022-10-29 10:42:00, ----- (0%)

fc = open(input())
fm = open(input())
for line in fc :
    d = line.strip().split()
    


6530166121
# 1664538, 2022-10-29 10:40:53, xxxxx (0%)

file1 = input().strip(); file2 = input().strip()
fcolor = open(file1, 'r')

lcolor = []; lcolor2 = []
for line in fcolor:
    lcolor.append(line.lower().strip().split())
for l in lcolor:
    for e in l:
        lcolor2.append(e)  ### color list done
fcolor.close()

print(lcolor2)###

fsong = open(file2, 'r')
fsongl = fsong.readlines(); fsongl = [e.strip() for e in fsongl]
print(fsongl) ###


dsent = [e.lower() for e in fsongl]; cindex = [[0]*len(sentence)]
print(dsent)####
for sentence in dsent:
    for i in range(len(cindex)):
        for color in lcolor2:
            if sentence.find(color) != -1:
                cindex.append(sentence.find(color))
        
        
#     for color in lcolor2:
#         if sentence.find(color) != -1:
#             cindex.append(sentence.find(color))
print(cindex)



6530173521
# 1664023, 2022-10-29 10:35:27, ----- (0%)

f = open(input())
for line in f:
  print(line)
f.close()

6530182121
# 1663238, 2022-10-29 10:20:14, ----- (0%)

# file1 = input()
# file2 = input()
# f1 = open(file1,'r')
# f2 = open(file2,'r')
# color = [] ; new = [] ; neww = []
# 
# for i in f1 :
#     i = i.strip().lower()
#     if i != " " :
#         color.append(i.split())
#     for k in range (len(color)) :
#         if color[k] != [] :
#             for a in range (len(color[k])) :
#                 new.append(color[k][a])
#     new.sort()
#     neww = [new[0]]
#     for i in range (len(new)-1) :
#         if new[i] != new[i+1] :
#             neww.append(new[i+1])
#                 
# for i in f2 :
#     for x in i :
#         

6530188021
# 1664399, 2022-10-29 10:39:50, ----- (0%)

x = input()
y = input()
color = open(x,'r')
mus = open(y,'r')
o = []
def white(i,y):
    sol = ''
    b = y.lower()
    n = b.find(i)
    sol += y[:n]
    while b.find(i) != -1:
        k = b.find(i,n+1)
        sol += '<'+i+'>'+x[n:n+len(i)]+'</>'
        if k == -1:
            sol += x[n+len(i):]
        else:
            sol += x[n+len(i):k]
        n = k
    return sol
for line in x:
    q = line[0:-1].split()
    if type(q) == list:
        for i in q:
            o += [i.lower]
    else:
        o += q.lower()
color.close()
for line in y:
    j = line.lower()
    for i in o:
        if j.find(i) != -1:
            line = white(i,line)
        else:pass
    print(line)
mus.close()

        


6530193021
# 1664624, 2022-10-29 10:41:42, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        a = 'True'
    else :
        a = 'False'
        for i in range(len(word)) :
            if word[i] == pattern[i] or pattern[i] == '?' :
                a = 'True'
            else :
                 a = 'False'
                 for i in range(len(pattern)) :
                    if pattern[i] == '?' :
                        if word[i] not in exclude_chars :
                            a = 'True'
                        else :
                             a = 'False'
                             if include_chars != word[:len(include_chars)] :
                                a = 'True'
                             else :
                                 a = 'False'
                        
                            
exec(input()) # DON'T remove this line


6530195321
# 1663600, 2022-10-29 10:27:53, ----- (0%)

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.")
print("Dark<blue>blue</>, <purple>purple</> and <green>green</>.")
print("")
print("I like <white>WHITE</>. I like <red>Red</>.")
print("What's your favorite color?")

6530198221
# 1664421, 2022-10-29 10:40:00, xxxxx (0%)

color = input()
song = input()

c = open(color)
s = open(song)

c1 = c.readlines()
a = []
for i in range(len(c1)) :
    c1[i].lower().strip()
    a.append(c1[i].replace('\n',''))
for l in s :
    for e in range(len(a)) :
        s.replace(a[e],'<'+a[e]+'>'+a[e]+'</>')
print(s.end == '')
        
s.close
c.close


6530199921
# 1663931, 2022-10-29 10:34:04, ----- (0%)

print("<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y.")
print("")

6530205021
# 1662326, 2022-10-29 09:54:30, compilation error (0%)

'''
SECOND_quiz
data.txt
singing.txt
'''

colorbook = input()
song = input()

c = open(colorbook , 'r')
s = open(song , 'r')

color = []
for line in c :
    for a in line.split() :
        color.append(a)
    
newsong = []
for line in s :
    k1 = 0
    for i in color
        while True :
        k2 = line.find('
 



6531316121
# 1664561, 2022-10-29 10:41:02, ----- (0%)

colorfile = open(input(),"r")
color = []
for line in colorfile:
    if len(line) != 0:
        l = line.split()
        for e in l:
            color.append(e.lower())

lyricsfile = open(input(),"r")
for line in lyricsfile:
    m = line.split()
    a = []
    for e in m:
        ans = ""
        wc = ""
        w = ""
        nw = ""
        for ele in e:
            if ele in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ":
                wc += ele.lower()
                w += ele
            else:
                nw += ele
            if wc in color:
                ans += "<" + wc + ">" + w + "</>" + e[-(len(e) - len(wc)):]
                break
        else:
            ans += e
        a.append(ans)
    print(" ".join(a))


6531318421
# 1664270, 2022-10-29 10:38:39, compilation error (0%)

print('<orange>Orange</>, <yellow>yellow</> and <pink>pink</>y. Dark<blue>blue</>, <purple>purple</> and <green>green</>.
I like <white>WHITE</>. I like <red>Red</>. What's your favorite color?')

6531319021
# 1663904, 2022-10-29 10:33:33, ----- (0%)

f1 = input().strip()
f2 = input().strip()
file1 = open(f1,'r')
file2 = open(f2,'r')

colors = []
for line in file1.readlines():
    for i in line.strip().split():
        colors.append(i.lower())


for line in file2.readlines():
    rr = line.split()
    kk = ""
    for i in line:
        if i.isalpha():
            kk+=i.lower()
        elif i == " ":
            kk+=" "
    kk = kk.split()
    for i in colors:
        if i in kk:
            rr[kk.index(i)] = "<"+i+">"+rr[kk.index(i)][:len(i)]+rr[kk.index(i)][len(i):]+"</>"
    print(" ".join(rr))

6531335021
# 1663322, 2022-10-29 10:22:31, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True
exec(input()) # DON'T remove this line


6531019821
# 1664015, 2022-10-29 10:35:23, ----- (0%)

x1 = str(input())
x2 = str(input())
file1 = open(x1)
file2 = open(x2)
color = []
for line in file1:
    x = line.split()
    color += x
if color == []:
    for line in file2:
        print(line)
color1 = []

6531027821
# 1662061, 2022-10-29 09:46:04, ----- (0%)

filename1=input()
filename2=input()
x=open(filename1,"r")
y=open(filename2,"r")

6531101521
# 1664013, 2022-10-29 10:35:22, ----- (0%)

def colorname(filename):
    f = open(filename, 'r')
    color = []
    finalcolor = []
    for i in f.readlines():
        color.append(i.lower().split())
    return finalcolor


color_file = input()
print(colorname(color_file))

6531106721
# 1663630, 2022-10-29 10:28:22, xxxxx (0%)

color=open(input(),"r")
lyric= open (input(),"r")
out=open("out.txt","w")
see=[]
for l in color:
    l=l.split()
    for x in l:
        see.append(x)
def tagsee(c):
    if c.lower() in see.lower():
        return "<"+s.lower()+">"+line[i:i+len(s)]+"</>"
    else:
        return c
for line in lyric:
    for s in see:
        for i in range(len(line)):
            out.write(tagsee(line[i:i+len(s)]))
            
for nn in out:
    print(nn)

6531501921
# 1664290, 2022-10-29 10:38:52, ----- (0%)

c = ''
d = []
word = []
fileColor = open(input(), 'r')
    
for line in fileColor:
    c += ''+ line.lower()
    cLSS = c.lower().strip().split()
    
fileSong = open(input(), 'r')
for line in fileSong :
    for i in range(len(line)) :
        d.append(line[i])
        if d[i] in ',' or' ' or'.':
            word = d[:len(d)-i]

6531704021
# 1664522, 2022-10-29 10:40:46, ----- (0%)

filecolor=input()
filelyric=input()
file=open(filecolor)
filee=open(filelyric)

print(file)
file.close()
filee.close()