def apply(v, *gates):
    m = gates[0]
    gates = gates[1:]
    for gate in gates:
        m = np.kron(gate, m)
    return m.dot(v)
def apply(v, *gates):
    m = gates[0]
    gates = gates[1:]
    for gate in gates:
        m = np.kron(gate, m)
    return m.dot(v)