def longest_leg(all_amounts):
    """
    Find the longest leg between amounts.

    Args:
        all_amounts: list of amounts.
    Returns:
        index of logest leg.
    """
    firsts = []
    for amounts in all_amounts:
        if len(amounts) == 0:
            firsts.append(0)
        else:
            firsts.append(abs(amounts[0]))
    return firsts.index(max(firsts))
