io.write((function (f, g, fh, i) local n,m,h,r = fh:read("*n"),fh:read("*n"),{},{} for _=1,n do f(h,fh:read("*n")) end for _=1,m-1 do i(r,g(h,fh:read("*n")))i(r," ") end i(r,g(h,fh:read("*n")))i(r,"\n") return unpack(r) 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, table.insert))