def METHOD_NAME(qubits, depth, p_had=0.5):
    random.seed(0)
    c = Ket(*(qubits * [0]))
    for _ in range(depth):
        r = random.random()
        if r > p_had:
            c = c.H(random.randrange(qubits))
        else:
            tgt = random.randrange(qubits)
            while True:
                ctrl = random.randrange(qubits)
                if ctrl != tgt:
                    break
            c = c.CX(tgt, ctrl)
    return c