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 java.io.*;
  import java.util.*;
  
  public class Main {
      
      public static void main(String[] args) throws IOException {
          Scanner scn = new Scanner(System.in);
          OutputWriter out = new OutputWriter(System.out);
          // Always print a trailing "\n" and close the OutputWriter as shown at the end of your output
          
          // example:
          int[] pow=new int[10];
          pow[0]=1;
          for(int i=1;i<=9;i++){
              pow[i]=(pow[i-1]*2);
          }
          TreeSet<Integer> set=new TreeSet<Integer>();
          TreeSet<Integer> set1=new TreeSet<Integer>();
          set.add(1000000000);
          for(int i1=0;i1<=9;i1++){
              for(int j=0;j<=9;j++){
                  for(int mask=0 ; mask <= pow[9] - 1 ;mask++)
                  {
                  int sum=0;
                  int x=1;
                  for(int i=1;i<=9;i++)
                  {
                  if((mask&(1<<i))>0)
                  {
                  sum+=i1*x;x=10*x;
                  }
                  else{
                      sum+=j*x;x=10*x;
                  }
                  set.add(sum);
                  }
                  }
              }
          }
          for(int j=0;j<=9;j++){
              int sum=0;int x=1;
              for(int i=1;i<=9;i++){
                  sum+=j*x;x=x*10;
                  set1.add(sum);
              }
          }
          set1.add(1111111111);
          /*out.print(set.toString());*/
          int t= scn.nextInt();
          for(int i=0;i<t;i++){
              int n=scn.nextInt();int k=scn.nextInt();
              if(k==1){
                  if(set1.contains(n)){
                  out.print(n+"\n");
              }
              else{
                  out.print(set1.higher(n)+"\n");
              }
              }
              else{
                 if(set.contains(n)){
                  out.print(n+"\n");
              }
              else{
                  out.print(set.higher(n)+"\n");
              } 
              }
              
          }
          out.close();
      }
  
      // fast input
      static class Scanner {
          public BufferedReader reader;
          public StringTokenizer tokenizer;
  
          public Scanner(InputStream stream) {
              reader = new BufferedReader(new InputStreamReader(stream));
              tokenizer = null;
          }
  
          public String next() {
              while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                  try {
                      String line = reader.readLine();
                      if (line == null)
                          return null;
                      tokenizer = new StringTokenizer(line);
                  } catch (Exception e) {
                      throw(new RuntimeException());
                  }
              }
              return tokenizer.nextToken();
          }
  
          public int nextInt() { return Integer.parseInt(next()); }
          public long nextLong() { return Long.parseLong(next()); }
          public double nextDouble() { return Double.parseDouble(next()); }
      }
  
      // fast output
      static class OutputWriter {
          BufferedWriter writer;
  
          public OutputWriter(OutputStream stream) {
              writer = new BufferedWriter(new OutputStreamWriter(stream));
          }
  
          public void print(int i) throws IOException { writer.write(i); }
          public void print(String s) throws IOException { writer.write(s); }
          public void print(char[] c) throws IOException { writer.write(c); }
          public void close() throws IOException { writer.close(); }
      }
  
  
  }
  
  