def gm_put(state, b1, b2):
    """
    If goal is ('pos',b1,b2) and we're holding b1,
    Generate either a putdown or a stack subtask for b1.
    b2 is b1's destination: either the table or another block.
    """
    if b2 != 'hand' and state.pos[b1] == 'hand':
        if b2 == 'table':
            return [('a_putdown', b1)]
        elif state.clear[b2]:
            return [('a_stack', b1, b2)]