def get_interaction(element_1, element_2, matrix_dimension):
    """Gets singular interaction between 2 elements of an ising matrix and returns the hamiltonion

    Args:
        element_1 ([int, int]): x, y coordinate of element 1 on the ising matrix
        element_2 ([int, int]): x, y coordinate of element 2 on the ising matrix
        matrix_dimension ([int, int]): Tuple representing the height, width of the ising matrix

    Example:
        element_1 : [1, 0]
        element_2 : [2, 0]
        matrix_dimension : 3, 3

        output : ( I^I^I ^ Z^I^I ^ Z^I^I )
        ___________________^_______^
        [1, 0] + [2, 0]

    Returns:
        str: Hamiltonian representing the singular interaction
    """
    output = []
    (tR, tC) = matrix_dimension
    (R1, C1) = element_1
    (R2, C2) = element_2
    if (-1 in element_1) or (-1 in element_2) or (tR in [R1, R2]) or (tC in [C1, C2]):
        # Return empty, for outside bounds in edge cases
        return ""

    for _ in range(tR):
        R = []
        for _ in range(tC):
            R += ["I"]
        output += [R]
    R, C = element_1
    output[R][C] = "Z"
    R, C = element_2
    output[R][C] = "Z"
    output = "^".join(["^".join([R for R in C]) for C in output])
    return f"({output})"