def hanoi(n):
    moves = []
    def transfer(count, source, target, spare):
        if count == 0:
            return
        transfer(count - 1, source, spare, target)
        moves.append((source, target))
        transfer(count - 1, spare, target, source)
    transfer(n, 'A', 'C', 'B')
    return moves
