#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
int n, m, a[N], b[N];
int main() {
  cin >> n;
  long long k, x;
  for (int i = 0; i < n; i++) {
    cin >> k >> x;
    cout << (9ll * (k - 1)) + x << endl;
  }
  return 0;
}
