Finish output first grant matrix code