Direct sums and direct products of canonical pencils of matrices