<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def print_summary(graph, tails, node_id_map):
 """Print out summary and per-node comparison data."""

    # Get comparison data
    heads = get_heads(tails)
    heights = get_heights(tails)
    max_height = max(heights)
    common_height, block_ids_at_common_height = get_common_height(tails)
    lags = get_lags(heights, max_height)
    common_ancestor = graph.root
    divergences = get_divergences(heights, graph.root)

    # Print summary info
    col_1 = 8
    col_n = 8
    format_str = '{:<' + str(col_1) + '} ' + ('{:<' + str(col_n) + '} ') * 2
    header = format_str.format("COMMON", "HEIGHT", "BLOCKS")
    print(header)
    print("-" * len(header))
    print(format_str.format(
        "ANCESTOR", common_ancestor.num, common_ancestor.ident[:col_n]))
    print(format_str.format(
        "HEIGHT", common_height, str(block_ids_at_common_height)))
    print()

    # Print per-node data
    node_col_width = get_col_width_for_num(len(tails), len("NODE"))
    num_col_width = get_col_width_for_num(max_height, len("HEIGHT"))
    lag_col_width = get_col_width_for_num(max(lags), len("LAG"))
    diverg_col_width = get_col_width_for_num(max(divergences), len("DIVERG"))

    format_str = (
        '{:<' + str(node_col_width) + '} '
        '{:<8} '
        '{:<' + str(num_col_width) + '} '
        '{:<' + str(lag_col_width) + '} '
        '{:<' + str(diverg_col_width) + '}'
    )

    header = format_str.format("NODE", "HEAD", "HEIGHT", "LAG", "DIVERG")
    print(header)
    print('-' * len(header))

    for i, _ in enumerate(tails):
        print(format_str.format(
            node_id_map[i],
            heads[i],
            heights[i],
            lags[i],
            divergences[i],
        ))
    print()