connected 1s in matrix