<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_with_mac(self, data, block):
 """Write one data block with additional integrity check. If prior to calling this method the tag was not authenticated, a :exc:`RuntimeError` exception is raised. Command execution errors raise :exc:`~nfc.tag.TagCommandError`. """

        # Write a single data block protected with a mac. The card
        # will only accept the write if it computed the same mac.
        log.debug("write 1 block with mac")
        if len(data) != 16:
            raise ValueError("data must be 16 octets")
        if type(block) is not int:
            raise ValueError("block number must be int")
        if self._sk is None or self._iv is None:
            raise RuntimeError("tag must be authenticated first")

        # The write count is the first three byte of the wcnt block.
        wcnt = str(self.read_without_mac(0x90)[0:3])
        log.debug("write count is 0x{0}".format(wcnt[::-1].encode("hex")))

        # We must generate the mac_a block to write the data. The data
        # to encrypt to the mac is composed of write count and block
        # numbers (8 byte) and the data we want to write. The mac for
        # write must be generated with the key flipped (sk2 || sk1).
        def flip(sk):
            return sk[8:16] + sk[0:8]

        data = wcnt + "\x00" + chr(block) + "\x00\x91\x00" + data
        maca = self.generate_mac(data, flip(self._sk), self._iv) + wcnt+5*"\0"

        # Now we can write the data block with our computed mac to the
        # desired block and the maca block. Write without encryption
        # means that the data is not encrypted with a service key.
        sc_list = [tt3.ServiceCode(0, 0b001001)]
        bc_list = [tt3.BlockCode(block), tt3.BlockCode(0x91)]
        self.write_without_encryption(sc_list, bc_list, data[8:24] + maca)