Codium interview question

connected components in graph after switchiing entire row or column