#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, x, y;
  cin >> a;
  while (a--) {
    cin >> x >> y;
    x = x - 1;
    while (x--) {
      y = y + 9;
    }
    cout << y << endl;
  }
  return 0;
}
