#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, a, b;
cin >> n;
while (cin >> oct >> a >> b)
cout << hex << uppercase << a + b << endl;
}
#include
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, a, b;
cin >> n;
while (cin >> oct >> a >> b)
cout << hex << uppercase << a + b << endl;
}