#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, cnt = 0, ans = 0, k;
  cin >> cnt;
  while (cnt--) {
    cin >> k >> n;
    ans = n + ((k - 1) * 9);
    cout << ans << endl;
  }
}
