import java.util.*;
public class Main { /* 数据分类处理 输入: 15 123 456 786 453 46 7 5 3 665 453456 745 456 786 453 123 5 6 3 6 3 0 输出: 30 3 6 0 123 3 453 7 3 9 453456 13 453 14 123 6 7 1 456 2 786 4 46 8 665 9 453456 11 456 12 786 说明: 将序列R:5,6,3,6,3,0(第一个5表明后续有5个整数)排序去重后,可得0,3,6。 序列I没有包含0的元素。 序列I中包含3的元素有:I[0]的值为123、I[3]的值为453、I[7]的值为3、I[9]的值为453456、I[13]的值为453、I[14]的值为123。 序列I中包含6的元素有:I[1]的值为456、I[2]的值为786、I[4]的值为46、I[8]的值为665、I[9]的值为453456、I[11]的值为456、I[12]的值为786。 最后按题目要求的格式进行输出即可 */ public static void main(String[] args) { Scanner in = new Scanner(System.in); String l1 = in.nextLine(); String l2 = in.nextLine(); String[] i = l1.split(" "); String[] r = l2.split(" "); LinkedHashSet rset = new LinkedHashSet<>(); ArrayList rlist = new ArrayList<>();
for (int j = 1; j < r.length; j++) {
String s = r[j];
rset.add(s);
}
for (String s : rset) {
int i1 = Integer.parseInt(s);
rlist.add(i1);
}
Collections.sort(rlist);
StringBuilder sb2 = new StringBuilder();
for (Integer rr : rlist) {
StringBuilder sb = new StringBuilder();
int count = 0;
for (int k = 1; k < i.length; k++) {
String s = i[k];
if(s.contains(rr.toString())){
sb.append((k-1)+" "+s+" ");
count++;
}
}
if(count > 0){
sb2.append(rr+" "+count+" "+sb.toString());
}
}
String[] s = sb2.toString().split(" ");
int length = s.length;
System.out.println(length+" "+sb2.toString());
} }