Cherry has a string S$S$ consisting of lowercase English letters. Using this string, he formed a pyramid of infinite length with certain rules:
- N$N$-th row of pyramid contains N$N$ characters.
- Each row of pyramid begins with the first character of the string.
- The subsequent characters of the row are appended to the string in cyclic fashion, until the size of string for that Row is reached (See example pyramid for better understanding).
He has another string T$T$ of smaller (or equal) size.
You are asked Q$Q$ queries. Each query is provided with a row number N$N$. The answer to the query is number of occurrences of string T$T$ in that particular row of pyramid. No of occurrences of String T$T$ in a string V$V$ would mean that you'd need to find number of substrings Vi,Vi+1...Vj$V_i, V_{i+1} ... V_j$ which are equal to String T$T$, where i≤j$i \leq j$.
For eg: If the string is code, then the pyramid will be of the form:
c
co
cod
code
codec
codeco
codecod
codecode
codecodec
codecodeco
...

-----Input:-----
- The first line contains string S$S$ — consisting of lowercase English letters.
- The second line contains string T$T$ — consisting of lowercase English letters.
- Next line contains an integer Q$Q$ — the number of queries.
- Then follow Q$Q$ lines with queries descriptions. Each of them contains a single integer N$N$ denoting the row number of pyramid.

-----Output:-----
- Print Q$Q$ lines. The i$i$-th of them should contain a integer denoting occurrences of string T$T$ in that particular row.

-----Constraints-----
- 1≤|S|≤105$1 \leq |S| \leq 10^5$
- 1≤|T|≤|S|$1 \leq |T| \leq |S|$
- 1≤Q≤105$1 \leq Q \leq 10^5$
- 1≤N≤109$1 \leq N \leq 10^9$

-----Sample Input:-----
codechef
chefcode
3
4
12
1455

-----Sample Output:-----
0
1
181

-----Explanation:-----
Pyramid will be formed as explained in the statement.
Query 1: Row number 4 of the pyramid is code. The number of occurrences of chefcode in code is 0.
Query 2: Row number 12 of the pyramid is codechefcode. The number of occurrences of chefcode in codechefcode is 1.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'def search(arr, lenl, val):\n    s = 0\n    l = lenl - 1\n\n    total = 0\n\n    while (s <= l):\n        m = int((s + l) / 2)\n\n        if (arr[m] <= val):\n            total = m + 1\n            s = m + 1\n\n        else:\n            l = m - 1\n\n    return total\n\n\ndef kmpsearch(string, lps):\n    lis = []\n    lens = len(string)\n    lensh = lens // 2\n\n    l = 0\n    i = 0\n    while i < lens:\n        if string[i] == pat[l]:\n            l += 1\n            i += 1\n        elif l > 0:\n            l = lps[l - 1]\n        else:\n            i += 1\n\n        if l == lenp:\n            if i - l < lensh:\n                lis.append(i - l)\n\n            l = lps[l - 1]\n\n    return lis\n\n\ndef kmp(pat, lenp):\n\n    lps = [0]*(lenp)\n    l = 0\n    i = 1\n\n    while i < lenp:\n        if pat[i] == pat[l]:\n            l += 1\n            lps[i] = l\n            i += 1\n        elif l > 0:\n            l = lps[l-1]\n        else:\n            lps[i] = 0\n            i += 1\n\n    return lps\n\n\n\nkeyword = input()\npat = input()\nq = int(input())\n\nlenk = len(keyword)\nlenp = len(pat)\n\nk = keyword * 2\nlis = kmpsearch(k, kmp(pat, lenp))\nlenl = len(lis)\n\nfor _ in range(q):\n    n = int(input())\n    count = 0\n\n    q = n // lenk\n    r = n % lenk\n\n    count += search(lis, lenl, r - lenp)\n\n    if q >= 1:\n        count += search(lis, lenl, lenk + r - lenp)\n\n    if q >= 2:\n        count += (q - 1)*lenl\n\n    print(count)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13651