require'mathn' (a,b=chomp.map{|$_|split(' ').map{|$_|split.map &:to_i}}.transpose;puts [*(m=Matrix)[*a]*m[*b]].map{|x|x*' '},$/)while gets''