Matrices are arranged as vertical and horizontal lines and the entrances are made in columns and rows by the method…