def GreedyMatching(edges, max_count: int):
    """Find matching greedily.
       Edges are picked sequentially from top of input.
       So, useful for greedy matching with weights as well."""
    M = set()
    matched_nodes = set()
    for u, v in edges:
        if u not in matched_nodes and v not in matched_nodes:
            matched_nodes.add(u)
            matched_nodes.add(v)
            M.add((u, v))
            if len(M) == max_count:
                return M
    return M