def main(): n, d = map(int, input().split()) a = [int(i) for i in input()] for c in range(len(a)): i = a[c] if i < d: a.insert(c, d) return "".join([str(b) for b in a]) return "".join([str(b) for b in a])+str(d) for _ in range(int(input())): print(main())