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 E {	
  	
  	public static void main(String[] args) {
  		
  		FastReader f = new FastReader();
  		StringBuffer sb=new StringBuffer();
  		
  		TreeSet<Long> one=new TreeSet<>();
  		TreeSet<Long> two=new TreeSet<>();
  		
  		for(int i=1;i<=9;i++)
  		{	
  			long no=0;
  			for(int j=1;j<=10;j++)
  			{
  				no=no*10L+i;
  				one.add(no);
  			}
  		}
  		
  		for(int i=0;i<10;i++) 
  		{
  			for(int j=i+1;j<10;j++) 
  	        {
  	            for(int k=1;k<11;k++) 
  	            {
  	                for(int l=0;l<(1<<k);++l) 
  	                {
  	                    long curr_num = 0;
  	                    for(int m=0;m<k;++m) 
  	                    {
  	                        if (((1<<m)&l)!=0) 
  	                            curr_num+=p10(m)*i; 
  	                        else 
  	                            curr_num+=p10(m)*j;
  	                    }
  	                    two.add(curr_num);
  	                }
  	            }
  	        }
  	    }
  //		System.out.println(two.size());
  		int test=f.nextInt();
  		while(test-->0)
  		{
  			int n=f.nextInt();
  			int k=f.nextInt();
  			if(k==1)
  				sb.append(one.ceiling((long)n)+"\n");
  			else
  				sb.append(two.ceiling((long)n)+"\n");
  		}
  		System.out.println(sb);
  	}
  	
  	static long p10(int a) {
  	    long ans=1;
  	    for (int i=0;i<a;i++) {
  	        ans*=10;
  	    }
  	    return ans;
  	}
  	
  	static class FastReader 
  	{ 
  	    BufferedReader br; 
  	    StringTokenizer st; 
   
  	    public FastReader() {
  	    	br = new BufferedReader(new
  	                 InputStreamReader(System.in)); 
  	    }
  	    String next() { 
  	        while (st == null || !st.hasMoreElements()) { 
  	            try{ 
  	                st = new StringTokenizer(br.readLine()); 
  	            } 
  	            catch (IOException  e) { 
  	                e.printStackTrace(); 
  	            } 
  	        } 
  	        return st.nextToken(); 
  	    } 
  	    int nextInt() { 
  	        return Integer.parseInt(next()); 
  	    } 
  	    long nextLong() { 
  	        return Long.parseLong(next()); 
  	    } 
  	    double nextDouble() { 
  	        return Double.parseDouble(next()); 
  	    } 
  	    String nextLine() { 
  	        String str = ""; 
  	        try{ 
  	            str = br.readLine(); 
  	        } 
  	        catch (IOException e) { 
  	            e.printStackTrace(); 
  	        } 
  	        return str; 
  	    } 
  	} 
  }
  