Given the complete bipartite graph. Each part of this graph has N vertices, i.e. the graph is balanced. An integer number (called a weight) assigns to each vertex. The weight of the edge is defined as the product of weights of vertices which connected by this edge.
It is well known, a matching in a graph is a set of edges without common vertices. A matching is perfect, if it covers all vertices of a graph.
Write a program to find a perfect match of the given bipartite graph with the maximal weight of the matching edges minimal.