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