import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String data = sc.nextLine();
            String sequence = sc.nextLine();
            String[] dataArr = data.split(" ");
            String[] sequenceArr = sequence.split(" ");

            List<Integer> list = new ArrayList<>();
            for (int i = 1; i < sequenceArr.length; i++) {
                int seq = Integer.parseInt(sequenceArr[i]);
                if(!list.contains(seq)) {
                    list.add(Integer.parseInt(sequenceArr[i]));
                }
            }
            Object[] seqArr = list.toArray();
            Arrays.sort(seqArr);

            int count = 0;
            String result = "";
            for (int i = 0; i < seqArr.length; i++) {
                StringBuilder sb = new StringBuilder();
                String seq = String.valueOf(seqArr[i]);
                int matchCount = 0;
                for (int j = 1; j < dataArr.length; j++) {
                    String number = dataArr[j];
                    if (number.contains(seq)) {
                        sb.append(" " + (j - 1) + " " + number);
                        count += 2;
                        matchCount++;
                    }
                }
                if (matchCount > 0) {
                    sb.insert(0, " " + seq + " " + matchCount);
                    count += 2;
                }
                result += sb.toString();
            }
            System.out.println(count + result);

        }
        sc.close();
    }

}