#include <bits/stdc++.h>
const int maxn = 100005;
using namespace std;
int num[15];
int check(int p) {
  int ans = 0;
  while (p) {
    ans += p % 10;
    p /= 10;
  }
  int cnt = 0;
  while (ans) {
    cnt += ans % 10;
    ans /= 10;
  }
  return cnt;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long k;
    int x;
    int cnt = 1;
    cin >> k >> x;
    cout << (k - 1) * 9 + x << endl;
  }
}
