def decode_literal(packet):
    """Decode a literal packet"""
    i = 0
    value = ''
    while True:
        group = packet[i:i+5]  # each group has 5 bits
        value += group[1:]  # the value is contained in the last 4 bits
        i += 5
        if group[0] == '0':
            break  # the last section is prefixed with a 0 bit
    sub_packet = packet[i:]
    return sub_packet, int(value, 2)