#include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
void IO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
}
int T;
int main() {
  IO();
  cin >> T;
  while (T--) {
    long long k, x;
    cin >> k >> x;
    long long result = 9 * (long long)(k - 1) + x;
    cout << result << endl;
  }
}
