I = input().split() R = input().split() Icount = int(I[0]) Rcount = int(R[0]) I.pop(0) R.pop(0) Rr = list(map(str, sorted(list(set(list(map(int, R))))))) temp = [] result = [] countList = [] count = 0 for i in Rr: for j, v in enumerate(I): if i in v: temp.append(str(j)) temp.append(v) count += 1 if count != 0: temp.insert(0, str(count)) temp.insert(0, i) count = 0 result.append(temp) temp = [] num = 0 for n in result: num = num + int(n[1]) num = (num + len(result)) * 2 print(num, end=" ") for s in result: print(" ".join(s), end=" ")