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