#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, x, k, i;
  cin >> t;
  while (t--) {
    cin >> k >> x;
    if (k == 1) {
      cout << x << "\n";
    } else {
      long long int y = x + (9 * (k - 1));
      cout << y << "\n";
    }
  }
  return 0;
}
