#include <bits/stdc++.h>
using namespace std;
const int MX = 1e9 + 1;
const int Imp = -1;
const int INF = 1e7 + 100;
const int N = 1e6 + 5;
const int M = 1e5 + 5;
int X[] = {1, -1, 0, 0};
int Y[] = {0, 0, 1, -1};
map<char, int> mp;
int mx = -1, ans;
int ok, ok1;
int t[M];
int main() {
  long long n;
  cin >> n;
  for (; n--;) {
    long long k, x;
    cin >> k >> x;
    cout << x + ((k - 1) * 9) << "\n";
  }
}
