if __name__ == '__main__':
    # 读取数据
    intSeries = list(map(int, input().strip().split()))
    ruleSeries = list(map(int, input().strip().split()))
    intLen = intSeries[0]
    intSeries = intSeries[1:]  # 截取属于数据部分 (去掉第一个代表长度的元素)
    ruleLen = ruleSeries[0]
    ruleSeries = ruleSeries[1:]  # 截取属于数据部分 (去掉第一个代表长度的元素)

    ruleSeries.sort()  # 排序
    ans = []  # 保存答案
    for i in range(len(ruleSeries)):
	    # 如果是重复的元素则不用考虑
        if i > 0 and ruleSeries[i] == ruleSeries[i - 1]:
            continue
		# 得到规则
        rule = str(ruleSeries[i])
		# 计算当前匹配规则 rule 下能够在 intSeries 上找到多少个答案
        cnt = 0
        matched = []  # 保存匹配到的 intSeries 元素
        for j in range(len(intSeries)):
            s = str(intSeries[j])
			# 在 intSeries 元素 s 中查找 rule
			# 如果找不到会返回 -1
            begin = s.find(rule)
            if begin != -1:
                cnt += 1
				# 将答案加到匹配数组中去
                matched.append(str(j))
                matched.append(s)
        if cnt > 0:
            ans.append(rule)
            ans.append(str(cnt))
            ans.extend(matched)
	# 答案输出
    print(len(ans), end=' ')
    print(' '.join(ans))