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 sys
  inputt=sys.stdin.readline
  printt=sys.stdout.write
  
  import math
  import functools  # functools.reduce
  from collections import deque
  import heapq
  from queue import PriorityQueue
  
  def get():
      return inputt().split()
  def getint():
      return int(inputt())
  def getints():
      return map(int, inputt().split())
  
  h1 = [i*int('1'*j) for i in range(1, 10) for j in range(1,10)]
  h1.sort()
  
  def find(h, n):
      if len(h)==1:
          return h[0]
      mid = len(h)//2
      if h[mid-1]<n and n<=h[mid]:
          return h[mid]
      elif n<=h[mid-1]:
          return find(h[:mid], n)
      else:
          return find(h[mid:], n)
  
  h2 = []
  
  for i, j in [(i, j) for i in range(0, 10) for j in range(i, 10)]:
      x = {i:set() for i in range(1,10)}
      x[0] = {''}
      for k in range(9):
          for st in x[k]:
              x[k+1].add(st+str(i))
              x[k+1].add(st+str(j))
          h2.extend(map(int, x[k+1]))
  
  h2.sort()
  
  for _ in range(getint()):
      n, k = getints()
      if n == 10**9:
          if k == 1:
              print(1111111111)
          else:
              print(n)
      else:
          if k==1:
              print(find(h1, n))
          else:
              print(find(h2, n))
      