#include <bits/stdc++.h>
using namespace std;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fastio();
  long long i, j, n, m, t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    cout << 9 * (n - 1) + m << endl;
  }
  return 0;
}
