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

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.stream.*;

/* 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
	{
		Set<String> A_Set = new HashSet<>(Arrays.asList("1111", "2222", "5555"));
        Set<String> B_Set = new HashSet<>(Arrays.asList("3333", "4444"));
        Set<String> C_Set = new HashSet<>(Arrays.asList("6666"));
        Set<String> D_Set = new HashSet<>(Arrays.asList("2222", "5555", "6666"));

        Map<String, Set<String>> values = new HashMap<>();
        values.put("A", A_Set);
        values.put("B", B_Set);
        values.put("C", C_Set);
        values.put("D", D_Set);
        
        Map<String, List<Boolean>> exists = values.values()
                .stream()
                .flatMap(Set::stream)
                .distinct()
                .collect(Collectors.toMap(v -> v, v -> Stream.of("A", "B", "C", "D")
                        .map(k -> values.get(k).contains(v))
                        .collect(Collectors.toList())));
                        
		System.out.println(exists);
	}
}