#include <bits/stdc++.h>   using namespace std;   int r[100005], g[100005], b[100005], nr, ng, nb, pos;   long long ans = 9e18;   long long calc(long long a, long long b, long long c) {     long long temp = (a - b) * (a - b) + (a - c) * (a - c) + (b - c) * (b - c);     return temp;   }   int bsearch(int a[], int len, int k) {     int l = 1, r = len, mid, ans = 0;     while (l < r) {       mid = (l + r) >> 1;       if (a[mid] > k)         r = mid;       else if (a[mid] == k)         return mid;       else {         if (a[mid + 1] > k)           return mid;         else if (a[mid + 1] == k)           return mid + 1;         else           l = mid + 1;       }     }     return l;   }   void check(int a[], int b[], int c[], int lena, int lenb, int lenc) {     int i, aa, bb, cc1, cc2, pos;     for (i = 1; i <= lena; i++) {       aa = a[i];       pos = lower_bound(b + 1, b + lenb + 1, aa) - b;       if (!(pos >= 1 && pos <= lenb && b[pos] >= aa)) continue;       bb = b[pos];       int mid = (aa + bb) / 2;       pos = lower_bound(c + 1, c + lenc + 1, mid) - c;       if (pos >= 1 && pos <= lenc && c[pos] >= mid) {         cc1 = c[pos];         ans = min(ans, calc((long long)aa, (long long)bb, (long long)cc1));       }       pos = bsearch(c, lenc, mid);       if (pos <= lenc && pos >= 1 && c[pos] <= mid) {         cc2 = c[pos];         ans = min(ans, calc((long long)aa, (long long)bb, (long long)cc2));       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       ans = 9e18;       int i;       scanf( %d%d%d , &nr, &ng, &nb);       for (i = 1; i <= nr; i++) scanf( %d , &r[i]);       for (i = 1; i <= ng; i++) scanf( %d , &g[i]);       for (i = 1; i <= nb; i++) scanf( %d , &b[i]);       sort(r + 1, r + nr + 1), sort(g + 1, g + ng + 1), sort(b + 1, b + nb + 1);       check(r, g, b, nr, ng, nb);       check(r, b, g, nr, nb, ng);       check(g, r, b, ng, nr, nb);       check(g, b, r, ng, nb, nr);       check(b, r, g, nb, nr, ng);       check(b, g, r, nb, ng, nr);       cout << ans << endl;     }     return 0;   }   