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: #include <bits/stdc++.h>
  using namespace std;
  template <typename A>
  ostream &operator<<(ostream &cout, vector<A> const &v);
  template <typename A, typename B>
  ostream &operator<<(ostream &cout, pair<A, B> const &p) {
    return cout << "(" << p.first << ", " << p.second << ")";
  }
  template <typename A>
  ostream &operator<<(ostream &cout, vector<A> const &v) {
    cout << "[";
    for (int i = 0; i < v.size(); i++) {
      if (i) cout << ", ";
      cout << v[i];
    }
    return cout << "]";
  }
  template <typename A, typename B>
  istream &operator>>(istream &cin, pair<A, B> &p) {
    cin >> p.first;
    return cin >> p.second;
  }
  set<long long> at[3];
  long long n, k;
  void solve(int tc = 0) {
    cin >> n >> k;
    long long ans = 1e12;
    for (long long i = 1; i <= k; i++) {
      ans = min(ans, *at[i].lower_bound(n));
    }
    cout << ans << '\n';
  }
  int main() {
    cout << setprecision(15) << fixed;
    for (long long d = 1; d <= 9; d++) {
      long long r = 0;
      for (long long i = 0; i < 12; i++) {
        r = 10 * r + d;
        at[1].insert(r);
      }
    }
    for (long long d = 0; d <= 9; d++) {
      for (long long e = d + 1; e <= 9; e++) {
        for (long long k = 0; k < 11; k++) {
          for (long long i = 0; i < (1 << k); i++) {
            long long r = 0;
            for (long long j = 0; j < k; j++) {
              long long v = (((i >> j) & 1) ? d : e);
              r = 10 * r + v;
            }
            at[2].insert(r);
          }
        }
      }
    }
    int tc = 1;
    cin >> tc;
    for (int t = 0; t < tc; t++) {
      solve(t);
    }
  }
  