#include <bits/stdc++.h>
using namespace std;
int main()
{
int n , m , k , t;
cin >> t;
while(t--){
cin >> n >> k;
if(k > 81){ // invalid case
cout << "-1\n";
continue;
}
int start = k / 9 + (k % 9 != 0); // first number
int order = k % 9; // order of the second number
if(order == 0) order = 9;
int second = order; // second number
if(second <= start) second--;