#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll long long
typedef pair<ll, ll> pll;
ll arr[SIZE];
ll t, n, temp,a,b, mod = 1000003;

ll modPow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x) {
	return modPow(x, mod - 2);
}

vector<ll> polyMult(const vector<ll>& lhs, const vector<ll>& rhs) {
	int n = lhs.size() - 1, m = rhs.size() - 1;
	vector<ll> ret(n + m + 1, 0);
	int k;
	for (int i = 0; i <= n + m; i++) {
		for (int j = 0; j <= n; j++) {
			k = i - j;
			if (k<0 || k>m)continue;
			ret[i] += (lhs[j] * rhs[k]);
			ret[i] %= mod;
		}
	}
	return ret;
}

vector<ll> polyAdd(const vector<ll>& lhs, const vector<ll>& rhs) {
	int n = lhs.size() - 1, m = rhs.size() - 1, addSize = max(n, m) + 1;
	vector<ll> ret(addSize, 0);
	for (int i = 0; i < addSize; i++) {
		if (i <= n)ret[i] += lhs[i];
		if (i <= m)ret[i] += rhs[i];
		ret[i] %= mod;
	}
	return ret;
}

vector<ll> coeffMult(const vector<ll>& poly, const ll& num) {
	vector<ll> ret(poly.size(), 0);
	for (int i = 0; i < poly.size(); i++) {
		ret[i] = poly[i] * num;
		ret[i] %= mod;
	}
	return ret;
}

ll sub(const vector<ll>& poly, const ll& num) {
	ll tot = 0, numMult = 1;
	for (ll coeff : poly) {
		tot += coeff * numMult;
		numMult *= num;
		numMult %= mod;
		tot %= mod;
	}
	return tot;
}

vector<ll> interpolation(const vector<pll>& pts) {
	int n = pts.size();
	vector<ll> ret(1, 0);
	vector<ll> linear(2, 0);
	linear[1] = 1;
	for (int i = 0; i < n; i++) {
		vector<ll> cr(1, 0);
		ll coeff = 1;
		cr[0] = 1;
		for (int j = 0; j < n; j++) {
			if (i == j)continue;
			linear[0] = mod - pts[j].first;
			cr = polyMult(cr, linear);
			coeff *= modInverse(pts[i].first - pts[j].first);
			coeff %= mod;
		}
		ret = polyAdd(ret, coeffMult(coeffMult(cr, coeff), pts[i].second));
	}
	return ret;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << (int)xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	vector<pll> f;
	for (ll i = 0; i < 11; i++) f.pb(make_pair(i, query(i)));
	bool exists = false;
	vector<ll> pol = interpolation(f);
	for (int i = 0; i < mod; i++)
	{
		if (sub(pol, i) % mod == 0) {
			cout << "! " << (int)i << "\n";
			fflush(stdout);
			exists = true;
			break;
		}
	}
	if (!exists) {
		cout << (int)-1 << "\n";
		fflush(stdout);
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll long long
ll arr[SIZE];
ll t, n, temp,a,b, modu = 1000003;
ll f[11];
struct Data
{
	ll x, y;
};

ll modPow(ll x, ll y, ll mod)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x, ll mod) {
	return modPow(x, mod - 2, mod);
}

ll interpolate(Data f[], ll xi, ll n)
{
	ll result = 0;
	for (int i = 0; i < n; i++)
	{
		ll term = f[i].y;
		for (int j = 0; j < n; j++) {
			if (j != i)
				term = (term * (xi - f[j].x) * modInverse((f[i].x - f[j].x), modu)) % modu;
		}
		result += term;
	}
	return result % modu;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << (int) xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	Data f[11];
	for (ll i = 0; i < 11; i++) f[i].x = i, f[i].y = query(i);
	bool exists = false;
	for (ll i = 0; i < modu; i++)
	{
		if ((ll)interpolate(f, i, 11) % modu == 0) {
			cout << "! " << (int) i << "\n";
			cout.flush();
			exists = true;
			break;
		}
	}
	if (!exists) {
		cout << "-1\n";
		cout.flush();
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll long long
typedef pair<ll, ll> pll;
ll arr[SIZE];
ll t, n, temp,a,b, mod = 1000003;

ll modPow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x) {
	return modPow(x, mod - 2);
}

vector<ll> polyMult(const vector<ll>& lhs, const vector<ll>& rhs) {
	int n = lhs.size() - 1, m = rhs.size() - 1;
	vector<ll> ret(n + m + 1, 0);
	int k;
	for (int i = 0; i <= n + m; i++) {
		for (int j = 0; j <= n; j++) {
			k = i - j;
			if (k<0 || k>m)continue;
			ret[i] += (lhs[j] * rhs[k]);
			ret[i] %= mod;
		}
	}
	return ret;
}

vector<ll> polyAdd(const vector<ll>& lhs, const vector<ll>& rhs) {
	int n = lhs.size() - 1, m = rhs.size() - 1, addSize = max(n, m) + 1;
	vector<ll> ret(addSize, 0);
	for (int i = 0; i < addSize; i++) {
		if (i <= n)ret[i] += lhs[i];
		if (i <= m)ret[i] += rhs[i];
		ret[i] %= mod;
	}
	return ret;
}

vector<ll> coeffMult(const vector<ll>& poly, const ll& num) {
	vector<ll> ret(poly.size(), 0);
	for (int i = 0; i < poly.size(); i++) {
		ret[i] = poly[i] * num;
		ret[i] %= mod;
	}
	return ret;
}

ll sub(const vector<ll>& poly, const ll& num) {
	ll tot = 0, numMult = 1;
	for (ll coeff : poly) {
		tot += coeff * numMult;
		numMult *= num;
		numMult %= mod;
		tot %= mod;
	}
	return tot;
}

vector<ll> interpolation(const vector<pll>& pts) {
	int n = pts.size();
	vector<ll> ret(1, 0);
	vector<ll> linear(2, 0);
	linear[1] = 1;
	for (int i = 0; i < n; i++) {
		vector<ll> cr(1, 0);
		ll coeff = 1;
		cr[0] = 1;
		for (int j = 0; j < n; j++) {
			if (i == j)continue;
			linear[0] = mod - pts[j].first;
			cr = polyMult(cr, linear);
			coeff *= modInverse(pts[i].first - pts[j].first);
			coeff %= mod;
		}
		ret = polyAdd(ret, coeffMult(coeffMult(cr, coeff), pts[i].second));
	}
	return ret;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << (int)xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	vector<pll> f;
	for (ll i = 0; i < 11; i++) f.pb(make_pair(i, query(i)));
	bool exists = false;
	vector<ll> pol = interpolation(f);
	for (int i = 0; i < mod; i++)
	{
		if (sub(pol, i) % mod == 0) {
			cout << "! " << (int)i << "\n";
			fflush(stdout);
			exists = true;
			break;
		}
	}
	if (!exists) {
		cout << (int)-1L << "\n";
		fflush(stdout);
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll ll
ll arr[SIZE];
ll t, n, temp,a,b, modu = 1000003;
ll f[11];
struct Data
{
	ll x, y;
};

ll modPow(ll x, ll y, ll mod)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x, ll mod) {
	return modPow(x, mod - 2, mod);
}

ll interpolate(Data f[], ll xi, ll n)
{
	ll result = 0;
	for (int i = 0; i < n; i++)
	{
		ll term = f[i].y;
		for (int j = 0; j < n; j++) {
			if (j != i)
				term = (term * (xi - f[j].x) * modInverse((f[i].x - f[j].x), modu)) % modu;
		}
		result += term;
	}
	return result % modu;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << (int) xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	Data f[11];
	for (ll i = 0; i < 11; i++) f[i].x = i, f[i].y = query(i);
	bool exists = false;
	for (ll i = 0; i < modu; i++)
	{
		if ((ll)interpolate(f, i, 11) % modu == 0) {
			cout << "! " << (int) i << "\n";
			cout.flush();
			exists = true;
			break;
		}
	}
	if (!exists) {
		cout << "-1\n";
		cout.flush();
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll long long
ll arr[SIZE];
ll t, n, temp,a,b, modu = 1000000 + 3;
ll f[11];
struct Data
{
	ll x, y;
};

ll modPow(ll x, ll y, ll mod)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x, ll mod) {
	return modPow(x, mod - 2, mod);
}

ll interpolate(Data f[], ll xi, ll n)
{
	ll result = 0;
	for (int i = 0; i < n; i++)
	{
		ll term = f[i].y;
		for (int j = 0; j < n; j++) {
			if (j != i)
				term = (term * (xi - f[j].x) * modInverse((f[i].x - f[j].x), modu)) % modu;
		}
		result += term;
	}
	return result % modu;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	Data f[11];
	for (ll i = 0; i < 11; i++) f[i].x = i, f[i].y = query(i);
	for (ll i = 0; i < modu; i++)
	{
		if ((ll)interpolate(f, i, 11) % modu == 0) {
			cout << "! " << i << "\n";
			cout.flush();
		}
		break;
	}
	cout << "-1\n";
	cout.flush();
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll long long
ll arr[SIZE];
ll t, n, temp,a,b, modu = 1000000 + 3;
ll f[11];
struct Data
{
	ll x, y;
};

ll modPow(ll x, ll y, ll mod)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x, ll mod) {
	return modPow(x, mod - 2, mod);
}

ll interpolate(Data f[], ll xi, ll n)
{
	ll result = 0;
	for (int i = 0; i < n; i++)
	{
		ll term = f[i].y;
		for (int j = 0; j < n; j++) {
			if (j != i)
				term = (term * (xi - f[j].x) * modInverse((f[i].x - f[j].x), modu)) % modu;
		}
		result += term;
	}
	return result % modu;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	Data f[11];
	for (ll i = 0; i < 11; i++) f[i].x = i, f[i].y = query(i);
	for (ll i = 0; i < modu; i++)
	{
		if ((ll)interpolate(f, i, 11) % modu == 0) {
			cout << i << "\n";
		}
		break;
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll long long
typedef pair<ll, ll> pll;
ll arr[SIZE];
ll t, n, temp,a,b, mod = 1000003;

ll modPow(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x) {
	return modPow(x, mod - 2);
}

vector<ll> polyMult(const vector<ll>& lhs, const vector<ll>& rhs) {
	int n = lhs.size() - 1, m = rhs.size() - 1;
	vector<ll> ret(n + m + 1, 0);
	int k;
	for (int i = 0; i <= n + m; i++) {
		for (int j = 0; j <= n; j++) {
			k = i - j;
			if (k<0 || k>m)continue;
			ret[i] += (lhs[j] * rhs[k]);
			ret[i] %= mod;
		}
	}
	return ret;
}

vector<ll> polyAdd(const vector<ll>& lhs, const vector<ll>& rhs) {
	int n = lhs.size() - 1, m = rhs.size() - 1, addSize = max(n, m) + 1;
	vector<ll> ret(addSize, 0);
	for (int i = 0; i < addSize; i++) {
		if (i <= n)ret[i] += lhs[i];
		if (i <= m)ret[i] += rhs[i];
		ret[i] %= mod;
	}
	return ret;
}

vector<ll> coeffMult(const vector<ll>& poly, const ll& num) {
	vector<ll> ret(poly.size(), 0);
	for (int i = 0; i < poly.size(); i++) {
		ret[i] = poly[i] * num;
		ret[i] %= mod;
	}
	return ret;
}

ll sub(const vector<ll>& poly, const ll& num) {
	ll tot = 0, numMult = 1;
	for (ll coeff : poly) {
		tot += coeff * numMult;
		numMult *= num;
		numMult %= mod;
		tot %= mod;
	}
	return tot;
}

vector<ll> interpolation(const vector<pll>& pts) {
	int n = pts.size();
	vector<ll> ret(1, 0);
	vector<ll> linear(2, 0);
	linear[1] = 1;
	for (int i = 0; i < n; i++) {
		vector<ll> cr(1, 0);
		ll coeff = 1;
		cr[0] = 1;
		for (int j = 0; j < n; j++) {
			if (i == j)continue;
			linear[0] = mod - pts[j].first;
			cr = polyMult(cr, linear);
			coeff *= modInverse(pts[i].first - pts[j].first);
			coeff %= mod;
		}
		ret = polyAdd(ret, coeffMult(coeffMult(cr, coeff), pts[i].second));
	}
	return ret;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << (int)xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	vector<pll> f;
	for (ll i = 0; i < 11; i++) f.pb(make_pair(i, query(i)));
	bool exists = false;
	vector<ll> pol = interpolation(f);
	for (int i = 0; i < mod; i++)
	{
		if (sub(pol, i) % mod == 0) {
			cout << "! " << (int)i << "\n";
			fflush(stdout);
			exists = true;
			break;
		}
	}
	ll minusOne = -1;
	if (!exists) {
		cout << "! " << (int)minusOne << "\n";
		fflush(stdout);
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll long long
ll arr[SIZE];
ll t, n, temp,a,b, modu = 1000003;
ll f[11];
struct Data
{
	ll x, y;
};

ll modPow(ll x, ll y, ll mod)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x, ll mod) {
	return modPow(x, mod - 2, mod);
}

ll interpolate(Data f[], ll xi, ll n)
{
	ll result = 0;
	for (int i = 0; i < n; i++)
	{
		ll term = f[i].y;
		for (int j = 0; j < n; j++) {
			if (j != i)
				term = (term * (xi - f[j].x) * modInverse((f[i].x - f[j].x), modu)) % modu;
		}
		result += term;
	}
	return result % modu;
}

ll query(int xq) {
	ll fxq;
	printf("? %d\n", xq);
	cout.flush();
	scanf("%lld",&fxq);
	return fxq;
}

int main() {
	ll ans;
	Data f[11];
	for (ll i = 0; i < 11; i++) f[i].x = i, f[i].y = query(i);
	bool exists = false;
	for (int i = 0; i < modu; i++)
	{
		if ((ll)interpolate(f, i, 11) % modu == 0) {
			printf("! %d\n", i);
			fflush(stdout);
			exists = true;
			break;
		}
	}
	if (!exists) {
		printf("-1\n");
		fflush(stdout);
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>
#include <algorithm>
#include <string>
# include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
using namespace std;
#define SIZE 500000
#define ll int
ll arr[SIZE];
ll t, n, temp,a,b, modu = 1000003;
ll f[11];
struct Data
{
	ll x, y;
};

ll modPow(ll x, ll y, ll mod)
{
	ll res = 1;
	x = x % mod;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1) res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}

ll modInverse(ll x, ll mod) {
	return modPow(x, mod - 2, mod);
}

ll interpolate(Data f[], ll xi, ll n)
{
	ll result = 0;
	for (int i = 0; i < n; i++)
	{
		ll term = f[i].y;
		for (int j = 0; j < n; j++) {
			if (j != i)
				term = (term * (xi - f[j].x) * modInverse((f[i].x - f[j].x), modu)) % modu;
		}
		result += term;
	}
	return result % modu;
}

ll query(ll xq) {
	ll fxq;
	cout << "? " << xq << "\n";
	cout.flush();
	cin >> fxq;
	return fxq;
}

int main() {
	fast;
	ll ans;
	Data f[11];
	for (ll i = 0; i < 11; i++) f[i].x = i, f[i].y = query(i);
	for (ll i = 0; i < modu; i++)
	{
		if ((ll)interpolate(f, i, 11) % modu == 0) {
			cout << "! " << i << "\n";
			cout.flush();
		}
		break;
	}
	cout << "-1\n";
	cout.flush();
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*//*1e9 + 7*/ 1e6 + 3;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

vector<long long> rev;

long long bpow(long long a, long long b)
{
	if (b == 0) return 1;
	long long p = a;
	long long q = 1;
	while (b > 1)
	{
		if (b & 1)
		{
			q *= p;
			q %= mod;
		}
		p *= p;
		p %= mod;
		b /= 2;
	}
	return (p * q) % mod;
}

void precalc()
{
	rev.push_back(0);
	for (long long i = 1; i < 1e6 + 3; i++)
	{
		rev.push_back(bpow(i, mod - 2));
	}
}

int main()
{
	precalc();
	vector<vector<long long>> a (11, vector<long long>(12));
	for (int i = 0; i < 11; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			a[i][j] = bpow(i, j);
		}
		cout << "? " << i << endl;
		fflush(stdout);
		cin >> a[i][11];
	}
	vector <long long> av (11);
	for (int i = 0; i < 11; i++)
	{
		for (int j = i + 1; j < 11; j++)
		{
			long long d = a[j][i] * rev[a[i][i]];
			for (int k = i; k < 12; k++)
			{
				a[j][k] -= (d * a[i][k]) % mod;
				if (a[j][k] < 0) a[j][k] += mod;
			}
		}
	}
	for (int i = 10; i >= 0; i--)
	{
		for (int j = i + 1; j < 10; j++)
		{
			a[i][11] -= (av[j] * a[i][j]) % mod;
			if (a[i][11] < 0) a[i][11] += mod;
		}
		av[i] = (a[i][11] * rev[a[i][i]]) % mod;
	}
	for (int i = 0; i < mod; i++)
	{
		long long ans = 0;
		for (int j = 0; j < 11; j++)
		{
			ans += (bpow(i, j) * av[j]) % mod;
			ans %= mod;
		}
		if (ans == 0)
		{
			cout << "! " << i << endl;
			fflush(stdout);
			gg;
		}
	}
	cout << "! -1" << endl;
	fflush(stdout);
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*//*1e9 + 7*/ 1e6 + 3;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

vector<long long> rev;

long long bpow(long long a, long long b)
{
	if (b == 0) return 1;
	long long p = a;
	long long q = 1;
	while (b > 1)
	{
		if (b & 1)
		{
			q *= p;
			q %= mod;
		}
		p *= p;
		p %= mod;
		b /= 2;
	}
	return (p * q) % mod;
}

void precalc()
{
	rev.push_back(0);
	for (long long i = 1; i < 1e6 + 3; i++)
	{
		rev.push_back(bpow(i, mod - 2));
	}
}

int main()
{
	precalc();
	vector<vector<long long>> a (11, vector<long long>(12));
	for (int i = 0; i < 11; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			a[i][j] = bpow(i, j);
		}
		cout << "? " << i << endl;
		fflush(stdout);
		cin >> a[i][11];
	}
	vector <long long> av (11);
	for (int i = 0; i < 11; i++)
	{
		for (int j = i + 1; j < 11; j++)
		{
			long long d = a[j][i] * rev[a[i][i]];
			for (int k = i; k < 12; k++)
			{
				a[j][k] -= (d * a[i][k]) % mod;
				if (a[j][k] < 0) a[j][k] += mod;
			}
		}
	}
	for (int i = 10; i >= 0; i--)
	{
		for (int j = i + 1; j <= 10; j++)
		{
			a[i][11] -= (av[j] * a[i][j]) % mod;
			if (a[i][11] < 0) a[i][11] += mod;
		}
		av[i] = (a[i][11] * rev[a[i][i]]) % mod;
	}
	for (int i = 0; i < mod; i++)
	{
		long long ans = 0;
		for (int j = 0; j < 11; j++)
		{
			ans += (bpow(i, j) * av[j]) % mod;
			ans %= mod;
		}
		if (ans == 0)
		{
			cout << "! " << i << endl;
			fflush(stdout);
			gg;
		}
	}
	cout << "! -1" << endl;
	fflush(stdout);
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*//*1e9 + 7*/ 1e6 + 3;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

vector<long long> rev;

long long bpow(long long a, long long b)
{
	if (b == 0) return 1;
	long long p = a;
	long long q = 1;
	while (b > 1)
	{
		if (b & 1)
		{
			q *= p;
			q %= mod;
		}
		p *= p;
		p %= mod;
		b /= 2;
	}
	return (p * q) % mod;
}

void precalc()
{
	rev.push_back(0);
	for (long long i = 1; i < mod; i++)
	{
		rev.push_back(bpow(i, mod - 2));
	}
}

int main()
{
	precalc();
	vector<vector<long long>> a (11, vector<long long>(12));
	for (int i = 0; i < 11; i++)
	{
		for (int j = 0; j < 11; j++)
		{
			a[i][j] = bpow(i, j);
		}
		cout << "? " << i << endl;
		fflush(stdout);
		cin >> a[i][11];
	}
	vector <long long> av (11);
	for (int i = 0; i < 11; i++)
	{
		if (a[i][i] == 0)
		{
			for (int j = i + 1; j < 11; j++)
			{
				if (a[j][i])
				{
					swap(a[j], a[i]);
					break;
				}
			}
		}
		for (int j = i + 1; j < 11; j++)
		{
			long long d = a[j][i] * rev[a[i][i]];
			for (int k = i; k < 12; k++)
			{
				a[j][k] -= (d * a[i][k]) % mod;
				if (a[j][k] < 0) a[j][k] += mod;
			}
		}
	}
	for (int i = 10; i >= 0; i--)
	{
		for (int j = i + 1; j < 10; j++)
		{
			a[i][11] -= (av[j] * a[i][j]) % mod;
			if (a[i][11] < 0) a[i][11] += mod;
		}
		av[i] = (a[i][11] * rev[a[i][i]]) % mod;
	}
	for (int i = 0; i < mod; i++)
	{
		long long ans = 0;
		for (int j = 0; j < 11; j++)
		{
			ans += (bpow(i, j) * av[j]) % mod;
			ans %= mod;
		}
		if (ans == 0)
		{
			cout << "! " << i << endl;
			fflush(stdout);
			gg;
		}
	}
	cout << "! -1" << endl;
	fflush(stdout);
	gg;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

long long mod = /*27449*//*998244353*/1e9 + 7;
int inf = 1e9;
double eps = 1e-2;

ifstream in("input.txt");
ofstream out("output.txt");

int main()
{
	cout << "? 0" << endl;
	fflush(stdout);
	long long v = 0;
	set<int> tested;
	cin >> v;
	for (int i = 1; i*i <= v; i++)
	{
		if (v % i == 0)
		{
			if (tested.find(i) == tested.end())
			{
				cout << "? " << i << endl;
				tested.insert(i);
				fflush(stdout);
				long long ans;
				cin >> ans;
				if (ans == 0)
				{
					cout << "! " << i << endl;
					fflush(stdout);
					gg;
				}
			}
			if (v / i != i && tested.find(v / i) == tested.end())
			{
				cout << "? " << v / i << endl;
				tested.insert(v / i);
				fflush(stdout);
				long long ans;
				cin >> ans;
				if (ans == 0)
				{
					cout << "! " << v / i << endl;
					fflush(stdout);
					gg;
				}
			}
		}
	}
	v = 1e6 + 3 - v;
	for (int i = 1; i*i <= v; i++)
	{
		if (v % i == 0)
		{
			if (tested.find(i) == tested.end())
			{
				cout << "? " << i << endl;
				tested.insert(i);
				fflush(stdout);
				long long ans;
				cin >> ans;
				if (ans == 0)
				{
					cout << "! " << i << endl;
					fflush(stdout);
					gg;
				}
			}
			if (v / i != i && tested.find(v / i) == tested.end())
			{
				cout << "? " << v / i << endl;
				tested.insert(v / i);
				fflush(stdout);
				long long ans;
				cin >> ans;
				if (ans == 0)
				{
					cout << "! " << v / i << endl;
					fflush(stdout);
					gg;
				}
			}
		}
	}
	cout << "! -1" << endl;
	fflush(stdout);
	gg;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
using namespace std;

long long MOD = 1e6 + 3;

long long binPow(long long x, long long p) {
    if (!p)
        return 1;
    if (p % 2)
        return binPow(x, p - 1) * x % MOD;
    long long r = binPow(x, p / 2);
    return r * r % MOD;
}

long long add(long long a, long long b) {
    return (a + b) % MOD;
}

long long subtract(long long a, long long b) {
    return ((a - b) % MOD + MOD) % MOD;
}

long long inverse(long long a) {
    return binPow(a, MOD - 2);
}

long long multiply(long long a, long long b) {
    return a * b % MOD;
}

long long divide(long long a, long long b) {
    return multiply(a, inverse(b));
}

const int SZ = 11;
long long a[SZ][SZ + 1];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    for (int x = 0; x < SZ; x++) {
        for (int p = 0; p < SZ; p++)
            a[x][p] = binPow(x, p);

        printf("? %d\n", x);
        fflush(stdout);

        scanf("%lld", &a[x][SZ]);
    }

    long long ansRow[SZ];
    fill(ansRow, ansRow + SZ, -1);

    for (int col = 0, row = 0; col < SZ && row < SZ; col++) {
        int bestRow = row;
        for (int i = row + 1; i < SZ; i++)
            if (a[i][col] > a[bestRow][col])
                bestRow = i;

        if (a[bestRow][col] == 0)
            continue;

        for (int j = 0; j < SZ + 1; j++)
            swap(a[row][j], a[bestRow][j]);
        ansRow[col] = row;

        for (int i = 0; i < SZ; i++) {
            if (i == row)
                continue;
            long long k = divide(a[i][col], a[row][col]);
            for (int j = col; j < SZ + 1; j++)
                a[i][j] = subtract(a[i][j], multiply(k, a[row][j]));
        }
        row++;
    }

    long long ans[SZ];
    for (int col = 0; col < SZ; col++)
        ans[col] = (ansRow[col] != -1 ? divide(a[ansRow[col]][SZ], a[ansRow[col]][col]) : 0);

    for (int row = 0; row < SZ; row++) {
        long long s = 0;
        for (int col = 0; col < SZ; col++) {
            s = add(s, multiply(a[row][col], ans[col]));
        }
        if (s - a[row][SZ]) {
            printf("! -1");
            fflush(stdout);
            return 0;
        }
    }

    for (long long x = 0; x < MOD; x++) {
        long long s = 0;
        for (int p = 0; p < SZ; p++) {
            s = add(s, multiply(ans[p], binPow(x, p)));
        }
        if (s == 0) {
            printf("! %lld", x);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1");
    fflush(stdout);
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
using namespace std;

long long MOD = 1e6 + 3;

long long binPow(long long x, long long p) {
    if (!p)
        return 1;
    if (p % 2)
        return binPow(x, p - 1) * x % MOD;
    long long r = binPow(x, p / 2);
    return r * r % MOD;
}

long long add(long long a, long long b) {
    return (a + b) % MOD;
}

long long subtract(long long a, long long b) {
    return ((a - b) % MOD + MOD) % MOD;
}

long long inverse(long long a) {
    return binPow(a, MOD - 2);
}

long long multiply(long long a, long long b) {
    return a * b % MOD;
}

long long divide(long long a, long long b) {
    return multiply(a, inverse(b));
}

long long a[11][12];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    for (int x = 0; x <= 10; x++) {
        for (int p = 0; p <= 10; p++)
            a[x][p] = binPow(x, p);

        printf("? %d\n", x);
        fflush(stdout);

        scanf("%lld", &a[x][11]);
    }

    long long ansRow[11];
    fill(ansRow, ansRow + 11, -1);

    for (int col = 0, row = 0; col < 11 && row < 11; col++) {
        int bestRow = row;
        for (int i = row + 1; i < 11; i++)
            if (a[i][col] > a[bestRow][col])
                bestRow = i;

        if (a[bestRow][col] == 0)
            continue;

        for (int j = 0; j < 12; j++)
            swap(a[row][j], a[bestRow][j]);
        ansRow[col] = row;

        for (int i = 0; i < 11; i++) {
            if (i == row)
                continue;
            long long k = divide(a[i][col], a[row][col]);
            for (int j = col; j < 12; j++)
                a[i][j] = subtract(a[i][j], multiply(k, a[row][j]));
        }
        row++;
    }

    long long ans[11];
    for (int col = 0; col < 11; col++)
        ans[col] = (ansRow[col] != -1 ? divide(a[ansRow[col]][11], a[ansRow[col]][col]) : 0);

    for (int row = 0; row < 11; row++) {
        long long s = 0;
        for (int col = 0; col < 1; col++)
            s = add(s, multiply(a[row][col], ans[col]));
        if (s - a[row][11]) {
            printf("! -1");
            fflush(stdout);
            return 0;
        }
    }

    for (long long x = 0; x < MOD; x++) {
        long long s = 0;
        for (int p = 0; p <= 10; p++) {
            s = add(s, multiply(ans[p], binPow(x, p)));
        }
        if (s == 0) {
            printf("! %lld", x);
            fflush(stdout);
            return 0;
        }
    }

    printf("! -1");
    fflush(stdout);
}


#include <stdio.h>
#include <string.h>

#define N	11
#define MD	1000003

int inv[MD], aa[N][N + 1], bb[N + 1], xx[N];

int power(int a, int b) {
	int p;

	if (b == 0)
		return 1;
	p = power(a, b / 2);
	p = (long long) p * p % MD;
	if (b % 2)
		p = (long long) p * a % MD;
	return p;
}

int add() {
	int i, j;

	for (i = 0; i < N; i++)
		if (bb[i] && aa[i][i]) {
			int a = (long long) bb[i] * inv[aa[i][i]] % MD;

			for (j = i; j <= N; j++)
				bb[j] = (bb[j] - (long long) aa[i][j] * a % MD + MD) % MD;
		}
	for (i = 0; i < N; i++)
		if (bb[i]) {
			for (j = i; j <= N; j++)
				aa[i][j] = bb[j];
			return 1;
		}
	return 0;
}

void init() {
	int a, j, p, cnt;

	for (a = 1; a < MD; a++)
		inv[a] = power(a, MD - 2);
	cnt = 0;
	for (a = 0; a < MD; a++) {
		for (j = 0, p = 1; j < N; j++, p = (long long) p * a % MD)
			bb[j] = p;
		if (add()) {
			xx[cnt++] = a;
			if (cnt == N)
				break;
		}
	}
}

int main() {
	int h, i, j, p, a;

	init();
	memset(aa, 0, sizeof aa);
	for (h = 0; h < N; h++) {
		printf("? %d\n", a = xx[h]);
		fflush(stdout);
		for (j = 0, p = 1; j < N; j++, p = (long long) p * a % MD)
			bb[j] = p;
		scanf("%d", &bb[N]);
		add();
	}
	for (i = N - 1; i >= 0; i--) {
		int x = aa[i][N];

		for (j = i + 1; j < N; j++)
			x = (x - (long long) aa[i][j] * xx[j] % MD + MD) % MD;
		xx[i] = (long long) x * inv[aa[i][i]] % MD;
	}
	for (a = 0; a < MD; a++) {
		int f = 0;

		for (j = 0, p = 1; j < N; j++, p = (long long) p * a % MD)
			f = (f + (long long) xx[j] * p) % MD;
		if (f == 0) {
			printf("! %d\n", a);
			fflush(stdout);
			return 0;
		}
	}
	printf("! -1\n");
	fflush(stdout);
	return 0;
}


/* upsolve with Dukkha */
#include <stdio.h>

#define N	11
#define MD	1000003

int bb[N][N + 1], inv[N]; /* inv[i] = 1 / bb[i][i] */

long long power(int a, int k) {
	long long p;

	if (k == 0)
		return 1;
	p = power(a, k / 2);
	p = p * p % MD;
	if (k % 2)
		p = p * a % MD;
	return p;
}

int add(int *aa, int n) {
	int i, j;

	for (i = 0; i < n; i++)
		if (aa[i] && bb[i][i]) {
			long long a = (long long) aa[i] * inv[i] % MD;

			for (j = i; j <= n; j++)
				aa[j] = (aa[j] - a * bb[i][j]) % MD;
		}
	for (i = 0; i < n; i++)
		if (aa[i]) {
			for (j = i; j <= n; j++)
				bb[i][j] = aa[j];
			inv[i] = power(bb[i][i], MD - 2);
			return 1;
		}
	return 0;
}

void solve(int *xx, int aa[][N + 1], int n) {
	int i, j;

	for (i = 0; i < n; i++)
		add(aa[i], n);
	for (i = n - 1; i >= 0; i--) {
		long long a = bb[i][n];

		for (j = i + 1; j < n; j++)
			a = (a - (long long) bb[i][j] * xx[j]) % MD;
		xx[i] = a * inv[i] % MD;
	}
}

int main() {
	static int aa[N][N + 1], ff[N];
	int x, i;
	long long p;

	for (x = 0; x < N; x++) {
		printf("? %d\n", x);
		fflush(stdout);
		p = 1;
		for (i = 0; i < N; i++) {
			aa[x][i] = p;
			p = p * x % MD;
		}
		scanf("%d", &aa[x][N]);
	}
	solve(ff, aa, N);
	for (x = 0; x < MD; x++) {
		long long a;

		a = 0;
		for (i = 10; i >= 0; i--)
			a = (a * x + ff[i]) % MD;
		if (a == 0) {
			printf("! %d\n", x);
			fflush(stdout);
			return 0;
		}
	}
	printf("! -1\n");
	fflush(stdout);
	return 0;
}


/* upsolve with Dukkha */
#include <stdio.h>

#define N	11
#define MD	1000003

long long power(int a, int k) {
	long long p;

	if (k == 0)
		return 1;
	p = power(a, k / 2);
	p = p * p % MD;
	if (k % 2)
		p = p * a % MD;
	return p;
}

int add(int bb[][N + 1], int *aa, int n) {
	int i, j;

	for (i = 0; i < n; i++) {
		if (!aa[i])
			continue;
		if (bb[i][i]) {
			long long a = aa[i];

			for (j = i; j <= n; j++)
				aa[j] = (aa[j] - a * bb[i][j]) % MD;
		} else {
			long long inv = power(aa[i], MD - 2);

			for (j = i; j <= n; j++)
				bb[i][j] = aa[j] * inv % MD;
			return 1;
		}
	}
	return 0;
}

void gauss(int bb[][N + 1], int aa[][N + 1], int n) {
	int i, j;

	for (i = 0; i < n; i++)
		add(bb, aa[i], n);
	for (i = n - 1; i >= 0; i--) {
		long long b = bb[i][n];

		for (j = n - 1; j > i; j--) {
			b = (b - (long long) bb[i][j] * bb[j][n]) % MD;
			bb[i][j] = 0;
		}
		bb[i][n] = b;
	}
}

int main() {
	static int aa[N][N + 1], bb[N][N + 1];
	int x, i;
	long long p, a;

	for (x = 0; x < N; x++) {
		printf("? %d\n", x);
		fflush(stdout);
		p = 1;
		for (i = 0; i < N; i++) {
			aa[x][i] = p;
			p = p * x % MD;
		}
		scanf("%d", &aa[x][N]);
	}
	gauss(bb, aa, N);
	for (x = 0; x < MD; x++) {
		a = 0;
		for (i = N - 1; i >= 0; i--)
			a = (a * x + bb[i][N]) % MD;
		if (a == 0) {
			printf("! %d\n", x);
			fflush(stdout);
			return 0;
		}
	}
	printf("! -1\n");
	fflush(stdout);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<math.h>
#include<string.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

const i32 mod = 1000000 + 3;

#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)
#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  i32 s = r;
  while (n > 0) {
    if (n & 1) t = (i64) t * s % mod;
    s = (i64) s * s % mod;
    n >>= 1;
  }
  return t;
}

i32 *fact = NULL;
i32 *iFact = NULL;
void init_fact (const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = inv (fact[n]);
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) (i + 1) * iFact[i + 1] % mod;
  }
}

i32 perm (i32 n, i32 k) {
  if (!(0 <=k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod;
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod * iFact[n - k] % mod;
}

i32 query (i32 x) {
  putchar ('?');
  putchar (' ');
  print_int (x);
  putchar ('\n');
  fflush (stdout);
  return (i32)read_int();
}

void answer (i32 x) {
  putchar ('!');
  putchar (' ');
  print_int (x);
  putchar ('\n');
  fflush (stdout);
  exit (0);
}

void run (void) {
  init_fact (mod - 1);
  i32 k = 10;
  i32 *b = (i32 *) calloc (k + 1, sizeof (i32));
  for (i32 i = 0; i <= k; ++i) {
    i32 y = query (i);
    if (y == 0) {
      answer (i);
    }
    for (i32 j = 0; j < i; ++j) {
      i32 z = (i64) b[j] * perm (i, i - j) % mod;
      y = (y + mod - z) % mod;
    }
    b[i] = (i64) y * inv (fact[i]) % mod;
  }
  for (i32 x = k + 1; x < mod; ++x) {
    i32 y = 0;
    for (i32 j = 0; j <= k; ++j) {
      y = (y + (i64) b[j] * perm (x, x - j)) % mod;
    }
    if (y == 0) {
      answer (x);
    }
  }
  puts ("! -1");
}

int main (void) {
  run ();
  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

const i32 mod = 1000000 + 3;

#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)
#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

void gauss (i32 *a, i32 *b, i32 n) {
  for (i32 i = 0; i < n; ++i) {
    i32 p = inv (a[i * n + i]);
    for (i32 j = i; j < n; ++j) {
      a[i * n + j] = (i64) a[i * n + j] * p % mod;
    }
    b[i] = (i64) b[i] * p % mod;
    for (i32 j = i + 1; j < n; ++j) {
      i32 p = a[j * n + i];
      for (i32 k = i; k < n; ++k) {
	SUB(a[j * n + k], (i64)p * a[i * n + k] % mod);
      }
      SUB(b[j], (i64)b[i] * p % mod);
    }
  }
  for (i32 i = n - 1; i >= 0; --i) {
    for (i32 j = i - 1; j >= 0; --j) {
      SUB(b[j], (i64) b[i] * a[j * n + i] % mod);
      a[j * n + i] = 0;
    }
  }
}

i32 query (i32 x) {
  putchar ('?');
  putchar (' ');
  print_int (x);
  putchar ('\n');
  fflush (stdout);
  return read_int();
}

void run (void) {
  const i32 k = 11;
  i32 *m = (i32 *) calloc (k * k, sizeof (i32));
  i32 *b = (i32 *) calloc (k, sizeof (i32));
  for (i32 x = 0; x < k; ++x) {
    b[x] = query (x);
    for (i32 j = 0, p = 1; j < k; ++j, p = (i64) p * x % mod) {
      m[x * k + j] = p;
    }
  }
  gauss (m, b, k);
  for (i32 x = 0; x < mod; ++x) {
    i32 y = 0;
    for (i32 j = k - 1; j >= 0; --j) {
      y = ((i64) y * x + b[j]) % mod;
    }
    if (y == 0) {
      putchar ('!');
      putchar (' ');
      print_int (x);
      puts("");
      return;
    }
  }
  puts ("! -1");
}

int main (void) {
  run ();
  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<math.h>
#include<string.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

const i32 mod = 1000000 + 3;

#define ADD(x, a) do{(x) += (a); if ((x) >= mod) (x) -= mod;} while (0)
#define SUB(x, a) do{(x) += mod - (a); if ((x) >= mod) (x) -= mod;} while (0)

i32 inv (i32 a) {
  i32 t = 1;
  while (a > 1) {
    t = (i64) t * (mod - mod / a) % mod;
    a = mod % a;
  }
  return t;
}

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  i32 s = r;
  while (n > 0) {
    if (n & 1) t = (i64) t * s % mod;
    s = (i64) s * s % mod;
    n >>= 1;
  }
  return t;
}

i32 *fact = NULL;
i32 *iFact = NULL;
void init_fact (const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = inv (fact[n]);
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) (i + 1) * iFact[i + 1] % mod;
  }
}

i32 perm (i32 n, i32 k) {
  if (!(0 <=k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod;
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod * iFact[n - k] % mod;
}

i32 query (i32 x) {
  putchar ('?');
  putchar (' ');
  print_int (x);
  putchar ('\n');
  fflush (stdout);
  return (i32)read_int();
}

void answer (i32 x) {
  putchar ('!');
  putchar (' ');
  print_int (x);
  putchar ('\n');
  fflush (stdout);
  exit (0);
}

void run (void) {
  init_fact (mod - 1);
  i32 k = 10;
  i32 *b = (i32 *) calloc (k + 1, sizeof (i32));
  b[0] = query (0);
  if (b[0] == 0) {
    answer (0);
  }
  for (i32 i = 1; i <= k; ++i) {
    i32 y = query (i);
    if (y == 0) {
      answer (i);
    }
    for (i32 j = 0; j < i; ++j) {
      i32 z = b[j] * perm (i, i - j) % mod;
      SUB(y, z);
    }
    b[i] = (i64) y * inv (fact[i]) % mod;
  }
  for (i32 x = k + 1; x < mod; ++x) {
    i32 y = 0;
    for (i32 j = 0; j <= k; ++j) {
      y = (y + (i64) b[j] * perm (x, x - j)) % mod;
    }
    if (y == 0) {
      answer (x);
    }
  }
  puts ("! -1");
}

int main (void) {
  run ();
  return 0;
}


/*
    AUTH -> krishna-3249
    DATE -> 9/8/20
    TIME -> 8:04 PM
*/

/*
    Simple can be harder than complex.
    Body, mind and spirit.
    Strive for progress, not perfection.
*/

import java.lang.*;
import java.io.*;
import java.util.*;

public class A {

    private static final long MOD = 1_000_000_000 + 7;

    private long power(long base, long exponent) {
        long res = 1;
        while (exponent > 0) {
            if ((exponent & 1) == 1) {
                res = (res * base) % MOD;
                exponent--;
            } else {
                base = (base * base) % MOD;
                exponent = exponent >> 1;
            }
        }
        return res;
    }

    private long inverseMod(long number) {
        return power(number, MOD - 2);
    }

    private int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    private long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    private static class Node {
        public int index, value;

        public Node(int index, int value) {
            this.index = index;
            this.value = value;
        }
    }

    public void solve(Read input, Write output) throws Exception {
        int cases = input.readInt();
        while (cases-- > 0) {
            int N = input.readInt();
            int[] arr = input.readIntArray(N);
            List<Node> even = new ArrayList<>();
            List<Node> odd = new ArrayList<>();
            int evenone = 0;
            int oddone = 0;
            for (int i=0;i<N;i++) {
                if (i%2==0) {
                    if (arr[i]==1) {
                        evenone++;
                        even.add(new Node(i, arr[i]));
                    }
                } else {
                    if (arr[i]==1) {
                        oddone++;
                        odd.add(new Node(i, arr[i]));
                    }
                }
            }
            boolean[] remove = new boolean[N];
            if (oddone!=evenone) {
                if (oddone>evenone) {
                     for (int i=odd.size()-1, c=0;c<(oddone-evenone) && i>=0;i--,c++) {
                         remove[odd.get(i).index] = true;
                     }
                } else {
                    for (int i=even.size()-1, c=0;c<(evenone-oddone) && i>=0;i--,c++) {
                        remove[even.get(i).index] = true;
                    }
                }
            }
            int len = 0;
            for (int i=0;i<N;i++) {
                if (!remove[i]) {
                    len++;
                }
            }
            output.printLine(len);
            for (int i=0;i<N;i++) {
                if (!remove[i]) {
                    output.print(arr[i]);
                    output.print(" ");
                }
            }
            output.printLine("");
        }
    }

    public static void main(String[] args) throws Exception {
        Read input = new Read();
        Write output = new Write();
        A D = new A();
        D.solve(input, output);
        output.flush();
        output.close();
    }

    // java fast io reader and writer
    // taken from various sources and customized

    static class Read {

        private byte[] buffer = new byte[10 * 1024];
        private int index;
        private InputStream input_stream;
        private int total;

        public Read() {
            input_stream = System.in;
        }

        public int read() throws IOException {
            if (total < 0)
                throw new InputMismatchException();
            if (index >= total) {
                index = 0;
                total = input_stream.read(buffer);
                if (total <= 0)
                    return -1;
            }
            return buffer[index++];
        }

        public long readLong() throws IOException {
            long number = 0;
            int n = read();
            while (isWhiteSpace(n))
                n = read();
            long neg = 1l;
            if (n == '-') {
                neg = -1l;
                n = read();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    number *= 10l;
                    number += (long) (n - '0');
                    n = read();
                } else throw new InputMismatchException();
            }
            return neg * number;
        }

        public int readInt() throws IOException {
            int integer = 0;
            int n = read();
            while (isWhiteSpace(n))
                n = read();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = read();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = read();
                } else throw new InputMismatchException();
            }
            return neg * integer;
        }

        public double readDouble() throws IOException {
            double doub = 0;
            int n = read();
            while (isWhiteSpace(n))
                n = read();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = read();
            }
            while (!isWhiteSpace(n) && n != '.') {
                if (n >= '0' && n <= '9') {
                    doub *= 10;
                    doub += n - '0';
                    n = read();
                } else throw new InputMismatchException();
            }

            if (n == '.') {
                n = read();
                double temp = 1;
                while (!isWhiteSpace(n)) {
                    if (n >= '0' && n <= '9') {
                        temp /= 10;
                        doub += (n - '0') * temp;
                        n = read();
                    } else throw new InputMismatchException();
                }
            }
            return doub * neg;
        }

        public String readString() throws IOException {
            StringBuilder sb = new StringBuilder();
            int n = read();
            while (isWhiteSpace(n))
                n = read();
            while (!isWhiteSpace(n)) {
                sb.append((char) n);
                n = read();
            }
            return sb.toString();
        }

        public List<Double> readDoubleList(int size) throws IOException {
            List<Double> res = new ArrayList<>();
            for (int i = 0; i < size; i++) {
                res.add(this.readDouble());
            }
            return res;
        }

        public double[] readDoubleArray(int size) throws IOException {
            double[] res = new double[size];
            for (int i = 0; i < size; i++) {
                res[i] = this.readDouble();
            }
            return res;
        }

        public List<String> readStringList(int size) throws IOException {
            List<String> res = new ArrayList<>();
            for (int i = 0; i < size; i++) {
                res.add(this.readString());
            }
            return res;
        }

        public String[] readStringArray(int size) throws IOException {
            String[] res = new String[size];
            for (int i = 0; i < size; i++) {
                res[i] = this.readString();
            }
            return res;
        }

        public List<Integer> readIntList(int size) throws IOException {
            List<Integer> res = new ArrayList<>();
            for (int i = 0; i < size; i++) {
                res.add(this.readInt());
            }
            return res;
        }

        public List<Long> readLongList(int size) throws IOException {
            List<Long> res = new ArrayList<>();
            for (int i = 0; i < size; i++) {
                res.add(this.readLong());
            }
            return res;
        }

        public int[] readIntArray(int size) throws IOException {
            int[] res = new int[size];
            for (int i = 0; i < size; i++) {
                res[i] = this.readInt();
            }
            return res;
        }

        public long[] readLongArray(int size) throws IOException {
            long[] res = new long[size];
            for (int i = 0; i < size; i++) {
                res[i] = this.readLong();
            }
            return res;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
                return true;
            return false;
        }
    }

    static class Write {

        private final BufferedWriter bw;

        public Write() {
            bw = new BufferedWriter(new OutputStreamWriter(System.out));
        }

        public void print(Object str) throws IOException {
            bw.append(str + "");
        }

        public void printLine(Object str) throws IOException {
            print(str);
            bw.append("\n");
        }

        public void close() throws IOException {
            bw.close();
        }

        public void flush() throws IOException {
            bw.flush();
        }
    }
}


import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/8 10:51 下午
 */
public class Ahahahahahahahaha {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int[] a = new int[10000];
            int n = scanner.nextInt();
            int oneCount = 0;
            for(int i = 0;i<n;i++){
                a[i] = scanner.nextInt();
                if(a[i] == 1){
                    oneCount++;
                }
            }
            int deletedOneNum = 0;
            int deletedZeroNum = 0;
            deletedOneNum = oneCount % 2;
            deletedZeroNum = deletedOneNum == oneCount?0:(n - deletedOneNum)%2;
            System.out.println(n - (deletedZeroNum + deletedOneNum));
            boolean flag = false;
            for(int i =0;i<n;i++){
                if(deletedOneNum > 0 && a[i] == 1){
                    deletedOneNum--;
                    continue;
                }
                if(deletedZeroNum > 0 && a[i] == 0){
                    deletedZeroNum--;
                    continue;
                }
                if(flag){
                    System.out.print(" ");
                }
                System.out.print(a[i]);
                flag = true;
            }
            System.out.println();
        }
    }
}


import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/8 10:51 下午
 */
public class Ahahahahahahahaha {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int[] a = new int[10000];
            int n = scanner.nextInt();
            int oneCount = 0;
            for(int i = 0;i<n;i++){
                a[i] = scanner.nextInt();
                if(a[i] == 1){
                    oneCount++;
                }
            }
            int deletedOneNum = 0;
            int deletedZeroNum = 0;
            deletedOneNum = oneCount % 2;
            deletedZeroNum = deletedOneNum == oneCount?0:(n - deletedOneNum)%2;
            System.out.println(n - (deletedZeroNum + deletedOneNum));
            for(int i =0;i<n;i++){
                if(deletedOneNum > 0 && a[i] == 1){
                    deletedOneNum--;
                    continue;
                }
                if(deletedZeroNum > 0 && a[i] == 0){
                    deletedZeroNum--;
                    continue;
                }
                System.out.print(a[i]+" ");
            }
        }
    }
}


import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/8 10:51 下午
 */
public class Ahahahahahahahaha {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int[] a = new int[10000];
            int[] ans = new int[10000];
            int index = 0;
            int n = scanner.nextInt();
            int oneIndex = -1;
            for(int i = 0;i<n;i++){
                a[i] = scanner.nextInt();
                if(a[i] == 1){
                    if(oneIndex == -1){
                        oneIndex = index;
                    }else{
                        if((index - oneIndex)%2 == 0){
                            index--;
                        }
                        oneIndex = -1;
                    }
                }
                ans[index++] = a[i];
            }
            System.out.println(index - (oneIndex == -1?0:1));
            boolean flag = false;
            for(int i = 0;i<index;i++){
                if(oneIndex == i){
                    continue;
                }
                if(flag){
                    System.out.print(" ");
                }
                System.out.print(ans[i]);
                flag = true;
            }
            System.out.println();
        }
    }
}


import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/8 10:51 下午
 */
public class Ahahahahahahahaha {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int[] a = new int[10000];
            int[] ans = new int[10000];
            int index = 0;
            int n = scanner.nextInt();
            int oneIndex = -1;
            for(int i = 0;i<n;i++){
                a[i] = scanner.nextInt();
                if(a[i] == 1){
                    if(oneIndex == -1){
                        oneIndex = i;
                    }else{
                        if((i - oneIndex)%2 == 0){
                            index--;
                        }
                        oneIndex = -1;
                    }
                }
                ans[index++] = a[i];
            }
            System.out.println(index - (oneIndex == -1?0:1));
            boolean flag = false;
            for(int i = 0;i<n;i++){
                if(oneIndex == i){
                    continue;
                }
                if(flag){
                    System.out.print(" ");
                }
                System.out.print(ans[i]);
                flag = true;
            }
            System.out.println();
        }
    }
}


import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/8 10:51 下午
 */
public class Ahahahahahahahaha {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        while (t-- > 0) {
            int[] a = new int[10000];
            int[] ans = new int[10000];
            int index = 0;
            int n = scanner.nextInt();
            int oneIndex = -1;
            for(int i = 0;i<n;i++){
                a[i] = scanner.nextInt();
                if(a[i] == 1){
                    if(oneIndex == -1){
                        oneIndex = index;
                    }else{
                        if((index - oneIndex)%2 == 0){
                            index--;
                        }
                        oneIndex = -1;
                    }
                }
                ans[index++] = a[i];
            }
            System.out.println(index - (oneIndex == -1?0:1));
            boolean flag = false;
            for(int i = 0;i<n;i++){
                if(oneIndex == i){
                    continue;
                }
                if(flag){
                    System.out.print(" ");
                }
                System.out.print(ans[i]);
                flag = true;
            }
            System.out.println();
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

// 1 0 1 0 0
public class D {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int t=sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			int a[]=sc.readArray(n);
			int sum1=0,sum2=0;
			ArrayList<Integer> al=new ArrayList<>();
			ArrayList<Integer> a1=new ArrayList<>();
			ArrayList<Integer> a2=new ArrayList<>();
			for(int i=0;i<n;i++ ) {
				al.add(a[i]);
				if(i%2==0) {
					sum1+=a[i];
				if(a[i]==1)	a1.add(i);
				}
				else {
					sum2+=a[i];
					if(a[i]==1) a2.add(i);
				}
			}
			//System.out.println(sum1+" "+sum2);
			if(sum1==sum2) {
				System.out.println(n);
				for(int i:a) System.out.print(i+" ");

			}
			else if(sum1>sum2) {
				// del 0,2,4..
				//System.out.println("a1 "+a1);

				int i=0;
				while(sum1!=sum2) {
					sum1--;
					int x=a1.get(i);
					al.remove(x);
					i++;

				}
				System.out.println(al.size());
				for(int i1:al) System.out.print(i1+" ");
			}
			else {
				//System.out.println("a2 "+a2);
				int i=0;
				while(sum1!=sum2) {
					sum2--;
					int x=a2.get(i);
					al.remove(x);
					i++;

				}
				System.out.println(al.size());
				for(int i1:al) System.out.print(i1+" ");
			}
			System.out.println();
		}

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;

// 1 0 1 0 0
public class D {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int t=sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			int a[]=sc.readArray(n);
			int sum1=0,sum2=0;
			ArrayList<Integer> al=new ArrayList<>();
			ArrayList<Integer> a1=new ArrayList<>();
			ArrayList<Integer> a2=new ArrayList<>();
			for(int i=0;i<n;i++ ) {
				al.add(a[i]);
				if(i%2==0) {
					sum1+=a[i];
				if(a[i]==1)	a1.add(i);
				}
				else {
					sum2+=a[i];
					if(a[i]==1) a2.add(i);
				}
			}
			//System.out.println(sum1+" "+sum2);
			if(sum1==sum2) {
				System.out.println(n);
				for(int i:a) System.out.print(i+" ");

			}
			else if(sum1>sum2) {
				// del 0,2,4..
				//System.out.println("a1 "+a1);

				int i=0;
				int count=0;
				while(sum1!=sum2) {
					sum1--;
					int x=a1.get(i)-count;
					al.remove(x);
					i++;
					count++;

				}
				System.out.println(al.size());
				for(int i1:al) System.out.print(i1+" ");
			}
			else {
				//System.out.println("a2 "+a2);
				int i=0;
				int count=0;
				while(sum1!=sum2) {
					sum2--;
					int x=a2.get(i)-count;
					al.remove(x);
					i++;
					count++;

				}
				System.out.println(al.size());
				for(int i1:al) System.out.print(i1+" ");
			}
			System.out.println();
		}

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int t = sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			int a[]=sc.readArray(n);
			int num0=0;
			for(int i:a) if(i==0) num0++;
			System.out.println(n/2);
			if(num0>=n/2) {
				for(int i=0;i<n/2;i++) System.out.print(0+" ");
			}
			else {
				for(int i=0;i<n/2;i++) System.out.print(1+" ");
			}
			System.out.println();
		}

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class A {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int t = sc.nextInt();
		while(t-->0) {
			int n=sc.nextInt();
			int a[]=sc.readArray(n);
			int num0=0;
			for(int i:a) if(i==0) num0++;

			if(num0>=n/2) {
				System.out.println(n/2);
				for(int i=0;i<n/2;i++) System.out.print(0+" ");
			}
			else {
				System.out.println(n/2+ (n/2%2));
				for(int i=0;i<n/2;i++) System.out.print(1+" ");
				if(n/2%2==1)
					System.out.print(1+" ");

			}
			System.out.println();
		}

	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


import java.util.*;
import java.io.*;

public class code{

	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] arg) throws IOException{
		Reader in=new Reader();
		//Scanner in=new Scanner(System.in);

		int t=in.nextInt();

		while(t-- > 0){
			int n=in.nextInt();

			int one=0;
			int zero=0;

			int[] arr=new int[n];

			for(int i=0;i<n;i++){
				arr[i]=in.nextInt();
				if(arr[i]==0)
					zero++;
				else
					one++;
			}

			if(zero>=n/2){
				System.out.println(zero);
				for(int i=0;i<zero;i++)
					System.out.print(0+" ");
			}
			else{
				System.out.println(one);
				for(int i=0;i<one;i++)
					System.out.print(1+" ");
			}

			System.out.println();
		}
	}
}


import java.util.*;
import java.io.*;

public class code{

	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] arg) throws IOException{
		Reader in=new Reader();
		//Scanner in=new Scanner(System.in);

		int t=in.nextInt();

		while(t-- > 0){
			int n=in.nextInt();

			int one=0;
			int zero=0;

			int[] arr=new int[n];

			for(int i=0;i<n;i++){
				arr[i]=in.nextInt();
				if(arr[i]==0)
					zero++;
				else
					one++;
			}

			if(zero>=n/2){
				System.out.println(zero);
				for(int i=0;i<zero;i++)
					System.out.print(0+" ");
			}
			else{
				if(one%2!=0)
					one--;
				System.out.println(one);
				for(int i=0;i<one;i++)
					System.out.print(1+" ");
			}

			System.out.println();
		}
	}
}


import java.util.*;
import java.io.*;

public class code{

	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] arg) throws IOException{
		Reader in=new Reader();
		//Scanner in=new Scanner(System.in);

		int t=in.nextInt();

		while(t-- > 0){
			int n=in.nextInt();

			int one=0;
			int zero=0;

			int[] arr=new int[n];

			for(int i=0;i<n;i++){
				arr[i]=in.nextInt();
				if(arr[i]==0)
					zero++;
				else
					one++;
			}

			if(zero>=n/2){
				System.out.println(zero);
				for(int i=0;i<zero;i++)
					System.out.print(0+" ");
			}
			else{
				System.out.println(one);
				for(int i=0;i<one-1;i++)
					System.out.print(1+" ");
			}

			System.out.println();
		}
	}
}


import java.util.*;
import java.io.*;

public class code{

	static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

	public static void main(String[] arg) throws IOException{
		Reader in=new Reader();
		//Scanner in=new Scanner(System.in);

		int t=in.nextInt();

		while(t-- > 0){
			int n=in.nextInt();

			int one=0;
			int zero=0;

			int[] arr=new int[n];

			for(int i=0;i<n;i++){
				arr[i]=in.nextInt();
				if(arr[i]==0)
					zero++;
				else
					one++;
			}

			if(zero>=n/2){
				System.out.println(zero);
				for(int i=0;i<zero;i++)
					System.out.print(0+" ");
			}
			else{
				System.out.println(one-1);
				for(int i=0;i<one-1;i++)
					System.out.print(1+" ");
			}

			System.out.println();
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;;
import java.util.StringTokenizer;
public class prob6691
{
    public static void main (String args[])
    {
        FastReader sc=new FastReader();
        int t=sc.nextInt();
        int n,i,arr[],one,zero;
        while(t-->0)
        {
            n=sc.nextInt();
            arr=new int[n];
            one=0;
            zero=0;
            for(i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
                if(arr[i]==1)
                    one++;
                else
                    zero++;
            }
            if(one>zero)
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("1 ");
                System.out.println();
            }
            else
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("0 ");
                System.out.println();
            }
        }
    }
}
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    { a
        br = new BufferedReader(new
        InputStreamReader(System.in));
    }
    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;;
import java.util.StringTokenizer;
public class prob6691
{
    public static void main (String args[])
    {
        FastReader sc=new FastReader();
        int t=sc.nextInt();
        int n,i,arr[],one,zero;
        while(t-->0)
        {
            n=sc.nextInt();
            arr=new int[n];
            one=0;
            zero=0;
            for(i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
                if(arr[i]==1)
                    one++;
                else
                    zero++;
            }
            if(one>zero)
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("1 ");
                System.out.println();
            }
            else
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("0 ");
                System.out.println();
            }
        }
    }
}
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br = new BufferedReader(new
        InputStreamReader(System.in));
    }
    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;;
import java.util.StringTokenizer;
public class prob6691
{
    public static void main (String args[])
    {
        FastReader sc=new FastReader();
        int t=sc.nextInt();
        int n,i,arr[],one,zero;
        /*
         * 4
2
1 0
2
0 0
4
0 1 1 1
4
1 1 0 0

         */
        while(t-->0)
        {
            n=sc.nextInt();
            arr=new int[n];
            one=0;
            zero=0;
            for(i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
                if(arr[i]==0)
                    zero++;
            }
            if(zero>=(n/2))
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("0 ");
                System.out.println();
            }
            else
            {
                System.out.println(n/2);
                if(zero%2==0)
                {
                    for(i=0;i<(n/2-zero);i++)
                        System.out.print("1 ");
                    for(i=0;i<zero;i++)
                        System.out.print("0 ");
                    System.out.println();
                }
                else
                {
                    for(i=0;i<(n/2-zero+1);i++)
                        System.out.print("1 ");
                    for(i=0;i<zero-1;i++)
                        System.out.print("0 ");
                    System.out.println();
                }
            }
        }
    }
}
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br = new BufferedReader(new
        InputStreamReader(System.in));
    }
    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;;
import java.util.StringTokenizer;
public class prob6691
{
    public static void main (String args[])
    {
        FastReader sc=new FastReader();
        int t=sc.nextInt();
        int n,i,arr[],one,zero;
        /*
         * 4
2
1 0
2
0 0
4
0 1 1 1
4
1 1 0 0

         */
        while(t-->0)
        {
            n=sc.nextInt();
            arr=new int[n];
            one=0;
            zero=0;
            for(i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
                if(arr[i]==0)
                    zero++;
            }
            if(zero>=(n/2))
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("0 ");
                System.out.println();
            }
            else
            {
                if((n/2)%2==0)
                {
                    System.out.println(n/2);
                    for(i=0;i<n/2;i++)
                        System.out.print("1 ");
                    System.out.println();
                }
                else
                {
                    System.out.println((n/2)+1);
                    for(i=0;i<n/2+1;i++)
                        System.out.print("1 ");
                    System.out.println();
                }
            }
        }
    }
}
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br = new BufferedReader(new
        InputStreamReader(System.in));
    }
    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;;
import java.util.StringTokenizer;
public class prob6691
{
    public static void main (String args[])
    {
        FastReader sc=new FastReader();
        int t=sc.nextInt();
        int n,i,arr[],one,zero;
        /*
         * 4
2
1 0
2
0 0
4
0 1 1 1
4
1 1 0 0

         */
        while(t-->0)
        {
            n=sc.nextInt();
            arr=new int[n];
            one=0;
            zero=0;
            for(i=0;i<n;i++)
            {
                arr[i]=sc.nextInt();
                if(arr[i]==0)
                    zero++;
            }
            if(zero>=(n/2))
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("0 ");
                System.out.println();
            }
            else
            {
                System.out.println(n/2);
                for(i=0;i<n/2;i++)
                    System.out.print("1 ");
                System.out.println();
                }
            }
        }
    }
class FastReader
{
    BufferedReader br;
    StringTokenizer st;
    public FastReader()
    {
        br = new BufferedReader(new
        InputStreamReader(System.in));
    }
    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }
    int nextInt()
    {
        return Integer.parseInt(next());
    }
    long nextLong()
    {
        return Long.parseLong(next());
    }
    double nextDouble()
    {
        return Double.parseDouble(next());
    }
    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}


import java.util.*;
import java.io.*;
public class a {
	static final FS sc = new FS();
	static final PrintWriter pw = new PrintWriter(System.out);

	static int n, num0s, num1s;
	public static void main(String[] args) {
		int t = sc.nextInt();
		for(int tt = 1; tt <= t; ++tt) {
			n = sc.nextInt();
			num0s = num1s = 0;

			for(int i = 0; i < n; ++i) {
				if(sc.nextInt() == 0) ++num0s;
				else ++num1s;
			}

			int k = -1, val = -1;
			if(num0s >= num1s) {
				k = num0s;
				val = 0;
			}
			else {
				k = num1s - (num1s % 2);
				val = 1;
			}

			pw.println(k);
			for(int j = 0; j < k; ++j) pw.print(val + " ");
			pw.println();
		}
		pw.flush();
	}
	static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch(Exception e) {}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int n =sc.nextInt();
		    int arr[] = new int[n];
		    int sum = 0;
		    for(int i = 0; i<n; i++){
		        arr[i] = sc.nextInt();
		        if(i % 2 == 1)arr[i] = -arr[i];
		        sum += arr[i];
		    }
		    boolean neg = false;
		    if(sum < 0)neg = true;
		    sum = Math.abs(sum - 0);
		    out.println(n - sum);
		    for(int i = 0; i<n; i++){
		        if(sum > 0 && arr[i] == -1 && neg){
		            arr[i] = 2;
		            sum--;
		            continue;
		        }
		        else if(sum > 0 && arr[i] == 1 && !neg){
		            arr[i] = 2;
		            sum--;
		            continue;
		        }
		    }
		    for(int i = 0; i<n; i++)if(arr[i] != 2)out.print((arr[i] < 0 ? -arr[i] : arr[i])  + " ");
		    out.println("");
		}
		out.flush();
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int n =sc.nextInt();
		    int arr[] = new int[n];
		    int sum = 0;
		    for(int i = 0; i<n; i++){
		        arr[i] = sc.nextInt();
		        if(i % 2 == 1)arr[i] = -arr[i];
		        sum += arr[i];
		    }
		    boolean neg = false;
		    if(sum < 0)neg = true;
		    sum = Math.abs(sum - 0);
		    out.println(n - sum);
		    for(int i = 0; i<n; i++){
		        if(sum > 0 && arr[i] == -1 && neg){
		            sum--;
		            continue;
		        }
		        else if(sum > 0 && arr[i] == 1 && !neg){
		            sum--;
		            continue;
		        }
		        else out.print((arr[i] < 0 ? -arr[i] : arr[i])  + " ");
		    }
		    out.println("");
		}
		out.flush();
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int n =sc.nextInt();
		    int arr[] = new int[n];
		    int sum = 0;
		    for(int i = 0; i<n; i++){
		        arr[i] = sc.nextInt();
		        if(i % 2 == 0)sum += arr[i];
		        else sum -= arr[i];
		    }
		    sum = Math.abs(sum - 0);
		    out.println(n - sum);
		    for(int i = 0; i<n; i++){
		        if(sum > 0 && arr[i] == 1){
		            sum--;
		            continue;

		        }
		        else out.print(arr[i] + " ");
		    }
		    out.println("");
		}
		out.flush();
	}
}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int T = sc.nextInt();
		for(int t = 0; t<T; t++){
		    int n =sc.nextInt();
		    int arr[] = new int[n];
		    int sum = 0;
		    for(int i = 0; i<n; i++){
		        arr[i] = sc.nextInt();
		        if(i % 2 == 1)arr[i] = -arr[i];
		        sum += arr[i];
		    }
		    boolean neg = false;
		    if(sum < 0)neg = true;
		    sum = Math.abs(sum - 0);
		    out.println(n - sum);
		    for(int i = n - 1; i >=0 ; i--){
		        if(sum > 0 && arr[i] == -1 && neg){
		            arr[i] = 2;
		            sum--;
		            continue;
		        }
		        else if(sum > 0 && arr[i] == 1 && !neg){
		            arr[i] = 2;
		            sum--;
		            continue;
		        }
		    }
		    for(int i = 0; i<n; i++)if(arr[i] != 2)out.print((arr[i] < 0 ? -arr[i] : arr[i])  + " ");
		    out.println("");
		}
		out.flush();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.LinkedList;

public class A
{
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int t = Integer.parseInt(br.readLine());
		while(t-->0)
		{
			int n = Integer.parseInt(br.readLine());
			int[] arr = new int[n];
			HashSet<Integer> removed = new HashSet<Integer>();
			String[] inp = br.readLine().split(" ");
			int even=0,odd=0;
			for(int i=0;i<n;i++)
				{
					int x =Integer.parseInt(inp[i]);
					arr[i]=x;
					if(x==1)
					{
						if((i&1)==0)even++;
						else odd++;
					}
				}
			boolean oddindex=true;
			for(int i=0;i<n;i++)
			{
				if(odd==even)break;
				if(arr[i]==1)
				{
					if((i&1)==0 && (removed.size()&1)==0)even--;
					else odd--;
					int tmp=odd;
					odd=even;
					even=tmp;
					removed.add(i);
				}
			}
			pw.println(n-removed.size());
			for(int i=0;i<n;i++)
			{
				if(!removed.contains(i))pw.print(arr[i]+" ");
			}
			pw.println();

		}
		pw.close();
		pw.flush();
	}

}