bipartite graph problem