output_description: Print the K-th lexicographically smallest substring of K.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      s
      K
attempt: from bisect import bisect_left, bisect_right
  from collections import Counter, defaultdict, deque, OrderedDict
  from copy import deepcopy
  from fractions import gcd
  from functools import lru_cache, reduce
  from math import ceil, floor
  from sys import setrecursionlimit
  
  import heapq
  import itertools
  import operator
  
  
  inf = float("inf")
  
  
  # globals
  S = ""
  K = 0
  
  
  def set_inputs():
      global S, K
      S = get_str()
      K = get_int()
      return
  
  
  def main():
      setrecursionlimit(100000)
      set_inputs()
      # ----------MAIN----------
      d = defaultdict(list)
      for i, s in enumerate(S):
          d[s].append(i)
      cnt = 0
      for s in sorted(d.keys()):
          substrings = set(s)
          for i in d[s]:
              for ss in [S[i : i + k] for k in range(2, K + 1)]:
                  substrings.add(ss)
          if cnt + len(substrings) >= K:
              print(list(sorted(substrings))[K - 1 - cnt])
              return
          cnt += len(substrings)
      return
  
  
  def get_int():
      return int(input())
  
  
  def get_float():
      return float(input())
  
  
  def get_str():
      return input().strip()
  
  
  def get_li():
      return [int(i) for i in input().split()]
  
  
  def get_lf():
      return [float(f) for f in input().split()]
  
  
  def get_lc():
      return list(input().strip())
  
  
  def get_data(n, types):
      if len(types) == 1:
          return [types[0](input()) for _ in range(n)]
      return zip(*([t(x) for t, x in zip(types, input().split())] for _ in range(n)))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  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}.
samples: [{"input": "aba\n    4", "output": "b\n    \n\ns has five substrings: `a`, `b`, `ab`, `ba` and `aba`. Among them, we should\nprint the fourth smallest one, `b`. Note that we do not count `a` twice.\n\n* * *"}, {"input": "atcoderandatcodeer\n    5", "output": "andat\n    \n\n* * *"}, {"input": "z\n    1", "output": "z"}]