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.util.*;
  import java.io.*;
  
  public class F1_Nearest_Beautiful_Number_easy_version_{
      public static void main(String[] args) {
          FastScanner s= new FastScanner();
          StringBuilder res = new StringBuilder();
          ArrayList<Long> number = new  ArrayList<Long>();
          for(int i=0;i<10;i++){
              for(int j=i+1;j<10;j++){
                   for(int k=1;k<=10;k++){
                       int num=(int)Math.pow(2,k);
                       for(int l=0;l<num;l++){
                           int array[]= new int[k];
                           int yo=k-1;
                           int yoyo=l;
                           while(yoyo>0){
                               if((yoyo&1)==1){
                                      array[yo]=1;
                                      yo--;
                               }
                               else{
                                   array[yo]=0;
                                   yo--;
                               }
                               yoyo=yoyo>>1;
                           }
                           long hh=0;
                           for(int g=0;g<array.length;g++){
                               if(array[g]==0){
                                   hh=hh*10;
                                   hh+=i;
                               }
                               else{
                                   hh=hh*10;
                                   hh+=j;
                               }
                           }
                           number.add(hh);
  
                       }
  
                   }
              }
          }
          Collections.sort(number);
          int t=s.nextInt();
          int p=0;
          while(p<t){
          int n=s.nextInt();
          int k=s.nextInt();
          if(k==1){
              int jj=n;
              ArrayList<Integer> digits = new ArrayList<Integer>();
              while(jj>0){
                  int dig=jj%10;
                  digits.add(dig);
                  jj/=10;
              }
              ArrayList<Integer> digits2 = new ArrayList<Integer>();
              for(int i=digits.size()-1;i>=0;i--){
                  digits2.add(digits.get(i));
              }
              int bb=digits2.get(0);
              int check=0;
  
              for(int i=1;i<digits2.size();i++){
                   if(digits2.get(i)>bb){
                       check=1;
                       break;
                   }
                   else if(digits2.get(i)<bb){
                       check=-1;
                       break;
                   }
              }
              if(check==1){
                  int a=bb+1;
                  for(int i=0;i<digits2.size();i++){
                      res.append(a);
                  }
                  res.append("\n");
              }
              else if(check==-1){
                  int a=bb;
                  for(int i=0;i<digits2.size();i++){
                      res.append(a);
                  }
                  res.append("\n");
              }
              else{
                  res.append(n+"\n");
              }
  
          }
          else{
              long num2=n;
              int index=Collections.binarySearch(number,num2);
              if(index>=0){
                  res.append(n+"\n");
              }
              else{
                  long kk=Math.abs(index);
                  kk--;
                  res.append(number.get((int)kk)+"\n");
  
              }
  
          }
          p++;
      }
      System.out.println(res);
      }
      static class FastScanner {
  		BufferedReader br;
  		StringTokenizer st;
   
  		public FastScanner(String s) {
  			try {
  				br = new BufferedReader(new FileReader(s));
  			} catch (FileNotFoundException e) {
  				// TODO Auto-generated catch block
  				e.printStackTrace();
  			}
  		}
   
  		public FastScanner() {
  			br = new BufferedReader(new InputStreamReader(System.in));
  		}
   
  		String nextToken() {
  			while (st == null || !st.hasMoreElements()) {
  				try {
  					st = new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					// TODO Auto-generated catch block
  					e.printStackTrace();
  				}
  			}
  			return st.nextToken();
  		}
   
  		int nextInt() {
  			return Integer.parseInt(nextToken());
  		}
   
  		long nextLong() {
  			return Long.parseLong(nextToken());
  		}
   
  		double nextDouble() {
  			return Double.parseDouble(nextToken());
  		}
  	}
  
  
  
  
  }