#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    long long k, x;
    cin >> k >> x;
    long long res = x + (k - 1) * 9;
    cout << res << endl;
  }
  return 0;
}
