E. Binary Matrixtime limit per test3 secondsmemory limit per test16 megabytesinputstandard inputoutputstandard outputYou are given a matrix of size n m. Each element of the matrix is either 1 or 0. You have to determine the number of connected component…