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
  
  input = sys.stdin.readline  # 文字列入力はするな！！
  
  
  ans1=set()
  ans2=set()
  
  for a in range(10):
      ans=a
      for i in range(10):
          ans1.add(ans)
          ans=ans*10+a
  
  for a in range(10):
      for b in range(10):
          for k in range(2,11):
              for bit in range(2**k):
                  x=0
                  for i in range(k):
                      bitcnt=0
                      if (bit>>i)&1:
                          x=x*10+a
                          bitcnt+=1
                      else:
                          x=x*10+b
                  if not(bitcnt==0 or bitcnt==k):
                      ans2.add(x)
  
  
  ans1=list(ans1)
  ans2=list(ans2)
  ans1.sort()
  ans2.sort()
  
  
  #######################################
  
  
  def bilower(a,x):
      # a[i]<=x となる最大のiを返す ない時は-1
      if len(a)==0:return -1
      mi=0
      ma=len(a)-1
      if a[0]>x:return -1
      if a[ma]<=x:return ma
      while ma-mi>1:
          mid=(ma+mi)//2
          if a[mid]<=x:mi=mid
          else:ma=mid
      return mi
  
  def bihigher(a,x):
      # a[i]>=x となる最小のiを返す ない時は len(a)
      if len(a)==0:return 0
      mi=0
      ma=len(a)-1
      if a[ma]<x:return ma+1
      if a[0]>=x:return 0
      while ma-mi>1:
          mid=(ma+mi)//2
          if a[mid]>=x:ma=mid
          else:mi=mid
      return ma
  
  def birange(a,l,r):
  
      left=bihigher(a,l)
      right=bilower(a,r)
      return right-left+1
  
  ################################################
  
  
  
  
  
  T = int(input())
  for iiii in range(T):
      n,k=map(int,input().split())
      if k==1:
          print(ans1[bihigher(ans1,n)])
      else:
          print(ans2[bihigher(ans2,n)])
  
  
  
  
  
  
  
  