r=io.read x=r()while""do print(#x:gsub(r().." .*",1):gsub("%a",""))end