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

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

/* 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
    {
        List<Map<String,List<String>>> list=new ArrayList<>();
        Map<String,List<String>> map1=new HashMap<>();
        map1.put("1", Arrays.asList(new String[] {"A"}));
        map1.put("2", Arrays.asList(new String[] {"B"}));

        Map<String,List<String>> map2=new HashMap<>();
        map2.put("1", Arrays.asList(new String[] {"C"}));
        map2.put("2", Arrays.asList(new String[] {"D"}));
        list.add(map1);
        list.add(map2);

        Map<String, List<String>> result = new HashMap<>();
        result.put("1", list.stream()
            .filter(e -> e.containsKey("1"))
            .flatMap(e -> e.values().stream())
            .flatMap(List::stream)
            .collect(Collectors.toList()));
        Map<String, List<String>> result2 = list.stream()
            .filter(e -> e.containsKey("1"))
            .flatMap(e -> e.values().stream())
            .flatMap(List::stream)
            .collect(Collectors.groupingBy(t -> "1"));

        System.out.println(result.equals(result2));
    }

}