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: // Oh boy this is gonna be fun
  
  import com.sun.source.tree.Tree;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.util.Arrays;
  import java.util.Random;
  import java.util.StringTokenizer;
  import java.util.TreeSet;
  
  public class F {
  
      static FastScanner fs=new FastScanner();
      static TreeSet<Long> one = new TreeSet<>(), two = new TreeSet<>();
      public static void main(String[] args) {
          int tt = 1;
  
          for(int a = 0; a < 10; a++) {
              for(int b = 0; b < 10; b++) {
                  for(int len = 1; len <= 10; len++) {
                      for (int mask = 0; mask < (1 << len); mask++) {
                          long x = 0;
                          for (int i = 0; i < len; i++) {
                              x = 10 * x;
                              if ((mask >> i & 1) == 0) {
                                  x += a;
                              } else {
                                  x += b;
                              }
                          }
                          if (a == b) one.add(x);
                          two.add(x);
                      }
                  }
              }
          }
  
          tt = fs.nextInt();
          for(int w = 0; w < tt; w++) {
              solve();
          }
      }
  
      private static void solve() {
          long n = fs.nextLong(), k = fs.nextLong();
          if(k == 1) {
              if(one.contains(n)) {
                  System.out.println(n);
              } else {
                  System.out.println(one.higher(n));
              }
          } else {
              if(two.contains(n)) {
                  System.out.println(n);
              } else {
                  System.out.println(two.higher(n));
              }
          }
      }
  
      private static void mySort(int[] a) {
          int n = a.length;
          Random rd = new Random(420);
          for (int i = 0; i < n; i++) {
              int j = rd.nextInt(i+1);
              int tmp = a[j];
              a[j] = a[i];
              a[i] = tmp;
          }
          Arrays.sort(a);
      }
  
      static class FastScanner {
          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          StringTokenizer st=new StringTokenizer("");
          public String next() {
              while (!st.hasMoreElements())
                  try {
                      st=new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              return st.nextToken();
          }
  
          int[] readArray(int n) {
              int[] a=new int[n];
              for (int i=0; i<n; i++) a[i]=nextInt();
              return a;
          }
  
          int nextInt () {
              return Integer.parseInt(next());
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
      }
  
  }
  