library(Matrix) a <- queens(8) as(a[, 1], "pMatrix")