Generics in matrix