#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
fast;
int t;
cin >> t;
while(t--)
{
long long nr,ng,nb,i,j,k;
cin >> nr >> ng >> nb;
long long rmx,rmd = 1e9 + 5,rmn,a[nr],b[ng],c[nb],diff = 1e9 + 5;
vector<long long> s;
for(i = 0; i < nr; i++)
cin >> a[i];
for(i = 0; i < ng; i++)
cin >> b[i];
for(i = 0; i < nb; i++)
cin >> c[i];
i = j = k = 0;
sort(a,a + nr);
sort(b,b + ng);
sort(c,c + nb);
while(i < nr && j < ng && k < nb)
{
long long mx = max(a[i],max(b[j],c[k]));
long long mn = min(a[i],min(b[j],c[k]));
long long sum = a[i] + b[j] + c[k];
if(mx - mn < diff)
{
s.clear();
diff = (mx - mn);
rmx = mx;
rmn = mn;
rmd = sum - (mx + mn);
if(rmd == a[i])
s.push_back(0);
if(rmd == b[j])
s.push_back(1);
if(rmd == c[k])
s.push_back(2);
}
if(mn == a[i])
i++;
else if(mn == b[j])
j++;
else
k++;
}
long long ans = 2e18;
for(k = 0; k < s.size(); k++){
if(s[k] == 0)
{
for(i = 0; i < nr; i++)
ans = min(ans,(rmx - a[i])*(rmx - a[i]) + (a[i] - rmn)*(a[i] - rmn) + (rmx - rmn)*(rmx - rmn));
}
else if(s[k] == 1)
{
for(i = 0; i < ng; i++)
ans = min(ans,(rmx - b[i])*(rmx - b[i]) + (b[i] - rmn)*(b[i] - rmn) + (rmx - rmn)*(rmx - rmn));
}
else
{
for(i = 0; i < nb; i++)
ans = min(ans,(rmx - c[i])*(rmx - c[i]) + (c[i] - rmn)*(c[i] - rmn) + (rmx - rmn)*(rmx - rmn));
}
}
cout<<ans<<"\n";
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBmYXN0IGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpO2Npbi50aWUoTlVMTCk7Y291dC50aWUoTlVMTCkKaW50IG1haW4oKQp7CiAgZmFzdDsKICBpbnQgdDsKICBjaW4gPj4gdDsKICB3aGlsZSh0LS0pCiAgewogICAgbG9uZyBsb25nIG5yLG5nLG5iLGksaixrOwogICAgY2luID4+IG5yID4+IG5nID4+IG5iOwogICAgbG9uZyBsb25nIHJteCxybWQgPSAxZTkgKyA1LHJtbixhW25yXSxiW25nXSxjW25iXSxkaWZmID0gMWU5ICsgNTsKICAgIHZlY3Rvcjxsb25nIGxvbmc+IHM7CiAgICBmb3IoaSA9IDA7IGkgPCBucjsgaSsrKQogICAgICBjaW4gPj4gYVtpXTsKICAgIGZvcihpID0gMDsgaSA8IG5nOyBpKyspCiAgICAgIGNpbiA+PiBiW2ldOwogICAgZm9yKGkgPSAwOyBpIDwgbmI7IGkrKykKICAgICAgY2luID4+IGNbaV07CiAgICBpID0gaiA9IGsgPSAwOwogICAgc29ydChhLGEgKyBucik7CiAgICBzb3J0KGIsYiArIG5nKTsKICAgIHNvcnQoYyxjICsgbmIpOwogICAgd2hpbGUoaSA8IG5yICYmIGogPCBuZyAmJiBrIDwgbmIpCiAgICB7CiAgICAgIGxvbmcgbG9uZyBteCA9IG1heChhW2ldLG1heChiW2pdLGNba10pKTsKICAgICAgbG9uZyBsb25nIG1uID0gbWluKGFbaV0sbWluKGJbal0sY1trXSkpOwogICAgICBsb25nIGxvbmcgc3VtID0gYVtpXSArIGJbal0gKyBjW2tdOwogICAgICBpZihteCAtIG1uIDwgZGlmZikKICAgICAgewogICAgICAgIHMuY2xlYXIoKTsKICAgICAgICBkaWZmID0gKG14IC0gbW4pOwogICAgICAgIHJteCA9IG14OwogICAgICAgIHJtbiA9IG1uOwogICAgICAgIHJtZCA9IHN1bSAtIChteCArIG1uKTsKICAgICAgICBpZihybWQgPT0gYVtpXSkKICAgICAgICAgICAgcy5wdXNoX2JhY2soMCk7CiAgICAgICAgaWYocm1kID09IGJbal0pCiAgICAgICAgICAgIHMucHVzaF9iYWNrKDEpOwogICAgICAgIGlmKHJtZCA9PSBjW2tdKQogICAgICAgICAgICBzLnB1c2hfYmFjaygyKTsKICAgICAgfQogICAgICBpZihtbiA9PSBhW2ldKQogICAgICAgIGkrKzsKICAgICAgZWxzZSBpZihtbiA9PSBiW2pdKQogICAgICAgIGorKzsKICAgICAgZWxzZQogICAgICAgIGsrKzsKICAgIH0KICAgIGxvbmcgbG9uZyBhbnMgPSAyZTE4OwogICAgZm9yKGsgPSAwOyAgayA8IHMuc2l6ZSgpOyBrKyspewogICAgaWYoc1trXSA9PSAwKQogICAgewogICAgICAgIGZvcihpID0gMDsgaSA8IG5yOyBpKyspCiAgICAgICAgICAgIGFucyA9IG1pbihhbnMsKHJteCAtIGFbaV0pKihybXggLSBhW2ldKSArIChhW2ldIC0gcm1uKSooYVtpXSAtIHJtbikgKyAocm14IC0gcm1uKSoocm14IC0gcm1uKSk7CiAgICB9CiAgICBlbHNlIGlmKHNba10gPT0gMSkKICAgIHsKICAgICAgICBmb3IoaSA9IDA7IGkgPCBuZzsgaSsrKQogICAgICAgICAgICBhbnMgPSBtaW4oYW5zLChybXggLSBiW2ldKSoocm14IC0gYltpXSkgKyAoYltpXSAtIHJtbikqKGJbaV0gLSBybW4pICsgKHJteCAtIHJtbikqKHJteCAtIHJtbikpOwogICAgfQogICAgZWxzZQogICAgewogICAgICAgIGZvcihpID0gMDsgaSA8IG5iOyBpKyspCiAgICAgICAgICAgIGFucyA9IG1pbihhbnMsKHJteCAtIGNbaV0pKihybXggLSBjW2ldKSArIChjW2ldIC0gcm1uKSooY1tpXSAtIHJtbikgKyAocm14IC0gcm1uKSoocm14IC0gcm1uKSk7CiAgICB9CiAgICB9CiAgICBjb3V0PDxhbnM8PCJcbiI7CiAgfQogIHJldHVybiAwOwp9CiA=
Main.java:1: error: illegal character: '#'
#include<bits/stdc++.h>
^
Main.java:1: error: class, interface, or enum expected
#include<bits/stdc++.h>
^
Main.java:3: error: illegal character: '#'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
^
Main.java:3: error: class, interface, or enum expected
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
^
Main.java:7: error: class, interface, or enum expected
int t;
^
Main.java:8: error: class, interface, or enum expected
cin >> t;
^
Main.java:9: error: class, interface, or enum expected
while(t--)
^
Main.java:12: error: class, interface, or enum expected
cin >> nr >> ng >> nb;
^
Main.java:13: error: class, interface, or enum expected
long long rmx,rmd = 1e9 + 5,rmn,a[nr],b[ng],c[nb],diff = 1e9 + 5;
^
Main.java:14: error: class, interface, or enum expected
vector<long long> s;
^
Main.java:15: error: class, interface, or enum expected
for(i = 0; i < nr; i++)
^
Main.java:15: error: class, interface, or enum expected
for(i = 0; i < nr; i++)
^
Main.java:15: error: class, interface, or enum expected
for(i = 0; i < nr; i++)
^
Main.java:17: error: class, interface, or enum expected
for(i = 0; i < ng; i++)
^
Main.java:17: error: class, interface, or enum expected
for(i = 0; i < ng; i++)
^
Main.java:17: error: class, interface, or enum expected
for(i = 0; i < ng; i++)
^
Main.java:19: error: class, interface, or enum expected
for(i = 0; i < nb; i++)
^
Main.java:19: error: class, interface, or enum expected
for(i = 0; i < nb; i++)
^
Main.java:19: error: class, interface, or enum expected
for(i = 0; i < nb; i++)
^
Main.java:21: error: class, interface, or enum expected
i = j = k = 0;
^
Main.java:22: error: class, interface, or enum expected
sort(a,a + nr);
^
Main.java:23: error: class, interface, or enum expected
sort(b,b + ng);
^
Main.java:24: error: class, interface, or enum expected
sort(c,c + nb);
^
Main.java:25: error: class, interface, or enum expected
while(i < nr && j < ng && k < nb)
^
Main.java:28: error: class, interface, or enum expected
long long mn = min(a[i],min(b[j],c[k]));
^
Main.java:29: error: class, interface, or enum expected
long long sum = a[i] + b[j] + c[k];
^
Main.java:30: error: class, interface, or enum expected
if(mx - mn < diff)
^
Main.java:33: error: class, interface, or enum expected
diff = (mx - mn);
^
Main.java:34: error: class, interface, or enum expected
rmx = mx;
^
Main.java:35: error: class, interface, or enum expected
rmn = mn;
^
Main.java:36: error: class, interface, or enum expected
rmd = sum - (mx + mn);
^
Main.java:37: error: class, interface, or enum expected
if(rmd == a[i])
^
Main.java:39: error: class, interface, or enum expected
if(rmd == b[j])
^
Main.java:41: error: class, interface, or enum expected
if(rmd == c[k])
^
Main.java:43: error: class, interface, or enum expected
}
^
Main.java:46: error: class, interface, or enum expected
else if(mn == b[j])
^
Main.java:48: error: class, interface, or enum expected
else
^
Main.java:50: error: class, interface, or enum expected
}
^
Main.java:52: error: class, interface, or enum expected
for(k = 0; k < s.size(); k++){
^
Main.java:52: error: class, interface, or enum expected
for(k = 0; k < s.size(); k++){
^
Main.java:52: error: class, interface, or enum expected
for(k = 0; k < s.size(); k++){
^
Main.java:55: error: class, interface, or enum expected
for(i = 0; i < nr; i++)
^
Main.java:55: error: class, interface, or enum expected
for(i = 0; i < nr; i++)
^
Main.java:57: error: class, interface, or enum expected
}
^
Main.java:60: error: class, interface, or enum expected
for(i = 0; i < ng; i++)
^
Main.java:60: error: class, interface, or enum expected
for(i = 0; i < ng; i++)
^
Main.java:62: error: class, interface, or enum expected
}
^
Main.java:65: error: class, interface, or enum expected
for(i = 0; i < nb; i++)
^
Main.java:65: error: class, interface, or enum expected
for(i = 0; i < nb; i++)
^
Main.java:67: error: class, interface, or enum expected
}
^
Main.java:70: error: class, interface, or enum expected
}
^
Main.java:72: error: class, interface, or enum expected
}
^
54 errors