//#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//.find_by_order(1); по индексу
//.order_of_key(1);

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();

int32_t main() {
#ifdef LOCAL
    freopen("Input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

constexpr int MAXN = 3e5 + 1;
constexpr ll INF = 1e18;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> x(m);
    for (int i = 0; i < m; ++i) {
        cout << x[i];
    }
    if (n >= m) {
        cout << m * x[0] << '\n';
        return;
    }
    if ((m - n) % 2 == 0) {
        cout << (n - 1) * x[0] << '\n';
        return;
    }
    cout << n * x[0] << '\n';
}