CF1881A Don't Try to Count

题目描述

给定一个长度为 $n$ 的字符串 $x$,长度为 $m$ 的字符串 $s$,你可以进行下列操作: - 将 字符串 $x$ 复制到字符串 $x$末尾。 例:`aba` $->$ `abaaba` $->$ `abaabaabaaba`。 询问最少进行多少次操作字符串 $s$ 为字符串 $x$ 的子串。

输入格式

输入的第一行包含一个整数 $t$,表示 $t$ 组数据。 每组数据第一行,包含两个数字 $n$ 和 $m$,分别表示字符串 $x$ 和 $s$ 的长度。 每组数据的第二行包含长度为 $n$ 的字符串 $x$。 每组数据的第三行包含长度为 $m$ 的字符串 $s$。

输出格式

对于每组数据,输出一个数字,表示字符串$s$作为子串 出现在 $x$ 中的最小操作数。如果不可能,则输出 $-1$。

说明/提示

In the first test case of the example, after $ 2 $ operations, the string will become "aaaa", and after $ 3 $ operations, it will become "aaaaaaaa", so the answer is $ 3 $ . In the second test case of the example, after applying $ 1 $ operation, the string will become " $ \text{e}\color{red}{\text{force}}\text{forc} $ ", where the substring is highlighted in red. In the fourth test case of the example, it can be shown that it is impossible to obtain the desired string as a substring.