#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long a, b, c;
  scanf("%lld%lld", &a, &b);
  printf("%lld\n", (a - 1) * 9 + b);
  return;
}
int main() {
  int N;
  scanf("%d", &N);
  while (N--) solve();
  return 0;
}
