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 B{
      
      static int bin1(long n, List<Long> arr)
      {
          int low = -1; int high = arr.size();
          while(low+1<high)
          {
              int mid = (low+high)/2;
              long ele = arr.get(mid);
              if(ele>=n)high = mid;
              else low = mid;
          }
          return high;
      }
      
  	public static void main(String[] args)
  	{
  		FastScanner fs = new FastScanner();
  		PrintWriter out = new PrintWriter(System.out);
  		
  		List<Long> temp = new ArrayList();
  		List<Long> temp1 = new ArrayList();
  		
  		for(char first='0';first<='9';first++){
  		    for(int size=1;size<=10;size++){
              String str = "";
              for(int pos=0;pos<size;pos++)
              {
                  str += first;
              }
              long value = Long.valueOf(str);
              temp.add(value);
              temp1.add(value);
  		    }
          }
  		for(char first='0';first<='9';first++)
  		    {
  		        for(char second=(char)(first+1);second<='9';second++)
  		        {
  		            for(int size=1;size<=10;size++)
  		            {
  		                for(int i=0;i<(1<<size);i++)
  		                {
  		                    String str = "";
  		                    for(int pos=0;pos<size;pos++)
  		                    {
  		                        if(((1<<pos)&(i)) != 0)str += first;
  		                        else str += second;
  		                    }
  		                    long val = Long.valueOf(str);
  		                    temp1.add(val);
  		                }
  		            }
  		        }
  		    }
  		    Collections.sort(temp);
  		    Collections.sort(temp1);
  		int t = fs.nextInt();
  		for(int tt=0;tt<t;tt++)
  		{
  		    long n = fs.nextLong(); int k = fs.nextInt();
  		    
  		    if(k == 1)
  		    {
  		        out.println(temp.get(bin1(n,temp)));
  		    }
  		    else out.println(temp1.get(bin1(n,temp1)));
  		    
  		}
  		out.close();		
  	}
  	static class FastScanner {
  		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  		StringTokenizer st=new StringTokenizer("");
  		String next() {
  			while (!st.hasMoreTokens())
  				try {
  					st=new StringTokenizer(br.readLine());
  				} catch (IOException e) {
  					e.printStackTrace();
  				}
  			return st.nextToken();
  		}
  		
  		int nextInt() {
  			return Integer.parseInt(next());
  		}
  		int[] readArray(int n) {
  			int[] a=new int[n];
  			for (int i=0; i<n; i++) a[i]=nextInt();
  			return a;
  		}
  		long nextLong() {
  			return Long.parseLong(next());
  		}
  	}
  	public static int[] sort(int[] arr)
  	{
  		List<Integer> temp = new ArrayList();
  		for(int i:arr)temp.add(i);
  		Collections.sort(temp);
  		int start = 0;
  		for(int i:temp)arr[start++]=i;
  		return arr;
  	}
  	public static List<Character> rev(List<Character> arr)
  	{
  	    for(int i=0;i<arr.size()/2;i++)
  	    {
  	        char first = arr.get(i);
  	        char sec = arr.get(arr.size()-1-i);
  	        
  	        arr.set(i,sec);
  	        arr.set(arr.size()-1-i,first);
  	        
  	    }
  	    return arr;
  	}
  }