You are given a string s.
Among the different substrings of s, print the K-th lexicographically smallest one.
A substring of s is a string obtained by taking out a non-empty contiguous part in s.
For example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.
Also, we say that substrings are different when they are different as strings.
Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.

-----Constraints-----
 - 1 ≤ |s| ≤ 5000
 - s consists of lowercase English letters.
 - 1 ≤ K ≤ 5
 - s has at least K different substrings.

-----Partial Score-----
 - 200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.

-----Input-----
Input is given from Standard Input in the following format:
s
K

-----Output-----
Print the K-th lexicographically smallest substring of K.

-----Sample Input-----
aba
4

-----Sample Output-----
b

s has five substrings: a, b, ab, ba and aba.
Among them, we should print the fourth smallest one, b.
Note that we do not count a twice.
[{"code": "import sys\nstdin=sys.stdin\n\nip=lambda: int(sp())\nfp=lambda: float(sp())\nlp=lambda:list(map(int,stdin.readline().split()))\nsp=lambda:stdin.readline().rstrip()\nyp=lambda:print('Yes')\nnp=lambda:print('No')\n\ns=list(sp())\nk=ip()\n\nans=set()\n\nalpa=list(set(s))\nalpa.sort()\nch=0\nsiyou=[]\nfor i in range(len(alpa)):\n  if i<=2:\n    siyou.append(alpa[i])\n  else:\n    break\n    \nfor x in siyou:\n  for i in range(len(s)):\n    if s[i]==x:\n      st=''\n      for y in range(i,i+5):\n        if y<len(s):\n          st+=s[y]\n          ans.add(st)\n  if len(ans)>k:\n    break\n  \nans=list(ans)\nans.sort()\nprint(ans[k-1])\n    \n\n\n", "passed": true, "time": 0.16, "memory": 14332.0, "status": "done"}, {"code": "s=input()\nK=int(input())\n\nif K==1:\n  print(sorted(s)[0])\n  return\n  \ntopK = sorted(s)[:min(K,len(s))]\n\nindices=[]\nfor i in range(len(s)):\n  if s[i] in topK:indices.append(i)\n    \nselected=[]\nfor j in range(len(indices)):\n  i = indices[j]\n  tmp=[]\n  for k in range(min(K,len(s)-i)):\n    tmp.append(s[i:i+k+1])\n  selected.extend(tmp)\n  \nselected = sorted(set(selected))\n\nprint(selected[K-1])", "passed": true, "time": 0.16, "memory": 14168.0, "status": "done"}, {"code": "import sys\nfrom collections import defaultdict\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n    return sys.stdin.readline().strip()\n\n\ndef main():\n    S = input()\n    N = len(S)\n    K = int(input())\n\n    places = defaultdict(list)\n    for i in range(N):\n        places[S[i]].append(i)\n\n    places = sorted(list(places.items()), key=lambda x: x[0])\n    words = set()\n    for k, v in places:\n        for start in v:\n            cnt = 0\n            for end in range(start + 1, N + 1):\n                words.add(S[start:end])\n                cnt += 1\n\n                if cnt == 5:\n                    break\n\n        if len(words) >= 5:\n            break\n\n    words = sorted(words)\n    print((words[K - 1]))\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.36, "memory": 13892.0, "status": "done"}, {"code": "s =input()\nk = int(input())\n\nls = len(s)\n\nres =[]\n\nfor i in range(1,k+1):\n    for j in range(ls-i+1):\n        res.append(s[j:j+i])\n        \nress = sorted(list(set(res)))\nprint(ress[k-1])", "passed": true, "time": 0.15, "memory": 14232.0, "status": "done"}, {"code": "# C - K-th Substring\n\ns = str(input())\nK = int(input())\n\nstr_list = set()\nfor i in range(len(s)+1):\n    for j in range(i+1, i+K+1):\n        if j > len(s):\n            break\n        str_list.add(s[i:j])\n\nstr_list = list(str_list)\nstr_list.sort()\nprint((str_list[K-1]))\n\n", "passed": true, "time": 1.9, "memory": 14180.0, "status": "done"}, {"code": "s = input()\nk = int(input())\na = []\n\nfor i in range(len(s)):\n    for j in range(i+1, len(s)+1):\n        if j - i >= 6:\n            break\n        a.append(s[i:j])\n\nres = sorted(set(a))\nprint(res[k-1])", "passed": true, "time": 0.15, "memory": 14376.0, "status": "done"}, {"code": "s = input()\nn = len(s)\nk = int(input())\nl = set()\n\nfor i in range(n):\n    for j in range(1, 6):\n        if i + j <= n:\n            l.add(s[i: i + j])\n\nl = sorted(l)\nprint(l[k - 1])", "passed": true, "time": 0.2, "memory": 14240.0, "status": "done"}, {"code": "s = input()\nl = len(s)\nk = int(input())\nA = set()\nfor i in range(l):\n    for j in range(1, 6):\n        if i+j <= l:\n            A.add(s[i:i+j])\nANS = sorted(A)\nprint((ANS[k-1]))\n", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n\ndata = set()\nfor i in range(len(s)):\n    for j in range(i, i + k):\n        data.add(s[i: j + 1])\ndata = sorted(data)\nprint(data[k - 1])", "passed": true, "time": 0.15, "memory": 14148.0, "status": "done"}, {"code": "s = input()\nK = int(input())\n\nS = set([])\nfor i in range(len(s)):\n    for j in range(i + 1, i + 1 + K):\n        # print(f'{s[i:j]=}')\n        S.add(s[i:j])\n# print(f'{S=}')\n# print(f'{sorted(S)=}')\nans = sorted(S)[K - 1]\nprint(ans)\n", "passed": true, "time": 0.17, "memory": 14212.0, "status": "done"}, {"code": "S = input()\nk = int(input())\nabc = []\nfor i in range(len(S)):\n    for j in range(1, k+1):\n        if i+j <= len(S):\n            s = S[i:i+j]\n            if not s in abc:\n                abc.append(S[i:i+j])\n    \nabc = sorted(abc)\nprint((abc[k-1]))\n", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "S = input()\nN = len(S)\nK = int(input())\ntop_k = []\nfor i in range(N):\n    for j in range(i + 1, min([i + K, N]) + 1):\n            st = S[i:j]\n            top_k.append(st)\n            if len(top_k) > K:\n                top_k = list(set(top_k))\n                top_k.sort()\n                top_k = top_k[:K]\ntop_k.sort()\nprint(top_k[-1])", "passed": true, "time": 0.18, "memory": 14284.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nseen = set()\ni = 1\n \nwhile i<=k:\n  for j in range(len(s)):\n    seen.add(s[j:j+i])\n  i += 1\n \nprint(sorted(seen)[k-1])", "passed": true, "time": 0.23, "memory": 14240.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n\nsubs = set()\nfor i in range(len(s)):\n    for j in range(i+1, min(i+6, len(s) + 1)):\n        sub = s[i:j]\n        subs.add(sub)\n\nprint((sorted(list(subs))[k-1]))\n", "passed": true, "time": 0.31, "memory": 14196.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nn = len(s)\nsubst = set()\nfor i in range(n):\n    for j in range(5):\n        subst.add(s[i:i+j+1])\nls = list(subst)\nls.sort()\nprint((ls[k-1]))\n", "passed": true, "time": 0.2, "memory": 14020.0, "status": "done"}, {"code": "def main():\n    s = input()\n    K = int(input())\n    r = set()\n    for i in range(97, 97 + 26):\n        for j, v in enumerate(s):\n            if v == chr(i):\n                for k in range(5):\n                    r.add(s[j:j+k+1])\n        if len(r) > 5:\n            break\n    l = list(r)\n    l.sort()\n    return l[K-1]\nprint((main()))\n", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "# input\ns = input()\nK = int(input())\n\n# check\ncase = []\nappend = case.append\nfor i in range(1, K + 1):\n    for idx in range(0, len(s) - (i - 1)):\n        if s[idx:idx + i] not in case:\n            append(s[idx:idx + i])\ncase.sort(reverse=True)\n\nprint(case[-K])", "passed": true, "time": 0.16, "memory": 14164.0, "status": "done"}, {"code": "# Python3 (3.4.3)\nimport sys\ninput = sys.stdin.readline\n\n# -------------------------------------------------------------\n# function\n# -------------------------------------------------------------\n\n\n# -------------------------------------------------------------\n# main\n# -------------------------------------------------------------\nS = input().rstrip()\nK = int(input())\n\nAns = []\nfor k in range(5):\n    for i in range(len(S)-k):\n        s = S[i:i+k+1]\n        if s not in Ans:\n            Ans.append(s)\n\nAns.sort()\nprint(Ans[K-1])", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "s=input()\nk=int(input())\nr=set()\n\nfor i in range(1,6):\n    for j in range(len(s)-i+1):\n        r.add(s[j:j+i])\nl=list(r)\nl=sorted(l)\nprint(l[k-1])", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "import sys\ns = input()\nK = int(input())\n\na_list = sorted(set(s))\nfor i in a_list:\n  if K == 1:\n    print(i)\n    return\n  p = []\n  for j, x in enumerate(s):\n    if x == i:\n      p.append(s[j:min(j+K,len(s))])\n  p.sort()\n  t = K\n  for j in range(len(p)):\n    if j != len(p) - 1:\n      if p[j] == p[j+1][0:len(p[j])]:\n        continue\n    if len(p[j]) < t:\n      t -= len(p[j]) - 1\n    else:\n      print(p[j][0:t])\n      return\n  K = t - 1", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "import sys\n\nsys.setrecursionlimit(10 ** 9)\n\nS = input()\nK = int(input())\n\nchars = sorted(set(S))\nchecked = set()\n\n\ndef dfs(s):\n    for c in chars:\n        if len(checked) >= K:\n            return\n        next_s = s + c\n        if next_s not in checked and next_s in S:\n            checked.add(next_s)\n            if len(checked) == K:\n                print(next_s)\n                return\n            elif len(next_s) <= len(S):\n                dfs(next_s)\n\n\ndfs('')\n", "passed": true, "time": 0.15, "memory": 14048.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nc = set()\nfor i in range(len(s)):\n    for j in range(i+1, i+6):\n        c.add(s[i:j])\nprint((sorted(list(c))[k-1]))\n", "passed": true, "time": 0.14, "memory": 14120.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nn = len(s)\n\n# print('s',s,'k',k)\nc = set()\nfor i in range(n):\n    # print(s[i:i+5])\n    t = s[i:i+5]\n    for j in range(1,5+1):\n        # print(t[:j])\n        c.add(t[:j])\n\nc = list(c)\nc.sort()\n# print(*c,sep='\\n')\nprint((c[k-1]))\n", "passed": true, "time": 0.15, "memory": 14136.0, "status": "done"}, {"code": "import collections\n\ns = input()\nk = int(input())\nb = collections.Counter(s)\nc = sorted(b.items())\ncon = []\nn = 0\nwhile True:\n    con.append(c[n][0])\n    if len(con) == k:\n        break\n    for i in range(len(c)):\n        check = c[n][0] + c[i][0]\n        if check in s:\n            con.append(check)\n            if len(con) >= k:\n                break\n            for i_2 in range(len(c)):\n                check_2 = check + c[i_2][0]\n                if check_2 in s:\n                    con.append(check_2)\n                    if len(con) >= k:\n                        break\n                    for i_3 in range(len(c)):\n                        check_3 = check_2 + c[i_3][0]\n                        if check_3 in s:\n                            con.append(check_3)\n                            if len(con) >= k:\n                                break\n                            for i_4 in range(len(c)):\n                                check_4 = check_3 + c[i_4][0]\n                                if check_4 in s:\n                                    con.append(check_4)\n                                    if len(con) >= k:\n                                        break\n    if len(con) >= k:\n        break                              \n    n +=1\nprint(con[k-1])", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n#l = \"abcdefghijklmnopqrstuvwxyz\"\n#print(ord(\"b\")) 97\nans = []\nfor i in range(len(s)):\n    x = 0\n    for j in range(5):\n        if (i+j<len(s)):\n            x += (ord(s[i+j])-96)*10**(8-2*j)\n            ans.append((x,s[i:i+j+1]))\nans = list(set(ans))\nans.sort()\n#print(ans)\nprint(ans[k-1][1])", "passed": true, "time": 0.14, "memory": 14144.0, "status": "done"}, {"code": "s = list(input())\nk =  int(input())\ns.append((''))\nDict = {}\ndict_keys = []\nfor left in range(len(s)):\n    for right in range(left+1,len(s)):\n        string = ''.join(s[left:right])\n        if len(string)>k:\n            break\n        if string not in Dict.keys():\n            Dict[string] = True\nDict = sorted(Dict.keys())\nprint(Dict[k-1])", "passed": true, "time": 0.15, "memory": 14120.0, "status": "done"}, {"code": "S = input()\nk = int(input())\nss = []\nfor i in range(len(S)):\n    for j in range(i+1, min(i+k+1, len(S)+1)):\n        ss.append(S[i:j])\n\nss = sorted(list(set(ss)))\nprint(ss[k-1])", "passed": true, "time": 0.15, "memory": 14184.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nc = set()\nfor i in range(len(s)):\n    for j in range(k):\n        c.add(s[i:i+j+1])\nprint((sorted(list(c))[k-1]))\n", "passed": true, "time": 0.14, "memory": 14308.0, "status": "done"}, {"code": "s = input()\nn = len(s)\nK = int(input())\nans = []\nan = set()\nfor i in range(1,min(5,n)+1):\n    for j in range(n-i+1):\n        S = s[j:j+i]\n        if S not in an:\n            ans.append(S)\n            an.add(S)\nans.sort()\nprint(ans[K-1])", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "S = input()\nN = len(S)\nK = int(input())\nStringList = []\nfor TSt in range(0,N):\n    for TEd in range(TSt+1,TSt+K+1):\n        StringList.append(S[TSt:TEd])\nSetString = sorted(set(StringList))\nprint(SetString[K-1])", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "s = input()\nK = int(input())\n\ndef substring(S):\n    N = len(S)\n    ls = []\n    for i in range(1,min(6,N+1)):\n        for j in range(0,N-i+1):\n            ls.append(S[j:j+i])\n    setls = set(ls)\n    ls = list(setls)\n    ls.sort()\n    return ls\nprint(substring(s)[K-1])", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "s = input()\nn = len(s)\nk = int(input())\nl = set()\n\nfor i in range(n):\n    for j in range(1, 6):\n        if i + j <= n:\n            l.add(s[i: i + j])\n\nl = sorted(l)\nprint((l[k - 1]))\n", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "S = input()\nK = int(input())\nS_len = len(S)\nans = set()\nfor i in range(0, K+1):\n    for j in range(0, S_len):\n        if j + i <= S_len:\n            t = S[j:j + i]\n            if t != '':\n                ans.add(t)\nans = list(ans)\nans.sort()\nprint((ans[K-1]))\n", "passed": true, "time": 0.23, "memory": 14092.0, "status": "done"}, {"code": "s = list(input())\nK = int(input())\nsub_list = []\nfor i in range(1, min(K+1, len(s)+1)):\n    for j in range(len(s) - i + 1):\n        sub = \"\".join(s[j:j+i])\n        if sub not in sub_list:\n            sub_list.append(sub)\nsub_list.sort()\nprint(sub_list[K-1])", "passed": true, "time": 0.23, "memory": 14348.0, "status": "done"}, {"code": "s=input()\nk=int(input())\nn=len(s)\nr=[]\nfor right in range(0,n):\n  for left in range(right+1, right+k+1):\n    r.append(s[right:left])\nprint(sorted(set(r))[k-1])", "passed": true, "time": 0.27, "memory": 14276.0, "status": "done"}, {"code": "def main2():\n    S=list(input())\n    K=int(input())\n    N=len(S)\n\n    P=sorted(S)\n    l=[]\n    a=[]\n    k=0\n    while len(l)<=5 and k<N:\n        if P[k] not in a:\n            a.append(P[k])\n            for n in range(N):\n                if S[n]==P[k]:\n                    for i in range(1,6):\n                        if n+i<=N:\n                            tmp=\"\".join(S[n:n+i])\n                            if tmp not in l:\n                                l.append(tmp)\n        k+=1\n    l.sort()\n    print(l[K-1])\n\ndef __starting_point():\n    main2()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "s = input()\nK = int(input())\n\nseq = set()\nl = len(s)\nfor i in range(l):\n    for j in range(1, K + 1):\n        seq.add(s[i:i + j])\n\nseq = list(seq)\nseq.sort()\nprint((seq[K - 1]))\n", "passed": true, "time": 0.21, "memory": 14280.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nn = len(s)\n\ndic = {}\nansl = []\n\nfor i in range(n):\n    for j in range(i, n):\n        length = j-i+1\n        if length > k:\n            continue\n        partial = s[i:j+1]\n        if not dic.get(partial, False):\n            dic[partial] = True\n            ansl.append(partial)\n\nansl.sort()\nprint((ansl[k-1]))\n", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n    s = list(input())\n    k = int(input())\n    subs = set()\n    lens = len(s)\n    for i1 in range(k + 1):\n        for i2 in range(lens - i1):\n            subs.add(\"\".join(s[i2:i2+i1+1]))\n    subs_l = list(subs)\n    subs_l.sort()\n    print(subs_l[k-1])\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nl = []\nfor i in range(len(s)):\n    for j in range(i+1,min(i+k+1, len(s)+1)):\n        l.append(s[i:j])\nprint(sorted(list(set(l)))[k-1])", "passed": true, "time": 0.14, "memory": 14136.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nfrom collections import deque\n\n\ndef search(moji):\n    num = len(moji)\n    setsn = set([])\n    for i in range(len(s)-num+1):\n        if s[i:i+num] == moji:\n            str_ = s[i:i+num+1]\n            if len(str_) == num+1:\n                setsn.add(str_)\n    sorted_setsn = sorted(setsn, reverse=True)\n\n    return sorted_setsn\n\n\ns = str(input())\nk = int(input())\nn = len(s)\n\nsets1 = set([])\nfor i in range(0, len(s)):\n    sets1.add(s[i])\n\nsorted_sets1 = sorted(sets1)\n\n# if k == 1:\n#     print(sorted_sets1[0])\n#     return\n# else:\n#     k -= 1\n\ndq = deque(sorted_sets1)\n\nwhile(len(dq)):\n    # print(dq, k)\n    moji = dq.popleft()\n    k -= 1\n    if k == 0:\n        print(moji)\n        return\n    sorted_setsn = search(moji)\n\n    # print(sorted_setsn)\n    dq.extendleft(sorted_setsn)\n", "passed": true, "time": 0.24, "memory": 14192.0, "status": "done"}, {"code": "s = input()\n\nd = [\"z\"*5010]*5\n\nk = int(input())\nfor i in range(len(s)):\n    for j in range(i, i+k):\n        x = s[i:j+1]\n        if x in d or x == '':\n            continue\n        l = 0\n        while l < 5 and x > d[l]:\n            l += 1\n        # print(k, d[0:k], x, d[k:])\n        if l < 5:\n            d = d[0:l] + [x] + d[l:]\n            d = d[0:5]\n        # print(f\"->{d}\")\n# l = list(d)\n# l.sort()\n# print(l)\n# if l[0] == '':\n    # l = l[1:]\n\nprint((d[k-1]))\n", "passed": true, "time": 0.14, "memory": 14204.0, "status": "done"}, {"code": "S = input()\nN = len(S)\nK = int(input())\nS_list = sorted(set(list(S)))\n\nmemo = {}\n\nfor small_char in S_list:\n    for i in range(N):\n        if S[i] == small_char:\n            for j in range(i+1, i+K+1):\n                word = S[i:j]\n                memo[word] = None\n    if len(memo) >= K:\n        break\n\nans_list = sorted(list(memo.keys()))\nprint((ans_list[K-1]))\n", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "s = input()\nK = int(input())\n\nsubst = []\nfor i in range(5):\n  for j in range(len(s) - i):\n    subst.append(s[j:j+i+1])\n\nsubst = list(set(subst))\nsubst.sort()\n\nprint(subst[K - 1])", "passed": true, "time": 0.23, "memory": 14208.0, "status": "done"}, {"code": "S = input()\nN = len(S)\nK = int(input())\nttl = []\nfor i in range(N):\n    for j in range(N - i):\n        ttl.append(S[j:j+i+1])\n    if i > K:\n        break\nttl = sorted(list(set(ttl)))\nprint(ttl[K-1])", "passed": true, "time": 0.24, "memory": 14288.0, "status": "done"}, {"code": "from itertools import combinations\ns = input()\nn = int(input())\n\nle = len(s)\ntmp = s[:5]\n\nfor i in range(le - 4):\n    tmp = min(tmp, s[i:i+5])\n\nseed = tuple(combinations(list(range(min(6, le+1))), 2))\nres = set()\nfor i, j in seed:\n    res.add(tmp[i:j])\nans = sorted(res)\nprint((ans[n - 1]))\n", "passed": true, "time": 0.15, "memory": 14196.0, "status": "done"}, {"code": "S = input()\nK = int(input())\n\nN = len(S)\n\nmemo = []\nfor i in range(N):\n    for d in range(1, min(K, N - i) + 1):\n        memo.append(S[i:i + d])\n\nprint(sorted(set(memo))[K - 1])", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nse = set()\nfor i in s:\n    se.add(i)\nif len(s) > 1:\n    for i in range(len(s)-1):\n        se.add(s[i]+s[i+1])\nif len(s) > 2:\n    for i in range(len(s)-2):\n        se.add(s[i]+s[i+1]+s[i+2])\nif len(s) > 3:\n    for i in range(len(s)-3):\n        se.add(s[i]+s[i+1]+s[i+2]+s[i+3])\nif len(s) > 4:\n    for i in range(len(s)-4):\n        se.add(s[i]+s[i+1]+s[i+2]+s[i+3]+s[i+4])\nse = sorted(se)\nprint(se[k-1])", "passed": true, "time": 0.14, "memory": 14148.0, "status": "done"}, {"code": "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n    S = readline().strip()\n    K = int(readline())\n\n    subs = set()\n\n    for i in range(len(S)):\n        for j in range(i + 1, min(len(S) + 1, i + K + 1)):\n            subs.add(S[i:j])\n\n    subs = sorted(subs)\n    print((subs[K - 1]))\n\n    return\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "# K\u306f\u6700\u5927\u3067\uff15\u306a\u306e\u3067\u30011~\uff15\u6587\u5b57\u306e\u90e8\u5206\u6587\u5b57\u5217\u3092\u5168\u5217\u6319\u3057\u3066\u91cd\u8907\u7701\u3044\u3066\u30bd\u30fc\u30c8\u3059\u308c\u3070\u7d42\u308f\u308a\ns = input()\nK = int(input())\n\nsub = set()\nfor i in range(K):\n    for j in range(len(s) - i):\n        sub.add(s[j:j + i + 1])\n\nsub = list(sub)\nsub.sort()\n\nprint(sub[K - 1])", "passed": true, "time": 0.15, "memory": 14124.0, "status": "done"}, {"code": "def main():\n    S = input()\n    k = int(input())\n    setS = set(list(S))\n    count = 0\n    ans = []\n    for j in range(1, k + 1):\n        for i in range(len(S) - j + 1):\n            ans.append(S[i:i + j])\n    ans = sorted(list(set(ans)))\n    print((ans[k - 1]))\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14216.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n\nsubs_list = []\nfor i in range(len(s)):\n    for j in range(i+1, i+k+1):\n        subs_list.append(s[i:j])\n\nans = sorted(set(subs_list))\nprint((ans[k-1]))\n", "passed": true, "time": 0.15, "memory": 14072.0, "status": "done"}, {"code": "S = list(input())\nn = len(S)\nk = int(input())\nH = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\np = 0\ncnt = 0\nD = set()\n\nwhile True:\n    for i in range(n):\n        if S[i] == H[p]:\n            for j in range(1, 6):\n                if i + j <= n:\n                    D.add(\"\".join(S[i:i + j]))\n\n    p += 1\n    if len(list(D)) >= k:\n        break\n\nD = list(D)\nD.sort()\n\nprint(D[k-1])", "passed": true, "time": 0.15, "memory": 14240.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n\ncand = []\nfor i in range(len(s)):\n    temp = ''\n    for j in range(k):\n        if i + j >= len(s):continue\n        temp += s[i + j]\n        cand.append(temp)\n\ncand.sort()\n#print(cand)\nans = cand.pop(0)\nk -= 1\nwhile k != 0:\n    temp = cand.pop(0)\n    if temp == ans:continue \n    ans = temp\n    k -= 1\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "S = input()\nK = int(input())\nprint(sorted(set(S[i:i+j+1] for i in range(len(S)) for j in range(K)))[K-1])", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "S = input()\nK = int(input())\n\nsubstrings = set()\nfor length in range(1, K + 1):\n    for i in range(len(S) - length + 1):\n        substrings.add(S[i:i + length])\n\nsubstrings = sorted(substrings)\n\nprint((substrings[K - 1]))\n", "passed": true, "time": 0.15, "memory": 14172.0, "status": "done"}, {"code": "s = str(input())\nK = int(input())\n# s\u304cabcac \u306e\u5834\u5408\u3001a,bca,ac \u306a\u3069\u306f\u90e8\u5206\u5217(substring\n# abc \u3068ab\u306e\u5834\u5408\u3001ab\u306e\u65b9\u304c\u8f9e\u66f8\u9806\u3067\u5c0f\u3055\u3044\u3068\u5224\u65ad\u3059\u308b\u3002\n# abc \u3068aba\u306e\u5834\u5408\u3001aba\u306e\u65b9\u304c\u5c0f\u3055\u3044\n\nsubstrings = set([])\nfor i in range(5):\n    for j in range(len(s) - i):\n        # print(i, j)\n        substrings.add(s[j:j + i + 1])\n# print(substrings)\nprint((sorted(substrings)[K - 1]))\n", "passed": true, "time": 0.17, "memory": 14308.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nl = \"abcdefghijklmnopqrstuvwxyz\"\nd = {}\n\nfor i in range(26):\n    cnt = s.count(l[i])\n    pre = 0\n    if cnt > 0:\n        for j in range(cnt):\n            pos = s.find(l[i], pre)\n            pre = pos + 1\n            for m in range(min(len(s) - pos, k)):\n                if s[pos:pos + m + 1] not in d:\n                    d[s[pos:pos + m + 1]] = 1\n    if len(d) >= k:\n        dl = []\n        for i in d.keys():\n            dl.append(i)\n        dl.sort()\n        print(dl[k - 1])\n        return", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "s = input()\nl = len(s)\nk = int(input())\nA = set()\nfor i in range(l):\n    for j in range(1, 6):\n        if i+j <= l:\n            A.add(s[i:i+j])\nans = sorted(A)\nprint(ans[k-1])", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "def main():\n    S = input()\n    N = len(S)\n    K = int(input())\n    top_k = []\n    for i in range(N):\n        for j in range(i + 1, min([i + K, N]) + 1):\n            st = S[i:j]\n            top_k.append(st)\n            if len(top_k) > K:\n                top_k = list(set(top_k))\n                top_k.sort()\n                top_k = top_k[:K]\n    top_k.sort()\n    print(top_k[-1])\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n\nalphabets = [chr(i + 97) for i in range(26)]\n\nfor char in alphabets:\n    l = []\n    for i in range(len(s)):\n        if s[i] == char:\n            l.append(s[i:])\n\n    if l == []:\n        continue\n\n    if k == 1:\n        print((l[0][0]))\n        return\n    \n    k -= 1\n\n    strings = set([])\n    for i in l:\n        for j in range(2, min(k+2, len(i)+1)):\n            strings.add(i[:j])\n    strings = list(strings)\n    strings.sort()\n    \n    if len(strings) >= k:\n        print((strings[k-1]))\n        return\n    else:\n        k -= len(strings)\n", "passed": true, "time": 0.22, "memory": 14208.0, "status": "done"}, {"code": "s=input();k=int(input());print(sorted({s[i:i+j]for i in range(len(s))for j in range(1,k+1)})[k-1])", "passed": true, "time": 0.14, "memory": 14048.0, "status": "done"}, {"code": "s = input().rstrip()\nk = int(input())\n\nn = len(s)\nss = set()\nfor i in range(n):\n    for j in range(1, k + 1):\n        ss.add(s[i:i+j])\nprint(sorted(ss)[k - 1])", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nc = []\nfor i in range(len(s)):\n    for j in range(k): c.append(s[i:i+j+1])\nc.sort()\npre = ''\nfor x in c:\n    if pre == x: continue\n    k -= 1\n    if k == 0:\n        print(x)\n        break\n    pre = x\n", "passed": true, "time": 0.18, "memory": 14240.0, "status": "done"}, {"code": "# coding: utf-8\nimport sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nS = sr()\nK = ir()\ncand = set()\nlength = len(S)\nfor i in range(length):\n    for j in range(1, 6):\n        cand.add(S[i:i+j])\n\nanswer = sorted(list(cand))[K-1]\nprint(answer)\n", "passed": true, "time": 0.17, "memory": 14132.0, "status": "done"}, {"code": "# import sys\n# sys.setrecursionlimit(10 ** 6)\nimport bisect\n# from collections import deque\n# from decorator import stop_watch\n#\n#\n# @stop_watch\ndef solve(S, K):\n    n = len(S)\n    l = [''] + ['\u3042'] * 5\n    for i in range(n):\n        for j in range(i, i + 5):\n            tmp = S[i:j + 1]\n            tmp_num = bisect.bisect_left(l, tmp)\n            if tmp_num > 5:\n                continue\n            elif l[tmp_num] != tmp:\n                l.insert(tmp_num, tmp)\n                l.pop(-1)\n    print((l[K]))\n\n\ndef __starting_point():\n    S = input()\n    K = int(input())\n    solve(S, K)\n\n    # # test\n    # from random import randint\n    # from func import random_str\n    # n = 5000\n    # S = random_str(n, 'abcde')\n    # K = randint(1, 5)\n    # print(S)\n    # print(K)\n    # solve(S, K)\n\n__starting_point()", "passed": true, "time": 0.17, "memory": 14332.0, "status": "done"}, {"code": "s = input()\nl = len(s)\nk = int(input())\nA = set()\nfor i in range(l):\n    for j in range(1, 6):\n        if i+j <= l:\n            A.add(s[i:i+j])\nANS = sorted(A)\nprint((ANS[k-1]))\n", "passed": true, "time": 0.16, "memory": 14204.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nsubstring = set([])\nfor i in range(min(len(s), 5)):\n    for j in range(0, len(s)-i):\n        substring.add(s[j:i+j+1])\nans = list(substring)\nans.sort()\nprint(ans[k-1])", "passed": true, "time": 0.16, "memory": 14244.0, "status": "done"}, {"code": "s=input()\nk=int(input())\nans=[]\n\nfor i in range(len(s)):\n  for j in range(i+1,min(k+i+1,len(s)+1)):\n    ans.append(s[i:j])\n\nans=list(set(ans))\nans.sort()\nprint((ans[k-1]))\n", "passed": true, "time": 0.19, "memory": 14268.0, "status": "done"}, {"code": "S=input()\nK=int(input())\nN=len(S)\ns=set()\nfor i in range(N):\n    for j in range(i+1,min(i+K+1,N+1)):\n        s|={S[i:j]}\nA=list(s)\nA.sort()\nprint((A[K-1]))\n", "passed": true, "time": 0.18, "memory": 14128.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nseen = set()\ni = 1\n\nwhile i<=k:\n  for j in range(len(s)):\n    seen.add(s[j:j+i])\n  i += 1\n\nprint(sorted(seen)[k-1])", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "# coding: utf-8\n# hello world\u3068\u8868\u793a\u3059\u308b\n#dp\u3067\u3067\u304d\u306a\u3044\u304b\u306a\uff1f\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil,pi\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\ns=SI()\nk=I()\nn=len(s)\nstrs=[]\nfor i in range(n):\n    for j in range(1,k+1):\n        strs.append(s[i:i+j])\nprint(sorted(list(set(strs)))[k-1])", "passed": true, "time": 0.17, "memory": 14124.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n\nl = k\ncount = 0\nn = len(s)\nlst = 'abcdefghijklmnopqrstuvwxyz'\nfor alpha in lst:\n    alpha_index = []\n    for index in range(n):\n        if alpha == s[index]:\n            alpha_index.append(index)\n    if len(alpha_index) > 0:\n        cand_lst = []\n        for index2 in alpha_index:\n            end_lst = [index2 + m for m in range(1,6) if index2 + m <= n]\n            for end in end_lst:\n                cand_lst.append(s[index2:end])\n        cand_lst = set(cand_lst)\n        cand_lst = sorted(cand_lst)\n        #print('alpha:  ', alpha)\n        #print('alpha_index: ', alpha_index)\n        #print('cand_lst: ', cand_lst)\n        if len(cand_lst) < l:\n            l = l - len(cand_lst)\n        else:\n            res = cand_lst[l-1]\n            break\n\nprint(res)", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}, {"code": "S = input()\nK = int(input())\nA = []\nfor i in range(len(S)):\n    for j in range(1,6):\n        a = S[i:i+j]\n        A.append(a)   \n        #print(A)\n\nA = set(A)\nA = sorted(set(A))\nprint(A[K-1])", "passed": true, "time": 0.15, "memory": 14096.0, "status": "done"}, {"code": "from collections import defaultdict\nimport string\ns = input()\nK = int(input())\nlocation = defaultdict(list)\nfor i, s_i in enumerate(s):\n    location[s_i].append(i)\ncount = 0\ns_list = []\nfor c in string.ascii_lowercase[:26]:\n    if location[c] == []:\n        continue\n    for idx in location[c]:\n        for i in range(K):\n            if idx + i + 1 > len(s):\n                break\n            if s[idx:idx+i+1] in s_list:\n                continue\n            s_list.append(s[idx:idx+i+1])\n    count += 1\n    if count == K:\n        break\ns_list.sort()\nprint(s_list[K-1])", "passed": true, "time": 0.17, "memory": 14248.0, "status": "done"}, {"code": "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom collections import defaultdict\ndef main():\n    s = list(input())\n    k = int(input())\n    k -= 1\n\n    d1 = defaultdict(list)\n    for i, c in enumerate(s):\n        d1[c].append(i)\n    d2 = sorted(d1.items())\n\n    lens = len(s)\n    for d2e in d2:\n        subs = set()\n        subs.add(d2e[0])\n        for d2ee in d2e[1]:\n            end = min(lens + 1, d2ee + k + 2)\n            for i1 in range(d2ee+1, end):\n                subs.add(\"\".join(s[d2ee:i1]))\n        if len(subs) > k:\n            subsl = list(subs)\n            subsl.sort()\n            print(subsl[k])\n            return\n        else:\n            k -= len(subs)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.17, "memory": 14256.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nn = len(s)\ntemp_set = set()\nfor i in range(n):\n    for j in range(i + 1, min(i + k + 1, n + 1)):\n        temp_set.add(s[i:j])\ntemp_list = sorted(list(temp_set))\nprint(temp_list[k - 1])", "passed": true, "time": 0.14, "memory": 14336.0, "status": "done"}, {"code": "def main():\n    s=input()\n    k=int(input())\n    a=set()\n    for l in range(5):\n        for i in range(len(s)-l):\n            a.add(s[i:i+l+1])\n    print(sorted(a)[k-1])\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14060.0, "status": "done"}, {"code": "#!/usr/bin/env python3\n\n\ndef main():\n    s = input()\n    N = len(s)\n    K = int(input())\n    X = set()\n    for i in range(1,K+1):\n        for j in range(N-i+1):\n            X.add(s[j:j+i])\n    print((sorted(X)[K-1]))\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14120.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nli = []\nfor i in range(len(s)):\n    for j in range(i+1,len(s)+1):\n        if j-i<=6:\n            li += [s[i:j]]\nli2 = set(li)\nli3 = sorted(li2)\nprint(li3[k-1])", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "s=input()\nn=len(s)\nk=int(input())\nl=[]\nfor i in range(n):\n  for j in range(i,i+k+1):\n    a=s[i:j+1]\n    l.append(a)\nl=set(l)\nl=list(l)\nl.sort()\nprint(l[k-1])", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "S = input()\nN = len(S)\nK = int(input())\ncnt = {i: [] for i in range(N)}\nfor i in range(N):\n    for j in range(N - i):\n        s = S[j:j+i+1]\n        l = len(s)\n        if s not in cnt[l-1]:\n            cnt[l-1].append(s)\n    if i > K:\n        break\nttl = []\nfor k, v in cnt.items():\n    ttl.extend(v)\nttl.sort()\nprint(ttl[K-1])", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "s=input()\ns=s+'0'\nK=int(input())\np=set()\nfor i in range(len(s)):\n  for j in range(1,6):\n    if i+j<=len(s)-1:\n      p.add(s[i:j+i])\np=sorted(p)\nprint(p[K-1])", "passed": true, "time": 0.14, "memory": 14340.0, "status": "done"}, {"code": "s = input()\nk = int(input())\nlst = sorted(list(set(s)))\ntank = []\nfor tg in lst:\n    for i in range(len(s)):\n        if s[i]==tg:\n            for j in range(k):\n                if i+j<=len(s) and (s[i:i+j+1] not in tank):\n                    tank.append(s[i:i+j+1])\n    if len(tank) >= k:\n        break\ntank.sort()\nprint(tank[k-1])", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "s = input()\nK = int(input())\nN = len(s)\n\nans = []\n\nfor i in range(min(K, N)):\n  for j in range(N-i):\n    ans.append(s[j:j+i+1])\n  \nans.sort()\ncount = 0\nnow = '0'\nfor i in range(len(ans)):\n  if ans[i] != now:\n    count += 1\n    now = ans[i]\n    if count == K:\n      print(now)\n      return\n    \n", "passed": true, "time": 0.13, "memory": 14272.0, "status": "done"}, {"code": "from collections import deque\n\ns = input()\nk = int(input())\n\ndef index_Multi(List,liter):\n    #List\u306f\u30ea\u30b9\u30c8\u672c\u4f53\u30fbliter\u306f\u691c\u7d22\u3057\u305f\u3044\u6587\u5b57\n    index_L = []\n    for val in range(0,len(List)):\n        if liter == List[val]:\n            index_L.append(val)\n    return index_L\n\ndef substr(s, k, j):\n    n = ord(\"a\")\n\n    while True:\n        l = index_Multi(s, chr(n+j))\n        word = []\n        if len(l) == 0:\n            n += 1\n        else:\n            for p in l:\n                for i in range(k):\n                    word.append(s[p:p+i+1])\n            sword = set(word)\n            if len(sword) >= k:\n                tword = list(sword)\n                tword.sort()\n                #print(tword, sword)\n                return tword[k-1]\n            else:\n                return substr(s, k-len(sword), j+1)\n            break\n\nprint(substr(s, k, 0))", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "def calc( s , k , n):\n\n\tbruh = {}\n\tfor i  in range(1, k + 1): # length\n\t\tfor j in range( n - ( i - 1)): # start \n\t\t\tbruh[s[j: j + i:]] = 0\n\tanother = bruh.keys()\n\tanother = sorted(another)\n\tprint( another[k - 1])\n\ns = input()\n\nk = int(input())\n\nn = len(s)\n \ncalc( s , k , n)", "passed": true, "time": 0.14, "memory": 14128.0, "status": "done"}, {"code": "s = input()\nk = int(input())\n\nSUBSTRINGS = set()\nfor i in range(len(s)):\n    for j in range(i + 1, i + 6):\n        SUBSTRINGS.add(s[i:j])\n\nSUBSTRINGS = sorted(SUBSTRINGS)\n\nprint((SUBSTRINGS[k - 1]))\n", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}]