#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    int a1 = a / 10;
    int a2 = a % 10;
    int b1 = b / 10;
    int b2 = b % 10;
    int m = a + b;
    if (a1 != 0 && b1 != 0) {
      int x = a1 * 10 + b1 + a2 * 10 + b2;
      int y = a1 * 10 + b2 + b1 * 10 + a2;
      int z = b2 * 10 + a2 + b1 * 10 + a1;
      m = max(max(x, y), max(m, z));
      cout << m << endl;
    } else if (a1 != 0 && b1 == 0) {
      int x = a1 * 10 + b1 + a2;
      int y = b2 * 10 + a2 + a1;
      m = max(m, max(x, y));
      cout << m << endl;
    } else if (a1 == 0 && b1 != 0) {
      int x = a2 * 10 + b2 + b1;
      int y = b1 * 10 + a2 + b2;
      m = max(m, max(x, y));
      cout << m << endl;
    } else
      cout << m << endl;
  }
  return 0;
}
