def _apply_modifiers(intervals, modifiers):
    """ Given a set of tuple intervals and a set of modifiers, adjusts the intervals accordingly"""
    for i in range(len(intervals) - 1, -1, -1):
        for j in range(len(modifiers) - 1, -1, -1):
            if intervals[i][0] == modifiers[j][0]:
                if modifiers[j][1] == -1:
                    intervals.pop(i)
                    modifiers.pop(j)
                    break
                else:
                    intervals[i] = modifiers[j]
                    modifiers.pop(i)
                    break
    for modifier in modifiers:
        intervals.append(modifier)
    return intervals
