<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def paint(self, text, x, y, colour=7, attr=0, bg=0, transparent=False, colour_map=None):
 """ Paint multi-colour text at the defined location. :param text: The (single line) text to be printed. :param x: The column (x coord) for the start of the text. :param y: The line (y coord) for the start of the text. :param colour: The default colour of the text to be displayed. :param attr: The default cell attribute of the text to be displayed. :param bg: The default background colour of the text to be displayed. :param transparent: Whether to print spaces or not, thus giving a transparent effect. :param colour_map: Colour/attribute list for multi-colour text. The colours and attributes are the COLOUR_xxx and A_yyy constants defined in the Screen class. colour_map is a list of tuples (foreground, attribute, background) that must be the same length as the passed in text (or None if no mapping is required). """

        if colour_map is None:
            self.print_at(text, x, y, colour, attr, bg, transparent)
        else:
            offset = 0
            for c, m in zip_longest(text, colour_map):
                if m:
                    if len(m) > 0 and m[0] is not None:
                        colour = m[0]
                    if len(m) > 1 and m[1] is not None:
                        attr = m[1]
                    if len(m) > 2 and m[2] is not None:
                        bg = m[2]
                if c:
                    self.print_at(c, x + offset, y, colour, attr, bg, transparent)
                    offset += wcwidth(c) if ord(c) >= 256 else 1