#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, n, k, ans;
  cin >> t;
  while (t--) {
    cin >> k >> n;
    ans = n + (k - 1) * 9;
    cout << ans << "\n";
  }
  return 0;
}
