#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
const long long INF = 1e18;
int main() {
  long long n;
  cin >> n;
  while (n--) {
    long long k, x;
    cin >> k >> x;
    cout << 9 * (k - 1) + x << endl;
  }
  return 0;
}
