#include <bits/stdc++.h>
using namespace std;
const int N = 100111;
long long n, arr[N], x, k;
int main() {
  cin >> n;
  while (n--) {
    cin >> k >> x;
    long long u = 9 * k;
    cout << u - (9 - x) << endl;
  }
}
