(function (f, g, fh) local n,m,h = fh:read("*n"),fh:read("*n"),{} for _=1,n do f(h,fh:read("*n")) end for _=1,m-1 do io.write(g(h,fh:read("*n"))," ") end io.write(g(h,fh:read("*n")),"\n") end)(function (h, k) h[k] = h[k]~=nil and h[k]+1 or 1 end, function (h, k) return h[k]~=nil and h[k] or 0 end, io.stdin)