#include<iostream>
using namespace std;
#include<algorithm>
int main()
{
int T, n, m, a[13][20] = { 0 }, b[13][500] = { 0 }, c[20] = { 0 }, d[500] = {0};
int q = 0, w = 0;
cin >> T;
for (int i = 0; i < T; i++)
{
cin >> n >> m;
c[q++] = n;
d[w++] = m;
for (int j = 0; j < n; j++)
{
cin >> a[i][j];
}
for (int j = 0; j < m; j++)
{
cin >> b[i][j];
}
}
q = 0;
w = 0;
for (int i = 0; i < T; i++)
{
sort(a[i], a[i] + c[q++], less<int>());
}
for (int i = 0; i < T; i++)
{
sort(b[i], b[i] + d[w++], less<int>());
}
for (int i = 0; i < T; i++)
{
cout << "Problem " << 1001 + i << ":" << endl;
if (a[i][0] != 0) cout << "Shortest judge solution: " << a[i][0] << " bytes." << endl;
else cout << "Shortest judge solution: N/A bytes." << endl;
if(b[i][0]!=0) cout << "Shortest team solution: " << b[i][0] << " bytes." << endl;
else cout << "Shortest team solution: N/A bytes." << endl;
}
return 0;
}