Implement a task processor for a sequence of operations. Each task has a unique `id`, an integer `deadline`, and an optional list `subtasks` containing task ids that must be consumed first.
A task is eligible to be consumed only when all task ids listed in its `subtasks` have already been consumed. Among all currently eligible tasks, `consume` must remove and return the task with the smallest deadline. If multiple eligible tasks have the same deadline, return the smaller `id`. If no task is currently eligible, return `None`.
Tasks may be added in any order, including before the tasks they depend on are added. Your function should process all operations in order and return a list containing the result of each `consume`.
Examples
Input: [('add', {'id': 1, 'deadline': 2, 'subtasks': [2]}), ('add', {'id': 2, 'deadline': 4, 'subtasks': []}), ('consume',), ('consume',), ('consume',)]
Expected Output: [2, 1, None]
Explanation: Task 1 is blocked until task 2 is consumed.
Input: [('add', {'id': 1, 'deadline': 2, 'subtasks': []}), ('add', {'id': 3, 'deadline': 2, 'subtasks': []}), ('add', {'id': 2, 'deadline': 1, 'subtasks': [3]}), ('consume',), ('consume',), ('consume',)]
Expected Output: [1, 3, 2]
Explanation: Task 2 has the smallest deadline but is blocked. Between eligible tasks 1 and 3, the smaller id is consumed first.
Input: [('add', {'id': 1, 'deadline': 1, 'subtasks': [2]}), ('add', {'id': 2, 'deadline': 2, 'subtasks': [1]}), ('consume',)]
Expected Output: [None]
Explanation: Both tasks are blocked by a cycle, so nothing is eligible.
Input: [('add', {'id': 5, 'deadline': 10, 'subtasks': [6]}), ('consume',), ('add', {'id': 6, 'deadline': 1, 'subtasks': []}), ('consume',), ('consume',)]
Expected Output: [None, 6, 5]
Explanation: The first consume fails because task 5 depends on task 6, which is added later.
Input: []
Expected Output: []
Explanation: No operations means no consume results.