翻译自 NordicOI 2023 A 题 ChatNOI。
你正在和你的机器人玩一个对话游戏,规则是这样的:
首先给定一个包含了 个字符串的仅含小写字符串组 和一个数字 。
定义一个字符串组的质量为其每个长度为 的连续段的在 中出现的次数的最小值。
有 次询问,每次给定 与 个字符串。
你需要构造 个字符串,使得在给出的 个字符串后依次加入构造的 个字符串形成的字符串组质量最大。
若有多解,只需输出任意一个。
第一行一个整数 和 。
第二行一句包含 个单词的句子 。
第三行一个整数 ,表示一共有 次询问。
然后 行,每行一个数 和长度为 的 的子字符串。
你需要对于每个询问,输出 之后的 个单词。
13 2 ullen dullen doff kikke lane koff koffe lane bikke bane ullen dullen doff 3 1 ullen dullen 2 ullen dullen 3 ullen dullen
doff doff kikke doff kikke lane
8 1 buffalo buffalo buffalo buffalo buffalo buffalo buffalo buffalo 1 7 buffalo
buffalo buffalo buffalo buffalo buffalo buffalo buffalo
16 1 have you not heard about the bird the bird bird bird the bird is the word 8 1 have 1 you 1 not 1 heard 1 about 1 the 1 bird 1 is
you not heard about the bird bird the
本题采用捆绑测试。
令 。
对于所有测试数据,,,,。