#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
  return (a * (b / gcd(a, b)));
}
template <typename T>
T isprime(T a) {
  for (long long int i = 0; i * i <= a; i++)
    if (a % i == 0) return 0;
  return 1;
}
int main() {
  long long int t, k, x, first, i;
  cin >> t;
  while (t--) {
    cin >> k >> x;
    if (k == 1) {
      cout << x << endl;
      continue;
    }
    first = 10 + x - 1;
    if (k == 2) {
      cout << first << endl;
      continue;
    }
    k = k - 2;
    cout << first + 9 * k << endl;
  }
}
