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