@staticmethod
def d_2():
    (n, g, e) = map(int, sys.stdin.readline().split())
    graph = nx.DiGraph()
    graph.add_nodes_from(range((n + 1)))
    for p in [int(x) for x in sys.stdin.readline().split()]:
        graph.add_edge(p, n, capacity=1)
    for _ in range(e):
        (a, b) = map(int, sys.stdin.readline().split())
        graph.add_edge(a, b, capacity=1)
        graph.add_edge(b, a, capacity=1)
    print(nx.minimum_cut_value(graph, 0, n))
@staticmethod
def d_2():
    (n, g, e) = map(int, sys.stdin.readline().split())
    graph = nx.DiGraph()
    graph.add_nodes_from(range((n + 1)))
    for p in [int(x) for x in sys.stdin.readline().split()]:
        graph.add_edge(p, n, capacity=1)
    for _ in range(e):
        (a, b) = map(int, sys.stdin.readline().split())
        graph.add_edge(a, b, capacity=1)
        graph.add_edge(b, a, capacity=1)
    print(nx.minimum_cut_value(graph, 0, n))