/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import static java.util.stream.Collectors.*;
import java.util.List;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
	 Map<String, List<Integer>> mapOfIntList = new HashMap<String, List<Integer>>();

        mapOfIntList.put("UNIT", Arrays.asList(1, 2, 3, 8, 7, 0, 8, 6));
        mapOfIntList.put("TEN", Arrays.asList(24, 90, 63, 87));
        mapOfIntList.put("HUNDRED", Arrays.asList(645, 457, 306, 762));
        mapOfIntList.put("THOUSAND", Arrays.asList(1234, 3456, 5340, 9876));


        Map<Integer, String> collect = mapOfIntList.entrySet()
                .stream()
                .flatMap(e -> e.getValue().stream().map(s -> new AbstractMap.SimpleEntry<>(s, e.getKey())))
                .collect(toMap(AbstractMap.SimpleEntry::getKey,
                        AbstractMap.SimpleEntry::getValue,
                        (l, r) -> l));

        System.out.println(collect);
	}
}