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 Solution_1 {
      public static void recurse(int n,int num1,int num2,long num,List<Long> al,Set<Long> set){
  		if(n>=11) return;
  		// System.out.println(num);
  		if(!set.contains(num)) {
  			al.add(num);
  			set.add(num);
  		}
  		recurse(n+1,num1,num2,num*10+num1,al,set);
  		recurse(n+1,num1,num2,num*10+num2,al,set);
  	}
  	public static long binarySearch(List<Long> al,long n){
  		int low = 0,high = al.size()-1;
  		long ans = 0;
  		while(low<=high){
  			int mid = (low+high)/2;
  			if(al.get(mid)>=n){
  				ans = al.get(mid);
  				high = mid-1;
  			}
  			else low = mid+1;
  		}
  		return ans;
  	}
  	public static void main(String[] args) {
  		List<Long> al = new ArrayList<>();
  		Set<Long> set = new HashSet<>();
  		for(int i=1;i<=9;i++){
  			for(int j=0;j<=9;j++){
  				if(i!=j) recurse(0,i,j,0,al,set);
  			}
  		}
  		List<Long> al1 = new ArrayList<>();
  		for(int i=1;i<=9;i++){
  			long val = i;
  			for(int j=1;j<=10;j++){
  				al1.add(val);
  				al.add(val);
  				val = val*10+i;
  			}
  		}
  		Collections.sort(al1);
  		Collections.sort(al);
  		// System.out.println(al.size());
  		Scanner sc = new Scanner(System.in);
  		int t = sc.nextInt();
  		while(t-->0){
  			long n = sc.nextLong();
  			int k = sc.nextInt();
  			long ans = 0;
  			if(k==1){
  				
  				ans = binarySearch(al1,n);
  			}
  			else{
  				ans = binarySearch(al,n);
  			}
  			System.out.println(ans);
  		}
  	}
  }