description: It is a simplified version of problem F2. The difference between them is the constraints (F1: k ≤ 2, F2: k ≤ 10).
  
  You are given an integer n. Find the minimum integer x such that x ≥ n and the number x is k-beautiful.
  
  A number is called k-beautiful if its decimal representation having no leading zeroes contains no more than k different digits. E.g. if k = 2, the numbers 3434443, 55550, 777 and 21 are k-beautiful whereas the numbers 120, 445435 and 998244353 are not.
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t test cases follow.
  
  Each test case consists of one line containing two integers n and k (1 ≤ n ≤ 10^9, 1 ≤ k ≤ 2).
  
  Output
  
  For each test case output on a separate line x — the minimum k-beautiful integer such that x ≥ n.
  
  Example
  
  Input
  
  
  4
  1 1
  221 2
  177890 2
  998244353 1
  
  
  Output
  
  
  1
  221
  181111
  999999999
solution: import collections
  import bisect
  from itertools import combinations
  
  t = int(input())
  
  all_cur = set()
  for x in combinations(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 2):
      for l in range(1, 10):
          cur = list(range(l))
          for i in range(l+1):
              for y in combinations(cur, i):
                  cur_res = ''
                  for j in range(l):
                      if j in y:
                          cur_res += x[0]
                      else:
                          cur_res += x[1]
                  if cur_res[0] == '0' and cur_res != '0':
                      continue
                  all_cur.add(int(cur_res))
  
  all_cur = list(all_cur)
  all_cur.sort()
  # print(len(all_cur))
  # print(all_cur)
  
  for case in range(t):
      n, k = list(map(int, input().split()))
      if n == 1000000000:
          if k == 2:
              print(1000000000)
          else:
              print(1111111111)
          continue
      if k == 1:
          cur = []
          for i in range(0, 10):
              cur.append(str(i) * len(str(n)))
          res = float('inf')
          for x in cur:
              if len(str(int(x))) != len(x):
                  continue
              if int(x) >= n:
                  res = min(res, int(x))
          print(res)
      else:
          index = bisect.bisect_left(all_cur, n)
          # print(index, all_cur[index], n)
          print(all_cur[index])
  
  