def z_to_y(mdrrt, z):
    """convert z into y according to target mdrrt.

    This method achieve the conversion of y into z.
    This is (7) in the paper.

    Args:
        mdrrt (MDRRT): target MDRRT
        z (pyqubo.array.Array): decision variable z

    Returns:
        list<list<pyqubo.Binary>>: decision variable y
    """
    n = mdrrt.n
    S = mdrrt.num_slots

    y = []
    for t in range(2 * n):
        row = []
        for s in range(S):
            # index (t, s) is on row k and line j. (3) in the paper.
            k, j = mdrrt.unpack_ts_dict[t, s]

            # the conversion of z to y. (7) in the paper
            if j in [0, 3]:
                row.append(z[k])
            else:
                row.append(1 - z[k])
        y.append(row)
    return y