def fitness_function(items, m):
    """Return sum of cost for child if weight < m otherwise return 0."""
    cost = 0
    weight = 0
    for key, is_selected in items.items():
        if is_selected:
            weight += key[1]
            cost += key[0]
    res = cost if weight <= m else 0
    return res