def hexKeyToBin(counts, n_qubits):
    """Generates binary representation of a hex based counts
    Derived from https://sarangzambare.github.io/jekyll/update/2020/06/13/quantum-frequencies.html
    Args:
        counts (dict): dictionary with hex keys
        n_qubits (int): number of qubits

    Returns:
        dict: dictionary with bin keys
        n_qubits (int): number of qubits
    """
    out = dict()
    for key, value in counts.items():
        out[format(int(key,16), f'0{int(n_qubits)}b')] = value
    return out, n_qubits