def splitanswertolists(answer):
    """Split 'answer' into tuple (items, values) of lists.
    @param answer : String "item1 item2 ... = val1 val2 ...<LF>" or single "value".
    @return : Tuple ([[item1], [item2], ...], [[val1, val2, ...]]) or (None, [[values]]).
    """
    answer = answer.split('\n')
    if '=' in answer[0]:
        itemdim = len(answer[0].split('=')[0].split())
        items = [[] for _ in range(itemdim)]  # do not use [[]] * itemdim
    else:
        return None, [[x.strip() for x in answer]]
    values = []
    for line in answer:
        line = line.strip()
        if not line:
            continue
        itemvals = line.split('=')[0].split()
        for dim in range(itemdim):
            items[dim].append(itemvals[dim])
        values.append(line.split('=')[1].split())
    return items, values