#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e7 + 9, MAXN = 1e6;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  unsigned long long int k, x;
  cin >> n;
  while (n--) {
    cin >> k >> x;
    cout << x + 9 * (k - 1) << endl;
  }
  return 0;
}
