Matrix exercise