find the number of group in 1-0 matrix using BFS