#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define y0 y_0
#define y1 y_1
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

signed main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const int MAXN = 2 * 16385;

ll n, m;
bool val[MAXN];
short t[MAXN];
ll find(ll v) {
	if (v == t[v]) {
		return v;
	}
	return t[v] = find(t[v]);
}
ll join(ll v, ll u) {
	v = find(v), u = find(u);
	if (v == u) {
		return 0;
	}
	t[u] = v;
	return 1;
}
void shift() {
	for (ll i = 0; i < m; i++) {
		t[i] = t[i + m] - m;
		val[i] = val[i + m];
		t[i + m] = i + m;
		val[i + m] = 0;
	}
}
bool checkbit(ll n, ll p) {
	return n & (1ll << p);
}
ll get(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 10 + c - 'A';
}

inline void solve() {
	for (ll i = 0; i < 2 * m; i++) {
		t[i] = i;
	}
	ll cnt1 = 0;
	ll cntm = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m / 4; j++) {
			char c;
			cin >> c;
			ll v = get(c);
			for (ll k = 0; k < 4; k++) {
				val[m + j * 4 + k] = checkbit(v, 3 - k);
				cnt1 += checkbit(v, 3 - k);
			}
		}
		for (ll i = 0; i < m; i++) {
			if (val[i] && val[i + m]) {
				cntm += join(i, i + m);
			}
			if (i && val[i + m] && val[i - 1 + m]) {
				cntm += join(i - 1 + m, i + m);
			}
		}
		shift();
	}
	ll ans = cnt1 - cntm;
	cout << ans << endl;
}

inline void read() {
	cin >> n >> m;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define y0 y_0
#define y1 y_1
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

signed main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const int MAXN = 2 * (1ll << 14);

ll n, m;
bitset<MAXN> val;
short t[MAXN];
ll find(ll v) {
	if (v == t[v]) {
		return v;
	}
	return t[v] = find(t[v]);
}
ll join(ll v, ll u) {
	v = find(v), u = find(u);
	if (v == u) {
		return 0;
	}
	t[u] = v;
	return 1;
}
void shift() {
	for (ll i = 0; i < m; i++) {
		t[i] = t[i + m] - m;
		val[i] = val[i + m];
		t[i + m] = i + m;
		val[i + m] = 0;
	}
}
bool checkbit(ll n, ll p) {
	return n & (1ll << p);
}
ll get(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 10 + c - 'A';
}

inline void solve() {
	for (ll i = 0; i < 2 * m; i++) {
		t[i] = i;
	}
	ll cnt1 = 0;
	ll cntm = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m / 4; j++) {
			char c;
			cin >> c;
			ll v = get(c);
			for (ll k = 0; k < 4; k++) {
				val[m + j * 4 + k] = checkbit(v, 3 - k);
				cnt1 += checkbit(v, 3 - k);
			}
		}
		for (ll i = 0; i < m; i++) {
			if (val[i] && val[i + m]) {
				cntm += join(i, i + m);
			}
			if (i && val[i + m] && val[i - 1 + m]) {
				cntm += join(i - 1 + m, i + m);
			}
		}
		shift();
	}
	ll ans = cnt1 - cntm;
	cout << ans << endl;
}

inline void read() {
	cin >> n >> m;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define y0 y_0
#define y1 y_1
using namespace std;
typedef int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

signed main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const ll MAXN = 2 * (1ll << 14);

struct dsu {
	ll n;
	short t[MAXN];
	bitset<MAXN> val;
	dsu() {}
	dsu(ll n_) {
		n = n_;
		iota(t, t + MAXN, 0);
	}
	ll find(ll v) {
		if (v == t[v]) {
			return v;
		}
		return t[v] = find(t[v]);
	}
	ll join(ll v, ll u) {
		v = find(v), u = find(u);
		if (v == u) {
			return 0;
		}
		t[u] = v;
		return 1;
	}
	void shift() {
		for (ll i = 0; i < n; i++) {
			t[i] = t[i + n] - n;
			val[i] = val[i + n];
			t[i + n] = i + n;
			val[i + n] = 0;
		}
	}
};

ll n, m;
dsu d;

bool checkbit(ll n, ll p) {
	return n & (1ll << p);
}

ll get(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 10 + c - 'A';
}

inline void solve() {
	ll cnt1 = 0;
	ll cntm = 0;
	d = dsu(m);
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m / 4; j++) {
			char c;
			cin >> c;
			ll v = get(c);
			for (ll k = 0; k < 4; k++) {
				d.val[m + j * 4 + k] = checkbit(v, 3 - k);
				cnt1 += checkbit(v, 3 - k);
			}
		}
		for (ll i = 0; i < m; i++) {
			if (d.val[i] && d.val[i + m]) {
				cntm += d.join(i + m, i);
			}
			if (i && d.val[i + m] && d.val[i - 1 + m]) {
				cntm += d.join(i - 1 + m, i + m);
			}
		}
		d.shift();
	}
	ll ans = cnt1 - cntm;
	cout << ans << endl;
}

inline void read() {
	cin >> n >> m;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>
#include <random>
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(a) (a).begin(), (a).end()
#define sz(a) (ll)((a).size())
#define heap priority_queue
#define hash_map unordered_map
#define hash_set unordered_set
#define ft first
#define sd second
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define y0 y_0
#define y1 y_1
using namespace std;
typedef short ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef map<ll, ll> mll;
const ll inf = numeric_limits<ll>::max() / 2;
const ld eps = 1e-9;
const ld pi = acos(-1);
template<typename T> inline bool mineq(T& a, T b) { return (a > b) ? (a = b, 1) : 0; }
template<typename T> inline bool maxeq(T& a, T b) { return (a < b) ? (a = b, 1) : 0; }

inline void solve(), read();
const string file = "";

signed main() {
#ifndef _DEBUG
	if (file != "") {
		freopen((file + ".in").c_str(), "r", stdin);
		freopen((file + ".out").c_str(), "w", stdout);
	}
#endif
	fast;
	read();
	solve();
	return 0;
}

const int MAXN = 2 * (1ll << 14);

ll n, m;
bitset<MAXN> val;
short t[MAXN];
ll find(ll v) {
	if (v == t[v]) {
		return v;
	}
	return t[v] = find(t[v]);
}
ll join(ll v, ll u) {
	v = find(v), u = find(u);
	if (v == u) {
		return 0;
	}
	t[u] = v;
	return 1;
}
void shift() {
	for (ll i = 0; i < m; i++) {
		t[i] = t[i + m] - m;
		val[i] = val[i + m];
		t[i + m] = i + m;
		val[i + m] = 0;
	}
}
bool checkbit(ll n, ll p) {
	return n & (1ll << p);
}
ll get(char c) {
	if ('0' <= c && c <= '9') {
		return c - '0';
	}
	return 10 + c - 'A';
}

inline void solve() {
	for (ll i = 0; i < 2 * m; i++) {
		t[i] = i;
	}
	ll cnt1 = 0;
	ll cntm = 0;
	for (ll i = 0; i < n; i++) {
		for (ll j = 0; j < m / 4; j++) {
			char c;
			cin >> c;
			ll v = get(c);
			for (ll k = 0; k < 4; k++) {
				val[m + j * 4 + k] = checkbit(v, 3 - k);
				cnt1 += checkbit(v, 3 - k);
			}
		}
		for (ll i = 0; i < m; i++) {
			if (val[i] && val[i + m]) {
				cntm += join(i, i + m);
			}
			if (i && val[i + m] && val[i - 1 + m]) {
				cntm += join(i - 1 + m, i + m);
			}
		}
		shift();
	}
	ll ans = cnt1 - cntm;
	cout << ans << endl;
}

inline void read() {
	cin >> n >> m;
}


#include <bits/stdc++.h>
using namespace std;

#if 0
#define db(x) cerr<<#x<<" == "<<x<<endl
#define dbs(x) cerr<<x<<endl
#define _ <<", "<<
#else
#define db(x) ((void)0)
#define dbs(x) ((void)0)
#endif

const int M = (1<<14)+5;

int n, m;
int par[2*M];
bool v[2][M];
bool* p[2];
int ans;

int readx() {
  char c = _getchar_nolock();
  if (c == '\n') c = _getchar_nolock();
  return isdigit(c) ? c - '0' : 10 + c - 'A';
}

int find(int u) {
  return !par[u] ? u : par[u] = find(par[u]);

  /*
  if (!par[u]) return u;
  while (par[par[u]]) {
    par[u] = par[par[u]];
  }
  return par[u];
  */
}

inline void unite(int u, int v) {
  u = find(u), v = find(v);
  if (u == v) return;
  if (u > v) par[u] = v;
  else par[v] = u;
  ans--;
}

inline void add(int j) {
  if (!p[0][j]) return;
  if (p[0][j-1]) unite(j, j-1);
  if (p[1][j])   unite(j, j+m);
}

int main() {
  scanf("%d%d", &n, &m);
  p[0] = v[0]; p[1] = v[1];
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      par[j+m] = par[j];
      par[j] = 0;
      if (par[j+m]) par[j+m]+=m;
    }

    for (int j = 1; j <= m; j+=4) {
      int x = readx();
      p[0][j]   = (x&8);
      p[0][j+1] = (x&4);
      p[0][j+2] = (x&2);
      p[0][j+3] = (x&1);
      ans += p[0][j] + p[0][j+1] + p[0][j+2] + p[0][j+3];

      add(j);
      add(j+1);
      add(j+2);
      add(j+3);
    }

    swap(p[0], p[1]);
  }

  printf("%d\n", ans);
  return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;

#if 0
#define db(x) cerr<<#x<<" == "<<x<<endl
#define dbs(x) cerr<<x<<endl
#define _ <<", "<<
#else
#define db(x) ((void)0)
#define dbs(x) ((void)0)
#endif

const int M = (1<<14)+5;

int n, m;
int par[2*M];
bool v[2][M];
bool* p[2];
int ans;

int readx() {
  char c = _getchar_nolock();
  if (c == '\n') c = _getchar_nolock();
  return isdigit(c) ? c - '0' : 10 + c - 'A';
}

int find(int u) {
  return !par[u] ? u : par[u] = find(par[u]);

  /*
  if (!par[u]) return u;
  while (par[par[u]]) {
    par[u] = par[par[u]];
  }
  return par[u];
  */
}

inline void unite(int u, int v) {
  u = find(u), v = find(v);
  if (u == v) return;
  if (u > v) par[u] = v;
  else par[v] = u;
  ans--;
}

inline void add(int j) {
  if (!p[0][j]) return;
  if (p[0][j-1]) unite(j, j-1);
  if (p[1][j])   unite(j, j+m);
}

int main() {
  scanf("%d%d", &n, &m);
  p[0] = v[0]; p[1] = v[1];
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      par[j+m] = par[j];
      par[j] = 0;
      if (par[j+m]) par[j+m]+=m;
    }

    for (int j = 1; j <= m; j+=4) {
      int x = readx();
      p[0][j]   = (x&8);
      p[0][j+1] = (x&4);
      p[0][j+2] = (x&2);
      p[0][j+3] = (x&1);
      ans += p[0][j] + p[0][j+1] + p[0][j+2] + p[0][j+3];

      add(j);
      add(j+1);
      add(j+2);
      add(j+3);
    }

    swap(p[0], p[1]);
  }

  printf("%d\n", ans);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define f cin
#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return (2 * (vert + oriz)) * (2 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
    f >> n;
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
        f >> x;
        viz[x] ++;
        to_clear.push_back(x);
    }
    nr = 0;
//    g << n << '\n';
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000000003.0;

    for(int i = 1; i <= NMax; ++i){
        if(viz[i] >= 2){
//            int ind = cautbin(1,nr,i);

            for(int j = 1; j <= nr; ++j){
                if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                    mn = verif(v[j],i);
                    ans1 = v[j];
                    ans2 = i;
                }
            }
//            if(ind != -1){
//                for(int j = ind - 50; j <= ind + 50; ++j){
//                    if(j <= nr && j >= 1 && mn > verif(v[j],i)){
//                        mn = verif(v[j],i);
//                        ans1 = v[j];
//                        ans2 = i;
//                    }
//                }
//            }
//            g << mn << '\n';
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    g << ans1 << ' ' << ans1 << ' ' << ans2 << ' ' << ans2 << '\n';
}
int main(){
    f >> t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define f cin
#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];

#define DIM 10000
char buff[DIM];
int poz=0;

void cit(int &numar)
{
     numar = 0;
     //cat timp caracterul din buffer nu e cifra ignor
     while (buff[poz] < '0' || buff[poz] > '9')
          //daca am "golit" bufferul atunci il umplu
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     //cat timp dau de o cifra recalculez numarul
     while ('0'<=buff[poz] && buff[poz]<='9')
     {
          numar = numar*10 + buff[poz] - '0';
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     }
}

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return 1.0*(2.0 * (vert + oriz)) * (2.0 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
    cit(n);
    vector<int> to_clear;
    for(int i = 1; i <= n; ++i){
        cit(x);
        viz[x] ++;
        if(viz[x] == 1){
            to_clear.push_back(x);
        }
    }
    nr = 0;
//    g << n << '\n';
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000003.0;

    for(int e = 0; e < to_clear.size(); ++e){
        int i = to_clear[e];
        if(viz[i] >= 2){
            int ind = cautbin(1,nr,i);

//            if(ind != -1){
                for(int j = ind - 50; j <= ind + 50; ++j){
                    if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                        mn = verif(v[j],i);
                        ans1 = v[j];
                        ans2 = i;
                    }
                }
//            }
//            g << mn << '\n';
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
}
int main(){
    cit(t);
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//#define f cin
//#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

#define DIM 10000
char buff[DIM];
int poz=0;

void cit(int &numar)
{
     numar = 0;
     //cat timp caracterul din buffer nu e cifra ignor
     while (buff[poz] < '0' || buff[poz] > '9')
          //daca am "golit" bufferul atunci il umplu
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     //cat timp dau de o cifra recalculez numarul
     while ('0'<=buff[poz] && buff[poz]<='9')
     {
          numar = numar*10 + buff[poz] - '0';
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     }
}

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return (2 * (vert + oriz)) * (2 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
//    f >> n;
    cit(n);
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
//        f >> x;
        cit(x);
        viz[x] ++;
        to_clear.push_back(x);
    }
    nr = 0;
//    g << n << '\n';
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000000003.0;

    for(int e = 0; e < to_clear.size(); ++e){
        int i = to_clear[e];
        if(viz[i] >= 2){
            if(nr >= 1){
            for(int j = 1; j <= nr; ++j){
                if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                    mn = verif(v[j],i);
                    ans1 = v[j];
                    ans2 = i;
                }
            }
            }
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }

            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
//    g << ans1 << ' ' << ans1 << ' ' << ans2 << ' ' << ans2 << '\n';
}
int main(){
//    freopen("d.in","r",stdin);
//    freopen("d.out","w",stdout);
    cit(t);
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//#define f cin
//#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

#define DIM 10000
char buff[DIM];
int poz=0;

void cit(int &numar)
{
     numar = 0;
     //cat timp caracterul din buffer nu e cifra ignor
     while (buff[poz] < '0' || buff[poz] > '9')
          //daca am "golit" bufferul atunci il umplu
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     //cat timp dau de o cifra recalculez numarul
     while ('0'<=buff[poz] && buff[poz]<='9')
     {
          numar = numar*10 + buff[poz] - '0';
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     }
}

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return (2 * (vert + oriz)) * (2 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
//    f >> n;
    cit(n);
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
//        f >> x;
        cit(x);
//        if(viz[x] == 0){
//            to_clear.push_back(x);
//        }
        viz[x] ++;
//        to_clear.push_back(x);
    }
//    sort(to_clear.begin(),to_clear.end());
    for(int i = 1; i < NMax; ++i){
        if(viz[i] != 0){
            to_clear.push_back(i);
        }
    }
    nr = 0;
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000000003.0;

    for(int e = 0; e < to_clear.size(); ++e){
        int i = to_clear[e];
//        printf("%d\n",i);
        if(viz[i] >= 2){
            if(nr >= 1){
                for(int j = 1; j <= nr; ++j){
                    if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                        mn = verif(v[j],i);
                        ans1 = v[j];
                        ans2 = i;
                    }
                }
            }
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
}
int main(){
//    freopen("d.in","r",stdin);
//    freopen("d.out","w",stdout);
    cit(t);
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//#define f cin
//#define g cout
ifstream f("d.in");
ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return (2 * (vert + oriz)) * (2 * (vert + oriz)) / (vert * oriz);
}
void solve(){
    f >> n;
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
        f >> x;
        viz[x] ++;
        to_clear.push_back(x);
    }
    nr = 0;
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000003.0;

    for(int i = 1; i < NMax; ++i){
        if(viz[i] >= 2){
            if(nr <= 100){
//                g << nr << '\n';
                for(int j = 1; j <= nr; ++j){
                    if(mn > verif(v[j], i)){
                        mn = verif(v[j],i);
                        ans1 = v[j];
                        ans2 = i;
                    }
                }
            }else{
                int pas = sqrt(nr);
                int aici = nr / 2;
                for(int j = pas + 1; j <= nr - pas - 1; j += pas){
                    if(verif(v[j - pas],i) > verif(v[j],i) && verif(v[j],i) < verif(v[j + pas], i)){
                        aici = j;
                    }
                }
                for(int j = aici - pas; j <= aici + pas; ++j){
                    if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                        mn = verif(v[j],i);
                        ans1 = v[j];
                        ans2 = i;
                    }
                }
            }
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    g << ans1 << ' ' << ans1 << ' ' << ans2 << ' ' << ans2 << '\n';
}
int main(){
    f >> t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define f cin
#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return 1.0*(2.0 * (vert + oriz)) * (2.0 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
    f >> n;
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
        f >> x;
        viz[x] ++;
        to_clear.push_back(x);
    }
    nr = 0;
//    g << n << '\n';
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000003.0;

    for(int i = 1; i <= NMax; ++i){
        if(viz[i] >= 2){
            int ind = cautbin(1,nr,i);

//            if(ind != -1){
                for(int j = ind - 50; j <= ind + 50; ++j){
                    if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                        mn = verif(v[j],i);
                        ans1 = v[j];
                        ans2 = i;
                    }
                }
//            }
//            g << mn << '\n';
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    g << ans1 << ' ' << ans1 << ' ' << ans2 << ' ' << ans2 << '\n';
}
int main(){
    f >> t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

//#define f cin
//#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

#define DIM 10000
char buff[DIM];
int poz=0;

void cit(int &numar)
{
     numar = 0;
     //cat timp caracterul din buffer nu e cifra ignor
     while (buff[poz] < '0' || buff[poz] > '9')
          //daca am "golit" bufferul atunci il umplu
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     //cat timp dau de o cifra recalculez numarul
     while ('0'<=buff[poz] && buff[poz]<='9')
     {
          numar = numar*10 + buff[poz] - '0';
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     }
}

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return 1.0 * (2 * (vert + oriz)) * (2 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
//    f >> n;
    cit(n);
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
//        f >> x;
        cit(x);
        if(viz[x] == 0){
            to_clear.push_back(x);
        }
        viz[x] ++;
//        to_clear.push_back(x);
    }
    sort(to_clear.begin(),to_clear.end());
    nr = 0;
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000000003.0;

    for(int e = 0; e < to_clear.size(); ++e){
        int i = to_clear[e];
//        printf("%d\n",i);
        if(viz[i] >= 2){
            if(nr >= 1){
                for(int j = max(0,nr - 10); j <= nr; ++j){
                    if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                        mn = verif(v[j],i);
                        ans1 = v[j];
                        ans2 = i;
                    }
                }
            }
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
}
int main(){
//    freopen("d.in","r",stdin);
//    freopen("d.out","w",stdout);
    cit(t);
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define f cin
#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return 1.0*(2.0 * (vert + oriz)) * (2.0 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
    f >> n;
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
        f >> x;
        viz[x] ++;
        if(viz[x] == 1){
            to_clear.push_back(x);
        }
    }
    nr = 0;
//    g << n << '\n';
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000003.0;

    for(int e = 0; e < to_clear.size(); ++e){
        int i = to_clear[e];
        if(viz[i] >= 2){
            int ind = cautbin(1,nr,i);

//            if(ind != -1){
                for(int j = ind - 50; j <= ind + 50; ++j){
                    if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                        mn = verif(v[j],i);
                        ans1 = v[j];
                        ans2 = i;
                    }
                }
//            }
//            g << mn << '\n';
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    g << ans1 << ' ' << ans1 << ' ' << ans2 << ' ' << ans2 << '\n';
}
int main(){
    f >> t;
    while(t--){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define f cin
#define g cout
//ifstream f("d.in");
//ofstream g("d.out");

const int NMax = 10004;

int n,x,nr,t;
int v[NMax],viz[NMax];
vector<int> to_clear;

#define DIM 10000
char buff[DIM];
int poz=0;

void cit(int &numar)
{
     numar = 0;
     //cat timp caracterul din buffer nu e cifra ignor
     while (buff[poz] < '0' || buff[poz] > '9')
          //daca am "golit" bufferul atunci il umplu
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     //cat timp dau de o cifra recalculez numarul
     while ('0'<=buff[poz] && buff[poz]<='9')
     {
          numar = numar*10 + buff[poz] - '0';
          if (++poz == DIM)
               fread(buff,1,DIM,stdin),poz=0;
     }
}

long double verif(int vert, int oriz){
    if(vert == 0 || oriz == 0){
        return 0;
    }
    return (2 * (vert + oriz)) * (2 * (vert + oriz)) / (vert * oriz);
}
int cautbin(int lo, int hi, int len){
    int mid = (lo + hi) / 2;
    int k = 0;
    while(lo <= hi && k <= 70){
        mid = (lo + hi) / 2;
        k++;
        long double ok1 = verif(v[mid - 1], len);
        long double ok2 = verif(v[mid], len);
        long double ok3 = verif(v[mid + 1], len);
        if(mid == 1 || mid == nr){
            return mid;
        }
        if(ok1 >= ok2 && ok2 <= ok3){
            return mid;
        }else
        if(ok1 <= ok2 && ok2 <= ok3){
            lo = mid + 1;
        }else
        if(ok1 >= ok2 && ok2 >= ok3){
            hi = mid - 1;
        }
    }
    return -1;
}
void solve(){
//    f >> n;
    cit(n);
    to_clear.clear();
    for(int i = 1; i <= n; ++i){
//        f >> x;
        cit(x);
        viz[x] ++;
        to_clear.push_back(x);
    }
    nr = 0;
//    g << n << '\n';
    int ans1 = 0, ans2 = 0;
    long double mn = 1000000000003.0;

    for(int i = 1; i < NMax; ++i){
        if(viz[i] >= 2){
            for(int j = 1; j <= nr; ++j){
                if(j <= nr && j >= 1 && mn > verif(v[j],i)){
                    mn = verif(v[j],i);
                    ans1 = v[j];
                    ans2 = i;
                }
            }
            if(viz[i] >= 4){
                if(mn > verif(i,i)){
                    mn = verif(i,i);
                    ans1 = i;
                    ans2 = i;
                }
            }
            v[++nr] = i;
        }
    }
    for(int i = 0; i < to_clear.size(); ++i){
        viz[to_clear[i]] = 0;
    }
    printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
//    g << ans1 << ' ' << ans1 << ' ' << ans2 << ' ' << ans2 << '\n';
}
int main(){
//    freopen("d.in","r",stdin);
//    freopen("d.out","w",stdout);
    cit(t);
    while(t--){
        solve();
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define maxn 1e5
using namespace std;

int t,n,a[1000005],b[1000005];
int cnt[10005],ansx,ansy;
double x,minn;

int main(){
	cin>>t;
	while(t--){
		cin>>n;
		int j=1;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			++cnt[a[i]];
			if(cnt[a[i]]==2){
				b[j]=a[i];
				cnt[a[i]]=0;
				++j;
			}
		}
		sort(b+1,b+j);
		minn=maxn;
		for(int i=j-2;i>=1;i--){
			x=double(b[i+1])/double(b[i]);
			if(x<minn){
				minn=x;
				ansx=b[i]; ansy=b[i+1];
			}
		}
		cout<<ansx<<" "<<ansx<<" "<<ansy<<" "<<ansy<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int maxn = 15000000;
const int M = 1e9+7;

ll cnt[10010];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	ll t;
	cin>>t;
	for (ll k=1; k<=t; k++){
		memset(cnt,0,sizeof(cnt));
		ll n;
		cin>>n;
		for (ll i=1; i<=n; i++){
			ll a;
			cin>>a;
			cnt[a]++;
		}
		ll f=0,p=0,a=0,b=0;
		for (ll i=1; i<=10000; i++){
			if (cnt[i]>=4){
				f=1;
				cout<<i<<' '<<i<<' '<<i<<' '<<i<<endl;
				break;
			}
			if (cnt[i]>=2 && cnt[i]<4){
//				dd(p),de(i);
				if (p){
					if ((a==0 && b==0) || (a*a+b*b)*p*i>=(i*i+p*p)*a*b){
						a=p;
						b=i;
					}
				}
				p=i;
			}
		}
		if (!f){
			cout<<a<<' '<<a<<' '<<b<<' '<<b<<endl;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int t, n, x, y;
vector <double> vt;
map <int, int>  cnt;
double minn;
int main() {
	scanf("%d", &t);
	while(t --) {
		minn = 1e9;
		cnt.clear(); vt.clear();
		scanf("%d", &n);
		for(int i = 1; i <= n; i ++) {
			int len; scanf("%d", &len);
			cnt[len] ++;
			if(cnt[len] == 2 || cnt[len] == 4)
				vt.push_back(len);
		}
		sort(vt.begin(), vt.end());
		for(int i = 0; i < vt.size() - 1; i ++)
			if(minn > vt[i + 1] / vt[i]) {
				x = vt[i + 1], y = vt[i];
				minn =  x / y;
			}
		printf("%d %d %d %d\n", x, x, y, y);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool mark[100005];
int n,m,t,ans1,ans2,i,j;
double res,minn;
priority_queue<int> q;
int main()
{
	int x,y;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(i=1;i<=10000;i++)mark[i]=false;
		for(i=1;i<=n;i++)
		{
			scanf("%d",&x);
			if(mark[x]){
				q.push(x);
				mark[x]=0;
			}
			else mark[x]=1;
		}
		x=1e9;
		minn=1e9;
		while(!q.empty())
		{
			y=q.top();q.pop();
			res=1.0*(x-y)*(x-y)/(1.0*x*y);
			if(res<minn){
				ans1=x;
				ans2=y;
				minn=res;
			}
			x=y;
		}
		printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = a; i < n; ++i)
#define mst(a, b) memset(a, b, sizeof a)
typedef long long ll;
inline int read() {
    int c = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        c = c * 10 + ch - '0';
        ch = getchar();
    }
    return c * f;
}
const int N = 1e6 + 10;
int b[N], tot = -1;
map<int, int> m;
int main() {
    int T = read();
    while (T--) {
        int n = read();
        m.clear();
        tot = -1;
        REP(i, 0, n) m[read()]++;
        int id = -1;
        for (auto &&it : m) {
            if (it.second >= 2) b[++tot] = it.first;
            if (it.second >= 4) {
                id = it.first;
                break;
            }
        }
        if (id != -1) {
            printf("%d %d %d %d\n", id, id, id, id);
            continue;
        }
        ll zi = b[0] * b[0] + b[1] * b[1], mu = b[0] * b[1], _zi, _mu;
        id = 0;
        REP(i, 1, tot) {
            _zi = b[i] * b[i] + b[i + 1] * b[i + 1];
            _mu = b[i] * b[i + 1];
            if (_zi * mu < zi * _mu) id = i;
        }
        printf("%d %d %d %d\n", b[id], b[id], b[id + 1], b[id + 1]);
    }
}


#include<bits/stdc++.h>
using namespace std;
bool mark[100005];
int n,m,t,ans1,ans2,i,j;
double res,minn;
priority_queue<int> q;
int main()
{
	int x,y;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(i=1;i<=n;i++)
		{
			scanf("%d",&x);
			if(mark[x]){
				q.push(x);
				mark[x]=0;
			}
			else mark[x]=1;
		}
		x=1e9;
		minn=1e9;
		while(!q.empty())
		{
			y=q.top();q.pop();
			res=1.0*(x-y)*(x-y)/(1.0*x*y);
			if(res<minn){
				ans1=x;
				ans2=y;
				minn=x-y;
			}
			x=y;
		}
		printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define maxn 1e5
using namespace std;

int t,n,a[1000005],b[1000005];
int cnt[10005],ansx,ansy;
double x,minn;

int main(){
	cin>>t;
	while(t--){
		cin>>n;
		int j=1;
		for(int i=1;i<=n;i++){
			cin>>a[i];
			++cnt[a[i]];
			if(cnt[a[i]]==2){
				b[j]=a[i];
				cnt[a[i]]=0;
				++j;
			}
		}
		sort(b+1,b+j);
		minn=maxn;
		for(int i=j-2;i>=1;i--){
			x=double(b[i+1]/b[i]);
			if(x<minn){
				minn=x;
				ansx=b[i]; ansy=b[i+1];
			}
		}
		cout<<ansx<<" "<<ansx<<" "<<ansy<<" "<<ansy<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool mark[100005];
long long n,m,t,ans1,ans2,i,j;
double res,minn;
priority_queue<int> q;
int main()
{
	int x,y;
	scanf("%lld",&t);
	while(t--)
	{
		scanf("%lld",&n);
		for(i=1;i<=n;i++)mark[i]=0;
		for(i=1;i<=n;i++)
		{
			scanf("%lld",&x);
			if(mark[x]){
				q.push(x);
				mark[x]=0;
			}
			else mark[x]=1;
		}
		x=1e9;
		minn=1e9;
		while(!q.empty())
		{
			y=q.top();q.pop();
			res=1.0*(x-y)*(x-y)/(1.0*x*y);
			if(res<minn){
				ans1=x;
				ans2=y;
				minn=res;
			}
			x=y;
		}
		printf("%lld %lld %lld %lld\n",ans1,ans1,ans2,ans2);
	}
	return 0;
}


//coder: Feliks*GM-YB
#include<bits/stdc++.h>
#define fu(i,a,b) for(int i = a, I = (b) + 1; i < I; ++i)
#define fd(i,a,b) for(int i = a, I = (b) - 1; i > I; --i)
#define gc getchar
typedef long long ll;
using namespace std;
const int N=1e6+5;
namespace rd{
	const int BUF=1<<21;
	char rB[BUF],*rS,*rT;
	inline char gcc(){
		return rS==rT&&(rT=(rS=rB)+fread(rB,1,BUF,stdin),rS==rT)?EOF:*rS++;
	}inline int read(){
	    int x=0;char ch=gc();
	    while(!isdigit(ch))ch=gc();
	    while(isdigit(ch))x=(x<<1)+(x<<3)+ch-'0',ch=gc();
	    return x;
	}
}using namespace rd;
int T,n;
int a[N],p[N],b[N],cnt;
bool vis[N];
int ans1,ans2;
inline void init(){
	memset(p,0,sizeof(p));
	memset(vis,0,sizeof(vis));
	cnt=0;
}
int main(){
	T=read();
	while(T--){
		init();
		n=read();
		fu(i,1,n){
			a[i]=read();
			p[a[i]]++;
		}fu(i,1,n){
			if(vis[a[i]])continue;
			if(p[a[i]]>=2)b[++cnt]=a[i];
			if(p[a[i]]>=4)b[++cnt]=a[i];
			vis[a[i]]=1;
		}sort(b+1,b+cnt+1);
		ans1=b[1],ans2=b[2];
		fu(i,2,cnt-1)
			if(1LL*b[i]*ans2>1LL*b[i+1]*ans1)ans1=b[i],ans2=b[i+1];
		printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
	}
	return 0;
}


#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<queue>
#include<iostream>
using namespace std;
const int maxm=1e6+7;
int t,n,cnt;
int a[maxm];
int num[10007];
int ans1,ans2;
int main()
{
 scanf("%d",&t);
 while(t--)
 {
  scanf("%d",&n);
  memset(num,0,sizeof(num));
  cnt=0;
  for(int i=1;i<=n;i++)
  {
  	int x;
    scanf("%d",&x);
	num[x]++;
	if(num[x]>=2)
	a[++cnt]=x;
  }
  sort(a+1,a+cnt+1);
  int minn=100000000;
  for(int i=1;i<cnt;i++)
  {
  	if(num[a[i]]>=4)
  	{
  	  ans1=a[i];
	  ans2=a[i];
	  break;
  	}
  	else
  	{
  		if(minn>a[i+1]-a[i])
  		{
  		   ans1=a[i];
		   ans2=a[i+1];
		   minn=a[i+1]-a[i];
  		}
  	}
  }
 printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
 }
 return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define dd(x) cout << #x << "=" << x << ","
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b-1);i>=a;--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl "\n"
#define lowbit(x) x&(-x)
const int maxn = 15000000;
const int M = 1e9+7;

ll cnt[10010];
vector<ll> b;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	ll t;
	cin>>t;
	for (ll k=1; k<=t; k++){
		memset(cnt,0,sizeof(cnt));
		b.clear();
		ll n;
		cin>>n;
		ll f=0;
		for (ll i=1; i<=n; i++){
			ll a;
			cin>>a;
			cnt[a]++;
			if (cnt[a]>=4){
				f=a;
			}
			if (cnt[a]==2){
				b.pb(a);
			}
		}
		if (f){
			cout<<f<<' '<<f<<' '<<f<<' '<<f<<endl;
			break;
		}
		sort(all(b));
		ll x=b[0],y=b[1];
		for (ll i=1; i<sz(b); i++){
			if ((x*x+y*y)*b[i]*b[i-1]>(b[i]*b[i]+b[i-1]*b[i-1])*x*y){
				x=b[i-1];
				y=b[i];
			}
		}
		cout<<x<<' '<<x<<' '<<y<<' '<<y<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool mark[100005];
int n,m,t,ans1,ans2,i,j;
double res,minn;
priority_queue<int> q;
int main()
{
	int x,y;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(i=1;i<=n;i++)mark[i]=0;
		for(i=1;i<=n;i++)
		{
			scanf("%d",&x);
			if(mark[x]){
				q.push(x);
				mark[x]=0;
			}
			else mark[x]=1;
		}
		x=1e9;
		minn=1e9;
		while(!q.empty())
		{
			y=q.top();q.pop();
			res=1.0*(x-y)*(x-y)/(1.0*x*y);
			if(res<minn){
				ans1=x;
				ans2=y;
				minn=res;
			}
			x=y;
		}
		printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
	}
	return 0;
}


#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll maxn=1e6+10;
ll n,T,cnt,a[maxn],b[maxn];
int main()
{
    ios::sync_with_stdio(0);
    cin >> T;
    while(T--)
	{
        cnt=0;
        cin>>n;
        for(ll i=1; i<=n; i++)
		{
            cin>>a[i];
        }
        sort(a+1,a+n+1);
        bool flag=false;
        for(ll i=1;i<=n;i++)
		{
            if(!flag)
			{
                flag = true;
            }
			else
			{
            	if(a[i]==a[i-1])
				{
                    b[++cnt]=a[i];
                    flag=false;
            	}
            }
        }
        double ans=1e9;
        ll x,y;
        for(ll i=1;i<cnt;i++)
		{
            if(ans>(b[i+1]*1.0)/b[i]+(b[i]*1.0)/b[i+1])
			{
                ans=(b[i+1]*1.0)/b[i]+(b[i]*1.0)/b[i+1];
                x=b[i],y=b[i+1];
            }
        }
        cout<<x<<" " <<x<<" "<<y<<" "<<y<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<vector>
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define N 100001
#define MOD 1e9+7
#define E 1e-6
#define LL long long
using namespace std;
const int MAXN=1e4+5;
int a[MAXN];
int vis[MAXN];
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        memset(a,0,sizeof(a));
        memset(vis,0,sizeof(vis));

        int n;
        scanf("%d",&n);

        int k=0;
        bool flag=true;
        for(int i=0;i<n;i++)
        {
            int d;
            scanf("%d",&d);
            vis[d]++;

            if(vis[d]==4&&flag)
            {
                printf("%d %d %d %d\n",d,d,d,d);
                flag=false;
            }

            if(vis[d]==2&&flag)
                a[k++]=d;
        }

        if(flag)
        {
            sort(a,a+k);
            double minn=INF;
            int ans1,ans2;
            for(int i=0;i<k-1;i++)
            {
                double temp=(double)a[i]/a[i+1]+(double)a[i+1]/a[i];
                if(temp<minn)
                {
                    minn=temp;
                    ans1=a[i];
                    ans2=a[i+1];
                }
            }
            printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool mark[100005];
int n,m,t,ans1,ans2,i,j;
double res,minn;
priority_queue<int> q;
int main()
{
	int x,y;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(i=1;i<=n;i++)
		{
			scanf("%d",&x);
			if(mark[x]){
				q.push(x);
				mark[x]=0;
			}
			else mark[x]=1;
		}
		x=1e9;
		minn=1e9;
		while(!q.empty())
		{
			y=q.top();q.pop();
			res=1.0*(x-y)*(x-y)/(1.0*x*y);
			if(res<minn){
				ans1=x;
				ans2=y;
				minn=res;
			}
			x=y;
		}
		printf("%d %d %d %d\n",ans1,ans1,ans2,ans2);
	}
	return 0;
}


#include<bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define For(i, k, j) for(int i = (k); i <= (j); i++)
#define INF 2147483647
using namespace std;
inline int read()
{
    int num = 0;
    char c=' ';
    bool flag = 1;
    for(;c>'9'||c<'0';c=getchar()) if(c=='-') flag = -1;
    for(;c>='0'&&c<='9';num=(num<<1)+(num<<3)+c-48,c=getchar());
    return num * flag;
}
#define N 1000005
double a[N];
double calc(double a, double b) {
	return (2*a+2*b) * (2*a+2*b) / a / b;
}
int main()
{
	int _ = read(), lstn = 0;
	while(_--) {
		For(i, 1, lstn) a[i] = 0;
		int n = read();
		lstn = n;
		For(i, 1, n) {
			a[i] = read();
		}
		sort(a + 1, a + 1 + n) ;
		int ak1, ak2;
		double ans = INF/2;
		For(i, 1, n) {
			if(a[i] == a[i+1]) {
				For(j, i+2, n) {
					if(a[j] == a[j+1]) {
						if(ans > calc(a[i], a[j])) {
//							cout << i <<' ' <<j << endl;
							ans = calc(a[i], a[j]);
							ak1 = i, ak2 = j;
						}
						break;
					}
				}
			}
		}
		printf("%.0lf %.0lf %.0lf %.0lf\n", a[ak1], a[ak1], a[ak2], a[ak2]);
	}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1000008;
int m,n,a[N],minc,place;
int main(){
	scanf("%d",&m);
	for(int i=1;i<=m;i++){
		scanf("%d",&n);
		for(int i=1;i<=n;i++)scanf("%d",&a[i]);
		sort(a+1,a+n+1);minc=1000000;
//		for(int i=1;i<=n;i++)printf("%d ",a[i]);
//		printf("\n");
		for(int i=1;i<=n-3;i++){
			if(a[i]==a[i+1]&&a[i+2]==a[i+3]){
				if(minc>a[i+2]-a[i]){
					minc=a[i+2]-a[i];place=i;
				}
			}
		}
		printf("%d %d %d %d\n",a[place],a[place+1],a[place+2],a[place+3]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long tiska,krulia,num,flag,ba,bb;
long long a[87488339],b[87488339];
int main()
{
	scanf("%lld",&tiska);
	while(tiska--)
	{
		num=0;
		scanf("%lld",&krulia);
		for(long long i=1;i<=krulia;i++)
			scanf("%lld",&a[i]);
		sort(a+1,a+krulia+1);
		flag=false;
		for(long long i=1;i<=krulia;i++)
			if(!flag)flag=true;
			else if(a[i]=a[i-1])
			{
				flag=false;
				b[++num]=a[i];
			}
		double ans=1e9;
        long long x, y;
        for(long long i=1;i<=num;i++)
            if(ans>(b[i+1]*1.0)/b[i]+(b[i]*1.0)/b[i+1])
			{
                ans=(b[i+1]*1.0)/b[i]+(b[i]*1.0)/b[i+1];
                x=b[i],y=b[i+1];
            }
		printf("%lld %lld %lld %lld\n",x,x,y,y);
	}
}


/*
 * @Author: Lenstar
 * @Date: 2019-11-24 11:05:51
 * @LastEditTime: 2019-11-24 11:47:21
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \C++\vjudge\贪心\F.cpp
*/
#include <bits/stdc++.h>
using namespace std;
#define M 10010
#define N 100010
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
int vis[M],val[N];
int main() {
    int T=read();
    while (T--) {
        int n=read(),cnt=0;
        memset(vis,0,sizeof(vis));
        for (int i=1;i<=n;i++) {
            int x=read();
            vis[x]++;
            if (vis[x]==2 || vis[x]==4) val[++cnt]=x;
        }
        sort(val+1,val+cnt+1);
        int a=1,b=0;
        for (int i=2;i<=cnt;i++) {
            if (val[i]*b<val[i-1]*a) a=val[i],b=val[i-1];
        }
        printf("%d %d %d %d\n",a,a,b,b);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for (int i = a; i < n; ++i)
#define mst(a, b) memset(a, b, sizeof a)
typedef long long ll;
inline int read() {
    int c = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        c = c * 10 + ch - '0';
        ch = getchar();
    }
    return c * f;
}
const int N = 1e6 + 10;
int b[N], tot = -1;
map<int, int> m;
int main() {
    int T = read();
    while (T--) {
        int n = read();
        m.clear();
        tot = -1;
        REP(i, 0, n) m[read()]++;
        int id = -1;
        for (auto &&it : m) {
            if (it.second >= 2) b[++tot] = it.firtst;
            if (it.second >= 4) {
                id = it.first;
                break;
            }
        }
        if (id != -1) {
            printf("%d %d %d %d\n", id, id, id, id);
            continue;
        }
        ll zi = b[0] * b[0] + b[1] * b[1], mu = b[0] * b[1], _zi, _mu;
        id = 0;
        REP(i, 1, tot) {
            _zi = b[i] * b[i] + b[i + 1] * b[i + 1];
            _mu = b[i] * b[i + 1];
            if (_zi * mu < zi * _mu) id = i;
        }
        printf("%d %d %d %d\n", b[id], b[id], b[id + 1], b[id + 1]);
    }
}


 #include <set>
#include <map>
#include <iostream>
#include <cstdio>
using namespace std;
#define INF 99999999
#define for(a,b) for(int i=a;i<=b;++i)
map<int,int> mp;
set<int>s;
inline int read()
{
    char x;
    while((x = getchar())<'0' || x>'9');
    int u = x-'0';
    while((x = getchar())>='0' && x<='9') u = (u<<3)+(u<<1)+x-'0';
    return u;
}
int main(){
    int n,m,T;
    int x,y;
    T = read();
    while(T--){
        mp.clear();
        s.clear();
        n = read();
        int flag = 0;
        for(1,n){
            m = read();
            mp[m]++;
            if(mp[m]>=2) s.insert(m);
            if(mp[m]>=4) {
                    flag = m;
            }
         }
         if(flag || s.size()==1){
            printf("%d %d %d %d\n",flag,flag,flag,flag);
         }
         else{
            int w = *s.begin();
            s.erase(s.begin());
            int h = *s.begin();
            s.erase(s.begin());
            x = w;
            y = h;
            double ans =100000000000;
            while(!s.empty()){
                double sum = (double)w*1.0/h*1.0+(double)h*1.0/w*1.0;
                if(sum < ans){
                    ans = sum;
                    x = w;
                    y = h;
                }
                w = h;
                h = *s.begin();
                s.erase(s.begin());
            }
            printf("%d %d %d %d\n",x,x,y,y);
         }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=1000005;
double calc(int a,int b){
    return (double)a/(double)b+(double)b/(double)a;
}
int q,n,a[MAXN],ans1,ans2;
bool flag;
map<int,int> m;
vector<int> v;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>q;
    while(q--){
        m.clear();
        v.clear();
        //cerr<<"IN"<<endl;
        cin>>n;
        memset(a,0,sizeof(int)*n);
        for(int i=0;i<n;i++){
            cin>>a[i];
            m[a[i]]++;
        }
        flag=0;
        sort(a,a+n);
        int tmp=unique(a,a+n)-a;
        //cerr<<"NEW END POS "<<tmp<<endl<<"SORTED ARRAY"<<endl;
        for(int i=0;i<tmp;i++){
            //cerr<<setw(5)<<a[i]<<'('<<m[a[i]]<<')'<<' ';
        }
        //cerr<<endl;
        for(int i=0;i<tmp;i++){
            //cerr<<"THE "<<i<<" ONE IS "<<a[i]<<" AND TIME "<<m[a[i]]<<endl;
            if(m[a[i]]>1){
                if(m[a[i]]>3){
                    //cerr<<"PRE OUT"<<endl;
                    for(int j=1;j<=4;j++) cout<<a[i]<<' ';
                    //cerr<<endl;
                    flag=1;
                    break;
                }
                //cerr<<"NORMAL VAR FOUND "<<a[i]<<endl;
                v.push_back(a[i]);
            }
        }
        if(!flag){
            double res=(int)1e9+5;
            tmp=v.size();
            for(int i=0;i<tmp;i++){
                double tmp2=calc(v[i],v[i-1]);
                if(res>tmp2){
                    res=tmp2;
                    ans1=v[i];
                    ans2=v[i-1];
                }
            }
            //cerr<<"NORMAL OUT"<<endl;
            cout<<ans2<<' '<<ans1<<' '<<ans1<<' '<<ans2<<' '<<endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,cad[1000005],cntn;
double mina=1e10;
int min_num;
int main()
{
	int T;
	cin>>T;
	while(T--)
	{;
		cntn=0;
		mina=1e10; map <int,int> h;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			int t;
			scanf("%d",&t);
			h[t]++;
			if(h[t]==2)
			{
				h[t]-=2;
				cad[cntn++]=t;
			}
		}
		sort(cad,cad+cntn);
		for(int i=0;i<cntn;i++)
		{
			if(cad[i]==cad[i+1])
			{
				min_num=i;
				break;
			}
			double ratio=2*(cad[i]+cad[i+1])*2*(cad[i]+cad[i+1]);
			ratio/=cad[i]*cad[i+1];
			if(ratio<mina)
			{
				min_num=i;
				mina=ratio;
			}
		}
		printf("%d %d %d %d\n",cad[min_num],cad[min_num],cad[min_num+1],cad[min_num+1]);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int a[1000007],f[10007],n,ansa,ansb,m;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		double minn=1.79769e+308;
		ansa=0;
		ansb=0;
		scanf("%d",&m);
		for(int j=1;j<=m;j++){
			scanf("%d",&a[j]);
			f[a[j]]++;
		}
		sort(a+1,a+m+1);
		for(int j=1;j<=m;j+=2){
			if(f[a[j]]>=2){
				int t=j+2;
				f[a[j]]-=2;
				if(f[a[t]]>=2){
					double z=(double)a[t]/(double)a[j];
					if(z<minn){
						minn=z;
						ansa=a[j];
						ansb=a[t];
					}
				}
			}

		}
		printf("%d %d %d %d\n",ansa,ansa,ansb,ansb);
		for(int i=1;i<=m;i++){
			f[a[i]]=0;
			a[i]=0;
		}
	}
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define il inline
#define res register int
using namespace std;
const int N=1e6+5;
il int read()
{
	int x=0,f=0,c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f?-x:x;
}
int T,n,mx;
int b[N],vis[10001],cnt;
int a[N];
int ret[2];
double ans=1e9;
double calc(int x,int y)
{
	return (double) 8+4*(  (x*1.0)/(y*1.0)  +  (y*1.0)/(x*1.0)  );
}
void clean()
{
	ans=1e9;
//	memset(vis,0,sizeof(vis));
	cnt=mx=0;
	ret[0]=ret[1]=0;
}

int main()
{
	T=read();
	while(T--)
	{
		clean();
		n=read();
		for(res i=1;i<=n;i++)
		{
			int x;
			a[i]=read();
			x=a[i];
			vis[x]++;
			mx=max(mx,x);
		}
		bool flag=0;
		for(res i=1;i<=mx;i++)
		{
			if(vis[i]>=4)
			{
				printf("%d %d %d %d\n",i,i,i,i);
				flag=1;
				break;
			}
			if(vis[i]>=2) b[++cnt]=i;//桶排序 这个时候已经是有序的了
		}
		for(res i=1;i<=n;i++) vis[a[i]]=0;

		if(flag) continue;
		for(res i=1;i<cnt;i++)
		{
			int x=b[i],y=b[i+1];
			double tmp=calc(x,y);
			if(  ans>tmp)
			{
				ans=tmp;
				ret[0]=x,ret[1]=y;
			}
		}
		printf("%d %d ",ret[0],ret[1]);
		printf("%d %d\n",ret[0],ret[1]);
	}
}


#include <bits/stdc++.h>

using namespace std;
const int N = 2000000;

int n;
int a[N], b[N];

map<int,int>cnt;

void work(void)
{
	int ans, m = 0;
	double Min = 1e19;
	scanf("%d", &n);
	for (int i=1;i<=n;++i) {
		scanf("%d", a+i);
		cnt[a[i]] = 0;
	}
	for (int i=1;i<=n;++i)
	{
		cnt[a[i]] ++;
		if (cnt[a[i]] == 2) b[++m] = a[i];
		if (cnt[a[i]] == 4) b[++m] = a[i];
	}
	sort(b+1,b+m+1);
	for (int i=1;i<m;++i)
	{
		if (b[i] == b[i+1]) {
			printf("%d %d ", b[i], b[i]);
			printf("%d %d\n", b[i], b[i]);
			return;
		}
		if (1.0 * b[i+1] / b[i] < Min)
			Min = 1.0 * b[i+1] / b[i], ans = i;
	}
	printf("%d %d ", b[ans], b[ans]);
	printf("%d %d\n", b[ans+1], b[ans+1]);
	return;
}

int main(void)
{
	int T; cin>>T;
	while (T --) work();
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#define maxn 1e5
using namespace std;

int t,n,a[1000005],b[1000005];
int cnt[10005],ansx,ansy;
double x,minn;

int main(){
	cin>>t;
	while(t--){
		cin>>n;
		int j=1;
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			++cnt[a[i]];
			if(cnt[a[i]]==2){
				b[j]=a[i];
				cnt[a[i]]=0;
				++j;
			}
		}
		sort(b+1,b+j);
		ansx=-1,ansy=1;
		for(int i=j-2;i>=1;i--){
			if(ansx*b[i+1]<b[i]*ansy){
				ansx=b[i]; ansy=b[i+1];
			}
		}
		printf("%d %d %d %d \n",ansx ,ansx ,ansy ,ansy);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,h[10005],cad[1000005],cntn;
double mina=1e10;
int min_num;
int main()
{
	int T;
	cin>>T;
	while(T--)
	{
		memset(cad,0,sizeof(cad));
		memset(h,0,sizeof(h));
		cntn=0;
		mina=1e10;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			int t;
			scanf("%d",&t);
			h[t]++;
			if(h[t]==2)
			{
				h[t]-=2;
				cad[cntn++]=t;
			}
		}
		sort(cad,cad+cntn);
		for(int i=0;i<cntn;i++)
		{
			double ratio=2*(cad[i]+cad[i+1])*2*(cad[i]+cad[i+1]);
			ratio/=cad[i]*cad[i+1];
			if(ratio<mina)
			{
				min_num=i;
				mina=ratio;
			}
		}
		printf("%d %d %d %d\n",cad[min_num],cad[min_num],cad[min_num+1],cad[min_num+1]);
	}
	return 0;
}


#include <iostream>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

int cishu[10005];
int num[1000005];
vector<int> m;

inline bool cmp(int a, int b, int c, int d){
	return ((ll)a * (ll)d < (ll)b * (ll)c);
}

int main(){
	int n, T, a, b, aa, bb;
	cin >> T;
	while (T--){
		cin >> n;
		m.clear();
		memset(cishu,0,sizeof(cishu));
		memset(num,0,sizeof(num));
		for (int i =0;i<n;i++){
			cin >>num[i];
			cishu[num[i]]++;
		}
		for (int i = 1;i<=10000;i++){
			if (cishu[i]>=2) m.push_back(i);
			if (cishu[i]>=4) m.push_back(i);
		}
		int a, b, t = 100000;
		if (m.size()==1){
			cout<<m[0]<<' '<<m[0]<<' '<<m[0]<<' '<<m[0]<<endl;
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i=0;i<m.size()-1;i++){
			if(cmp(m[i]*m[i]+m[i+1]*m[i+1],m[i]*m[i+1],aa,bb)){
				aa = m[i]*m[i]+m[i+1]*m[i+1];
				bb = m[i]*m[i+1];
				a = m[i];
				b = m[i+1];
			}
		}
		cout<<a<<' '<<b<<' '<<b<<' '<<a<<endl;
	}
}


#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

ll cishu[10005];
ll num[1000005];
vector<int> m;

inline bool cmp(ll a, ll b, ll c, ll d){
	return (a * d < b * c);
}

int main(){
	ll n, T, a, b, aa, bb, ta, tb;
	scanf("%I64d", &T);
	while (T--){
		scanf("%I64d", &n);
		m.clear();
		memset(cishu, 0, sizeof(cishu));
		for (int i =0; i < n; i++){
			scanf("%I64d", &num[i]);
			cishu[num[i]]++;
		}
		for (int i = 1; i <= 10000; i++){
			if (cishu[i] >= 2) m.push_back(i);
			if (cishu[i] >= 4) m.push_back(i);
		}
		if (m.size() == 1){
			printf("%d %d %d %d\n",m[0],m[0],m[0],m[0]);
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i=0;i<m.size()-1;i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if(ta*bb < tb*aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%I64d %I64d %I64d %I64d\n",a,b,b,a);
	}
}


#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int cishu[10005];
int num[1000005];
vector<int> m;

int main(){
	int n, T;
	cin>>T;
	while (T--){
		cin >> n;
		m.clear();
		memset(cishu,0,sizeof(cishu));
		memset(num,0,sizeof(num));
		for (int i =0;i<n;i++){
			cin >>num[i];
			cishu[num[i]]++;
		}
		for (int i = 1;i<=10000;i++){
			if (cishu[i]>=2) m.push_back(i);
		}
		int a, b, t=100000;
		if (m.size()==1){
			cout<<m[0]<<' '<<m[0]<<' '<<m[0]<<' '<<m[0]<<endl;
			continue;
		}
		for (int i=0;i<m.size()-1;i++){
			if(m[i+1]-m[i]<t){
				t=m[i+1]-m[i];
				a=m[i];
				b=m[i+1];
			}
		}
		cout<<a<<' '<<b<<' '<<b<<' '<<a<<endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
typedef long long ll;
using namespace std;

int num[1000001];
int cishu[10001];
int m[20001];

int main(){
	int n, T, a, b, aa, bb, ta, tb, c, t;
	scanf("%d", &T);
	while (T--){
		scanf("%d", &n);
		c = 0;
		memset(cishu, 0, sizeof(cishu));
		for (int i = 0; i < n; i++){
			scanf("%d", &t);
			cishu[t]++;
			if (cishu[t] == 2) m[c++] = t;
			else if (cishu[t] == 4) m[c++] = t;
		}
		sort(m, m + c);
		aa = 100000;
		bb = 1;
		for (int i = 0; i < c - 1; i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if((ll)ta*(ll)bb < (ll)tb*(ll)aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%d %d %d %d\n",a,b,b,a);
	}
	return 0;
}


#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int cishu[10005];
int num[1000005];
vector<int> m;

inline bool cmp(int a, int b, int c, int d){
	return ((ll)a * (ll)d < (ll)b * (ll)c);
}

int main(){
	int n, T, a, b, aa, bb;
	cin >> T;
	while (T--){
		cin >> n;
		m.clear();
		memset(cishu,0,sizeof(cishu));
		memset(num,0,sizeof(num));
		for (int i =0;i<n;i++){
			cin >>num[i];
			cishu[num[i]]++;
		}
		for (int i = 1;i<=10000;i++){
			if (cishu[i]>=2) m.push_back(i);
			if (cishu[i]>=4) m.push_back(i);
		}
		int a, b, t = 100000;
		if (m.size()==1){
			cout<<m[0]<<' '<<m[0]<<' '<<m[0]<<' '<<m[0]<<endl;
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i=0;i<m.size()-1;i++){
			if(cmp(m[i]*m[i]+m[i+1]*m[i+1],m[i]*m[i+1],aa,bb)){
				aa = m[i]*m[i]+m[i+1]*m[i+1];
				bb = m[i]*m[i+1];
				a = m[i];
				b = m[i+1];
			}
		}
		cout<<a<<' '<<b<<' '<<b<<' '<<a<<endl;
	}
}


#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int cishu[10005];
int num[100005];
vector<int> m;

int main(){
	int n, T;
	cin>>T;
	while (T--){
		cin >> n;
		m.clear();
		memset(cishu,0,sizeof(cishu));
		memset(num,0,sizeof(num));
		for (int i =0;i<n;i++){
			cin >>num[i];
			cishu[num[i]]++;
		}
		for (int i = 1;i<=10000;i++){
			if (cishu[i]>=2) m.push_back(i);
		}
		int a, b, t=100000;
		if (m.size()==1){
			cout<<m[0]<<' '<<m[0]<<' '<<m[0]<<' '<<m[0]<<endl;
			continue;
		}
		for (int i=0;i<m.size()-1;i++){
			if(m[i+1]-m[i]<t){
				t=m[i+1]-m[i];
				a=m[i];
				b=m[i+1];
			}
		}
		cout<<a<<' '<<b<<' '<<b<<' '<<a<<endl;
	}
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string.h>
typedef long long ll;
using namespace std;

int num[1000005];
int cishu[10001];
int m[20001];

int main(){
	ll n, T, a, b, aa, bb, ta, tb, c, t;
	scanf("%d", &T);
	while (T--){
		scanf("%d", &n);
		c = 0;
		memset(cishu, 0, sizeof(cishu));
		for (int i = 0; i < n; i++){
			scanf("%d", &t);
			cishu[t]++;
			if (cishu[t] == 2) m[c++] = t;
			else if (cishu[t] == 4) m[c++] = t;
		}
		sort(m, m + c);
		if (c == 1){
			printf("%d %d %d %d\n",m[0],m[0],m[0],m[0]);
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i = 0; i < c - 1; i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if((ll)ta*(ll)bb < (ll)tb*(ll)aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%d %d %d %d\n",a,b,b,a);
	}
}


#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

int cishu[10005];
int num[1000005];
vector<int> m;

inline bool cmp(int a, int b, int c, int d){
	return ((ll)a * (ll)d < (ll)b * (ll)c);
}

int main(){
	int n, T, a, b, aa, bb;
	scanf("%d", &T);
	while (T--){
		scanf("%d", &n);
		m.clear();
		memset(cishu, 0, sizeof(cishu));
		for (int i =0;i<n;i++){
			scanf("%d", &num[i]);
			cishu[num[i]]++;
		}
		for (int i = 1; i <= 10000; i++){
			if (cishu[i] >= 2) m.push_back(i);
			if (cishu[i] >= 4) m.push_back(i);
		}
		if (m.size() == 1){
			printf("%d %d %d %d\n",m[0],m[0],m[0],m[0]);
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i=0;i<m.size()-1;i++){
			if(cmp(m[i]*m[i]+m[i+1]*m[i+1],m[i]*m[i+1],aa,bb)){
				aa = m[i]*m[i]+m[i+1]*m[i+1];
				bb = m[i]*m[i+1];
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%d %d %d %d\n",a,b,b,a);
	}
}


#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

ll cishu[10005];
ll num[1000005];
ll m[10005];

inline bool cmp(ll a, ll b, ll c, ll d){
	return (a * d < b * c);
}

int main(){
	ll n, T, a, b, aa, bb, ta, tb, c;
	scanf("%I64d", &T);
	while (T--){
		scanf("%I64d", &n);
		memset(cishu, 0, sizeof(cishu));
		for (int i = 0; i < n; i++){
			scanf("%I64d", &num[i]);
			cishu[num[i]]++;
		}
		c = 0;
		for (int i = 1; i <= 10000; i++){
			if (cishu[i] >= 2) m[c++] = i;
			if (cishu[i] >= 4) m[c++] = i;
		}
		if (c == 1){
			printf("%d %d %d %d\n",m[0],m[0],m[0],m[0]);
			continue;
		}
		aa = 100000;
		bb = 1;
		c--;
		for (int i=0;i<c;i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if(ta*bb < tb*aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%I64d %I64d %I64d %I64d\n",a,b,b,a);
	}
}


#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int cishu[10005];
int num[1000005];
vector<int> m;

inline bool cmp(int a, int b, int c, int d){
	return (a * d < b * c);
}

int main(){
	int n, T, a, b, aa, bb;
	cin>>T;
	while (T--){
		cin >> n;
		m.clear();
		memset(cishu,0,sizeof(cishu));
		memset(num,0,sizeof(num));
		for (int i =0;i<n;i++){
			cin >>num[i];
			cishu[num[i]]++;
		}
		for (int i = 1;i<=10000;i++){
			if (cishu[i]>=2) m.push_back(i);
		}
		int a, b, t = 100000;
		if (m.size()==1){
			cout<<m[0]<<' '<<m[0]<<' '<<m[0]<<' '<<m[0]<<endl;
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i=0;i<m.size()-1;i++){
			if(cmp(m[i]*m[i]+m[i+1]*m[i+1],m[i]*m[i+1],aa,bb)){
				aa = m[i]*m[i]+m[i+1]*m[i+1];
				bb = m[i]*m[i+1];
				a = m[i];
				b = m[i+1];
			}
		}
		cout<<a<<' '<<b<<' '<<b<<' '<<a<<endl;
	}
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
typedef long long ll;
using namespace std;

int num[1000001];
int cishu[10001];
int m[20001];

int main(){
	ll n, T, a, b, aa, bb, ta, tb, c, t;
	scanf("%d", &T);
	while (T--){
		scanf("%d", &n);
		c = 0;
		memset(cishu, 0, sizeof(cishu));
		for (int i = 0; i < n; i++){
			scanf("%d", &t);
			cishu[t]++;
			if (cishu[t] == 2) m[c++] = t;
			else if (cishu[t] == 4) m[c++] = t;
		}
		sort(m, m + c);
		aa = 100000;
		bb = 1;
		for (int i = 0; i < c - 1; i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if((ll)ta*(ll)bb < (ll)tb*(ll)aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%d %d %d %d\n",a,b,b,a);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <string.h>
typedef long long ll;
using namespace std;

ll num[1000005];
ll m[20005];

int main(){
	ll n, T, a, b, aa, bb, ta, tb, c;
	scanf("%I64d", &T);
	while (T--){
		scanf("%I64d", &n);
		ll cishu[10005];
		for (int i = 0; i < n; i++){
			scanf("%I64d", &num[i]);
			cishu[num[i]]++;
		}
		c = 0;
		for (int i = 1; i <= 10000; i++){
			if (cishu[i] >= 2) m[c++] = i;
			if (cishu[i] >= 4) m[c++] = i;
		}
		if (c == 1){
			printf("%d %d %d %d\n",m[0],m[0],m[0],m[0]);
			continue;
		}
		aa = 100000;
		bb = 1;
		c--;
		for (int i=0;i<c;i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if(ta*bb < tb*aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%I64d %I64d %I64d %I64d\n",a,b,b,a);
	}
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string.h>
typedef long long ll;
using namespace std;

ll num[1000005];
ll cishu[10001];
vector<ll> m;

int main(){
	ll n, T, a, b, aa, bb, ta, tb, c, t;
	scanf("%I64d", &T);
	while (T--){
		scanf("%I64d", &n);
		m.clear();
		memset(cishu, 0, sizeof(cishu));
		for (int i = 0; i < n; i++){
			scanf("%I64d", &t);
			cishu[t]++;
			if (cishu[t] == 2) m.push_back(t);
			else if (cishu[t] == 4) m.push_back(t);
		}
		sort(m.begin(), m.end());
		if (m.size() == 1){
			printf("%d %d %d %d\n",m[0],m[0],m[0],m[0]);
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i=0;i<m.size()-1;i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if(ta*bb < tb*aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%I64d %I64d %I64d %I64d\n",a,b,b,a);
	}
}


#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int cishu[10005];
int num[1000005];
vector<int> m;

inline bool cmp(int a, int b, int c, int d){
	return (a * d < b * c);
}

int main(){
	int n, T, a, b, aa, bb;
	cin >> T;
	while (T--){
		cin >> n;
		m.clear();
		memset(cishu,0,sizeof(cishu));
		memset(num,0,sizeof(num));
		for (int i =0;i<n;i++){
			cin >>num[i];
			cishu[num[i]]++;
		}
		for (int i = 1;i<=10000;i++){
			if (cishu[i]>=2) m.push_back(i);
			if (cishu[i]>=4) m.push_back(i);
		}
		int a, b, t = 100000;
		if (m.size()==1){
			cout<<m[0]<<' '<<m[0]<<' '<<m[0]<<' '<<m[0]<<endl;
			continue;
		}
		aa = 100000;
		bb = 1;
		for (int i=0;i<m.size()-1;i++){
			if(cmp(m[i]*m[i]+m[i+1]*m[i+1],m[i]*m[i+1],aa,bb)){
				aa = m[i]*m[i]+m[i+1]*m[i+1];
				bb = m[i]*m[i+1];
				a = m[i];
				b = m[i+1];
			}
		}
		cout<<a<<' '<<b<<' '<<b<<' '<<a<<endl;
	}
}


#include <iostream>
#include <cstdio>
#include <string.h>
typedef long long ll;
using namespace std;

ll num[1000005];
ll m[20005];

int main(){
	ll n, T, a, b, aa, bb, ta, tb, c;
	scanf("%I64d", &T);
	while (T--){
		scanf("%I64d", &n);
		ll cishu[10005] = {0};
		for (int i = 0; i < n; i++){
			scanf("%I64d", &num[i]);
			cishu[num[i]]++;
		}
		c = 0;
		for (int i = 1; i <= 10000; i++){
			if (cishu[i] >= 2) m[c++] = i;
			if (cishu[i] >= 4) m[c++] = i;
		}
		if (c == 1){
			printf("%d %d %d %d\n",m[0],m[0],m[0],m[0]);
			continue;
		}
		aa = 100000;
		bb = 1;
		c--;
		for (int i=0;i<c;i++){
			ta = m[i]*m[i]+m[i+1]*m[i+1];
			tb = m[i]*m[i+1];
			if(ta*bb < tb*aa){
				aa = ta;
				bb = tb;
				a = m[i];
				b = m[i+1];
			}
		}
		printf("%I64d %I64d %I64d %I64d\n",a,b,b,a);
	}
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 1000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 10000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i]*1.0 / b[i + 1])+(b[i + 1]*1.0 / b[i]);
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 1000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 1000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = 4 * ((b[i] * 1.0 / b[i + 1]) + (b[i + 1] * 1.0 / b[i])) + 8;
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 1000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 10000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i] * 1.0 / b[i + 1]) + (b[i + 1] * 1.0 / b[i]);
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 100000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 1000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i]/b[i + 1]) + (b[i + 1]/b[i]);
            if (now < mini) {
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 1000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 1000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = 4 * ((b[i] * 1.0 / b[i + 1]) + (b[i + 1] * 1.0 / b[i])) + 8;
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        for (int i = 1; i < id - 1; i++) {
            double now = 4 * ((b[i] * 1.0 / b[i + 2]) + (b[i + 2] * 1.0 / b[i])) + 8;
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 2];
            }
        }
        for (int i = 1; i < id - 2; i++) {
            double now = 4 * ((b[i] * 1.0 / b[i + 3]) + (b[i + 3] * 1.0 / b[i])) + 8;
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 3];
            }
        }
        for (int i = 1; i < id - 3; i++) {
            double now = 4 * ((b[i] * 1.0 / b[i + 4]) + (b[i + 4] * 1.0 / b[i])) + 8;
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 4];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 100000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 1000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i]/b[i + 1]) + (b[i + 1]/b[i]);
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 100000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 10000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i] * 1.0 / b[i - 1]) + (b[i - 1] * 1.0 / b[i]);
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i - 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 10000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 10000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i] * 1.0 / b[i + 1]) + (b[i + 1] * 1.0 / b[i]);
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 100000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 1000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            for (int j = i + 1; j <= id; j++) {
                double now = (b[i] * 1.0 / b[j]) + (b[j] * 1.0 / b[i]);
                if (now < mini) {
                    mini = now;
                    ansa = b[i];
                    ansb = b[j];
                }
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


//luogu-version
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 100000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 10000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i] * 1.0 / b[i + 1]) + (b[i + 1] * 1.0 / b[i]);
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar (' ')
#define EL putchar ('\n')
#define N 10005
#define File(a) freopen(a".in", "r", stdin) , freopen(a".out", "w", stdout)
template<class T1>inline void read(T1&);
template<class T1>inline void write(T1);
int s[N];
int b[N];
int main () {
    int t;
    read(t);
    while (t--) {
        int n;
        double mini = 100000000000;
        int ansa, ansb;
        read(n);
        memset(s, 0, sizeof(s));
        for (int i = 1; i <= n; i++) {
            int a;
            read(a);
            s[a]++;
        }
        int id = 0;
        for (int i = 1; i <= 10000; i++) {
            if (s[i] >= 2) {
                b[++id] = i;
            }
            if (s[i] >= 4) {
                b[++id] = i;
            }
        }
        for (int i = 1; i < id; i++) {
            double now = (b[i] * 1.0 / b[i + 1]) + (b[i + 1] * 1.0 / b[i]);
            if (now < mini) {
                mini = now;
                ansa = b[i];
                ansb = b[i + 1];
            }
        }
        write(ansa);
        SP;
        write(ansa);
        SP;
        write(ansb);
        SP;
        write(ansb);
        EL;
    }
    return 0;
}
template<class T1>void read(T1 &r_e_a_d) {
    T1 k = 0;
    char ch = getchar();
    int flag = 1;
    while(!isNum(ch) ) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while(isNum(ch) ) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    r_e_a_d = flag * k;
}
template<class T1>void write(T1 w_r_i_t_e) {
    if (w_r_i_t_e < 0) {
        putchar('-');
        write(-w_r_i_t_e);
    }else {
        if (w_r_i_t_e < 10) {
            putchar(w_r_i_t_e + '0');
        }else {
            write(w_r_i_t_e / 10);
            putchar( (w_r_i_t_e % 10) + '0');
        }
    }
}


#include<bits/stdc++.h>
#define i64 long long
using namespace std;
i64 t,n,a[100001];
i64 c[100001];
i64 k,l,x,m;
map <i64,i64> mp;
void doit ()
{
	scanf("%lld",&n);
	for (i64 i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	m=0;
	mp.clear();
	for (i64 i=1;i<=n;i++)
	mp[a[i]]++;
	for (map<i64,i64>::iterator i=mp.begin();i!=mp.end();i++)
	{
		k=(*i).second;
		l=(*i).first;
		if (k>=4)
		{
			printf("%lld %lld %lld %lld\n",l,l,l,l);
			return;
		}
		if (k>=2) c[++m]=l;
	}
	sort(c+1,c+1+m);
	k=l=0;
	for (i64 i=2;i<=m;i++)
	{
		if (k==0 && l==0) k=c[i-1],l=c[i];
			else
		{
			i64 x=c[i-1],y=c[i];
			if ((x*x+y*y)*k*l<(k*k+l*l)*x*y) k=x,l=y;
		}
	}
	printf("%lld %lld %lld %lld\n",k,k,l,l);
	return;
};
int main()
{
	scanf("%d",&t);
	while (t--)
	doit();
	return 0;
}


#include<bits/stdc++.h>
#define i64 long long
using namespace std;
i64 t,n,a[100001];
i64 c[100001];
i64 k,l,x,m;
map <i64,i64> mp;
void doit ()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	m=0;
	for (i64 i=1;i<=n;i++)
	if (mp[a[i]]) c[++m]=a[i];
		else mp[a[i]]=1;
	sort(c+1,c+1+m);
	k=l=0;
	for (int i=2;i<=m;i++)
	{
		if (k==0 && l==0) k=c[i-1],l=c[i];
			else
		{
			i64 x=c[i-1],y=c[i];
			if ((x*x+y*y)*k*l<(k*k+l*l)*x*y) x=k,y=l;
		}
	}
	printf("%lld %lld %lld %lld\n",k,k,l,l);
	return;
};
int main()
{
	scanf("%d",&t);
	while (t--)
	doit();
	return 0;
}


#include<bits/stdc++.h>
#define i64 long long
using namespace std;
int n,x,a[500001],m;
map<int,int> mp;
void mian ()
{
	scanf("%d",&n);
	mp.clear();
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		mp[x]++;
	}
	m=0;
	for (map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		int fi=(*it).first;
		int se=(*it).second;
		if (se>=2) a[++m]=fi;
		if (se>=4)
		{
			printf("%d %d %d %d\n",fi,fi,fi,fi);
			return;
		}
	}
	i64 x=0,y=0;
	for (int i=2;i<=m;i++)
	{
		i64 xx=a[i-1],yy=a[i];
		if (x==0 && y==0) x=xx,y=yy;
			else if ((xx*xx+yy*yy)*x*y<(x*x+y*y)*xx*yy) x=xx,y=yy;
	}
	printf("%lld %lld %lld %lld\n",x,x,y,y);
	return;
}
int main()
{
	int T;
	scanf("%d",&T);
	while (T--)
	mian();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int t,n,a[100001];
long double ans;
int k,l,x;
void doit ()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	ans=1e+38;
	k=l=x=0;
	for (int i=1,j=1;i<=n;i=j)
	{
		while (a[i]==a[j])
		j++;
		if (i>=j-1) continue;
		if (i<=j-4)
		{
			ans=16;
			k=l=i;
		}
		if (x)
		{
			if (ans>(a[i]+a[x])*(a[i]+a[x])*4.0/(a[i]*a[x]))
			{
				ans=(a[i]+a[x])*(a[i]+a[x])*4.0/(a[i]*a[x]);
				k=x;
				l=i;
			}
		}
		x=i;
	}
	//printf("%0.5lf\n",ans);
	printf("%d %d %d %d\n",a[k],a[k],a[l],a[l]);
	return;
};
int main()
{
	scanf("%d",&t);
	while (t--)
	doit();
	return 0;
}