Cost of removal
An undirected graph is provided, which contains no loops or multiple edges. The vertices in this graph are categorized into two types: black and white. A black vertex will disappear if it has no adjacent white vertices, and similarly, a white vertex will vanish if it has no adjacent black vertices. Each vertex has a known removal cost. Your task is to determine the minimum cost required to remove all vertices from the graph.
Input
The input begins with two integers, n and k: the number of vertices and the number of edges in the graph, respectively, where 1 ≤ n ≤ 100 and 0 ≤ k ≤ n · (n - 1) / 2. This is followed by n lines, each containing two integers, t and c. Here, t indicates the type of the vertex (0 for white, 1 for black), and c represents the cost of removing that vertex, with 1 ≤ c ≤ 10^6
. After this, k lines follow, each containing two integers, a and b, which specify the vertices connected by an edge, where 1 ≤ a, b ≤ n.
Output
The output should be a single integer representing the minimum cost to remove all vertices from the graph.