#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

vector <pii> v;
void rec(int i, int num1, int num2, const int curr_or, const int sum, int carry) {
	if(i == 16) {
		v.pb({num1, num2});
		return;
	}

	if(curr_or >> i & 1) {
		if(sum >> i & 1) {
			if(carry) {
				rec(i + 1, num1 + (1 << i), num2 + (1 << i), curr_or, sum, 1);
			}
			else {
				rec(i + 1, num1 + (1 << i), num2, curr_or, sum, 0);
				rec(i + 1, num1, num2 + (1 << i), curr_or, sum, 0);
			}
		}
		else {
			if(carry) {
				rec(i + 1, num1 + (1 << i), num2, curr_or, sum, 1);
				rec(i + 1, num1, num2 + (1 << i), curr_or, sum, 1);
			}
			else {
				rec(i + 1, num1 + (1 << i), num2 + (1 << i), curr_or, sum, 1);
			}
		}
	}
	else {
		rec(i + 1, num1, num2, curr_or, sum, 0);
	}
}

int main()
{
	boost;
	int n, i;
	cin >> n;

	int xo[n];
	fo(i, 1, n) {
		cout << "XOR " << 1 << ' ' << i + 1 << endl;
		int x;
		cin >> x;
		xo[i] = x;
	}

	cout << "AND " << 1 << ' ' << 2 << endl;
	int curr_and;
	cin >> curr_and;

	cout << "OR " << 1 << ' ' << 2 << endl;
	int curr_or;
	cin >> curr_or;

	int sum = xo[1] + 2 * curr_and;
	rec(0, 0, 0, curr_or, sum, 0);

	cout << "OR " << n - 1 << ' ' << n << endl;
	int last_and;
	cin >> last_and;

	int ans1 = -1;
	for(pii p : v) {
		int num1 = p.f;
		int last_num1 = num1 ^ xo[n - 1];
		int last_num2 = num1 ^ xo[n - 2];

		/*int num2 = p.s;
		int last_num2 = num2 ^ xo[1] ^ xo[n - 1];

		if(last_num != last_num2) continue;
		if((num1 & num2) != curr_and) continue;
		if((num1 | (num2)) != curr_or) continue;*/

		bool ok = 1;
		if((last_num1 | last_num2) != last_and) ok = 0;

		if(ok) {
			ans1 = num1;
			break;
		}
	}

	cout << "! " << ans1 << ' ';
	fo(i, 1, n)
	cout << (ans1 ^ xo[i]) << ' ';
	cout << endl;
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	int n, i;
	cin >> n;
	int xo[n + 1];

	auto get_xor = [] (int x) {
		cout << "XOR " << 1 << ' ' << x << '\n';
		int a;
		cin >> a;
		return a;
	};

	auto get_and = [] (int x, int y) {
		cout << "AND " << x << ' ' << y << '\n';
		int a;
		cin >> a;
		return a;
	};

	for(int i = 2; i <= n; i++)
	xo[i] = get_xor(i);

	vector<int> vis(1 << 16, 0);
	int num1 = -1;

	for(int i = 2; i <= n; i++) {
		if(xo[i] == 0) {
			num1 = get_and(1, i);
			break;
		}
		else if(vis[xo[i]]) {
			num1 = xo[i] ^ get_and(vis[xo[i]], i);
			break;
		}
		vis[xo[i]] = i;
	}

	if(num1 == -1) {
		int curr = 0;
		for(int i = 2; i <= n; i++) {
			if(xo[i] == 1) {
				curr = get_and(1, i);
				break;
			}
		}

		for(int i = 0; i <= n; i++) {
			if(xo[i] == 2) {
				curr += (get_and(1, i) & 1);
				break;
			}
		}
		num1 = curr;
	}

	cout << "! " << num1 << ' ';
	for(int i = 2; i <= n; i++)
	cout << (xo[i] ^ num1) << ' ';
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	int a[n + 1];

	int a12, a23, a13, x12, x23, x13;
	cout << "AND " << 1 << ' ' << 2 << endl;
	cin >> a12;

	cout << "XOR " << 1 << ' ' << 2 << endl;
	cin >> x12;

	cout << "AND " << 2 << ' ' << 3 << endl;
	cin >> a23;

	cout << "XOR " << 2 << ' ' << 3 << endl;
	cin >> x23;

	cout << "AND " << 1 << ' ' << 3 << endl;
	cin >> a13;
	x13 = x12 ^ x23;

	int s12 = x12 + 2 * a12, s23 = x23 + 2 * a23, s13 = x13 + 2 * a13;
	a[1] = (s12 + s13 - s23) / 2;
	a[2] = s12 - a[1];
	a[3] = s13 - a[1];

	for(int i = 4; i <= n; i++) {
		cout << "XOR " << 1 << ' ' << i << endl;
		int x;
		cin >> x;
		a[i] = a[1] ^ x;
	}

	cout << "! ";
	for(int i = 1; i <= n; i++)
	cout << a[i] << ' ';
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

vector <pii> v;
void rec(int i, int num1, int num2, const int curr_or, const int sum, int carry) {
	if(i == 16) {
		v.pb({num1, num2});
		return;
	}

	if(curr_or >> i & 1) {
		if(sum >> i & 1) {
			if(carry) {
				rec(i + 1, num1 + (1 << i), num2 + (1 << i), curr_or, sum, 1);
			}
			else {
				rec(i + 1, num1 + (1 << i), num2, curr_or, sum, 0);
				rec(i + 1, num1, num2 + (1 << i), curr_or, sum, 0);
			}
		}
		else {
			if(carry) {
				rec(i + 1, num1 + (1 << i), num2, curr_or, sum, 1);
				rec(i + 1, num1, num2 + (1 << i), curr_or, sum, 1);
			}
			else {
				rec(i + 1, num1 + (1 << i), num2 + (1 << i), curr_or, sum, 1);
			}
		}
	}
	else {
		rec(i + 1, num1, num2, curr_or, sum, 0);
	}
}

int main()
{
	int n, i;
	cin >> n;

	int xo[n];
	fo(i, 1, n) {
		cout << "XOR " << 1 << ' ' << i + 1 << endl;
		int x;
		cin >> x;
		xo[i] = x;
	}

	cout << "AND " << 1 << ' ' << 2 << endl;
	int curr_and;
	cin >> curr_and;

	cout << "OR " << 1 << ' ' << 2 << endl;
	int curr_or;
	cin >> curr_or;

	int sum = xo[1] + 2 * curr_and;
	rec(0, 0, 0, curr_or, sum, 0);

	cout << "AND " << 1 << ' ' << n << endl;
	int last_and;
	cin >> last_and;

	int ans1 = -1;
	for(pii p : v) {
		int num = p.f;
		int last_num = num ^ xo[n - 1];

		bool ok = 1;
		if((num & last_num) != last_and) ok = 0;

		if(ok) {
			ans1 = num;
			break;
		}
	}

	cout << "! " << ans1 << ' ';
	fo(i, 1, n)
	cout << (ans1 ^ xo[i]) << ' ';
	cout << endl;
}


#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

vector <pii> v;
void rec(int i, int num1, int num2, const int curr_or, const int sum, int carry) {
	if(i == 16) {
		v.pb({num1, num2});
		return;
	}

	if(curr_or >> i & 1) {
		if(sum >> i & 1) {
			if(carry) {
				rec(i + 1, num1 + (1 << i), num2 + (1 << i), curr_or, sum, 1);
			}
			else {
				rec(i + 1, num1 + (1 << i), num2, curr_or, sum, 0);
				rec(i + 1, num1, num2 + (1 << i), curr_or, sum, 0);
			}
		}
		else {
			if(carry) {
				rec(i + 1, num1 + (1 << i), num2, curr_or, sum, 1);
				rec(i + 1, num1, num2 + (1 << i), curr_or, sum, 1);
			}
			else {
				rec(i + 1, num1 + (1 << i), num2 + (1 << i), curr_or, sum, 1);
			}
		}
	}
	else {
		rec(i + 1, num1, num2, curr_or, sum, 0);
	}
}

int main()
{
	boost;
	int n, i;
	cin >> n;

	int xo[n];
	fo(i, 1, n) {
		cout << "XOR " << 1 << ' ' << i + 1 << endl;
		int x;
		cin >> x;
		xo[i] = x;
	}

	cout << "AND " << 1 << ' ' << 2 << endl;
	int curr_and;
	cin >> curr_and;

	cout << "OR " << 1 << ' ' << 2 << endl;
	int curr_or;
	cin >> curr_or;

	int sum = xo[1] + 2 * curr_and;
	rec(0, 0, 0, curr_or, sum, 0);

	cout << "AND " << n - 1 << ' ' << n << endl;
	int last_and;
	cin >> last_and;

	int ans1 = -1;
	for(pii p : v) {
		int num1 = p.f;
		int last_num1 = num1 ^ xo[n - 1];
		int last_num2 = num1 ^ xo[n - 2];

		/*int num2 = p.s;
		int last_num2 = num2 ^ xo[1] ^ xo[n - 1];

		if(last_num != last_num2) continue;
		if((num1 & num2) != curr_and) continue;
		if((num1 | (num2)) != curr_or) continue;*/

		bool ok = 1;
		if((last_num1 & last_num2) != last_and) ok = 0;

		if(ok) {
			ans1 = num1;
			break;
		}
	}

	cout << "! " << ans1 << ' ';
	fo(i, 1, n)
	cout << (ans1 ^ xo[i]) << ' ';
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = (1 << 16) + 5;
int n;
int ans;
int arr[MAXN];
int XOR(int a, int b) {
	cout << "XOR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int OR(int a, int b) {
	cout << "OR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int AND(int a, int b) {
	cout << "AND " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
void init() {
	int or_ret = OR(1, 2);
	int and_ret = AND(1, 2);
	int or_ret_1 = OR(1, 3);
	int and_ret_2 = AND(2, 3);
	for (int i = 31; i >= 0; i--) {
		if (and_ret & (1 << i)) {
			arr[1] |= (1 << i);
			arr[2] |= (1 << i);
		}
		else if (or_ret & (1 << i)) {
			// [1, 0] 또는 [0, 1]
			if (!(or_ret_1 & (1 << i))) {
				arr[2] |= (1 << i);
			}
			else {
				if (and_ret_2 & (1 << i)) {
					arr[2] |= (1 << i);
				}
				else {
					arr[1] |= (1 << i);
				}
			}
		}
	}
}
int main() {
	cin >> n;
	init();
	vector<int> q;
	for (int i = 3; i <= n; i++) {
		int xor_ret = XOR(1, i);
		arr[i] = arr[1] ^ xor_ret;
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << arr[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = (1 << 16) + 5;
int n;
int ans;
int arr[MAXN];
int XOR(int a, int b) {
	cout << "XOR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int OR(int a, int b) {
	cout << "OR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int AND(int a, int b) {
	cout << "AND " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
void init() {
	int or_ret = OR(1, 2);
	int and_ret = AND(1, 2);
	int or_ret_1 = OR(1, 3);
	int and_ret_1 = AND(1, 3);
	for (int i = 31; i >= 0; i--) {
		if (and_ret & (1 << i)) {
			arr[1] |= (1 << i);
			arr[2] |= (1 << i);
		}
		else if (!(and_ret & (1 << i)) && (or_ret & (1<<i))) {
			// [1, 0] 또는 [0, 1]
			if (and_ret_1 & (1 << i)) {
				arr[1] |= (1 << i);
			}
			else if (!(or_ret_1 & (1 << i))) {
				arr[2] |= (1 << i);
			}
		}
	}
}
int main() {
	cin >> n;
	vector<int> q;
	for (int i = 3; i <= n; i++) {
		int xor_ret = XOR(1, i);
		arr[i] = arr[1] ^ xor_ret;
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << arr[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = (1 << 16) + 5;
int n;
int ans;
int arr[MAXN];
int XOR(int a, int b) {
	cout << "XOR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int OR(int a, int b) {
	cout << "OR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int AND(int a, int b) {
	cout << "AND " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
void init() {
	int or_ret = OR(1, 2);
	int and_ret = AND(1, 2);
	int or_ret_1 = OR(1, 3);
	int and_ret_1 = AND(1, 3);
	for (int i = 31; i >= 0; i--) {
		if (and_ret & (1 << i)) {
			arr[1] |= (1 << i);
			arr[2] |= (1 << i);
		}
		else if (!(and_ret & (1 << i)) && (or_ret & (1<<i))) {
			// [1, 0] 또는 [0, 1]
			if (and_ret_1 & (1 << i)) {
				arr[1] |= (1 << i);
			}
			else if (!(or_ret_1 & (1 << i))) {
				arr[2] |= (1 << i);
			}
		}
	}
}
int main() {
	cin >> n;
	init();
	vector<int> q;
	for (int i = 3; i <= n; i++) {
		int xor_ret = XOR(1, i);
		arr[i] = arr[1] ^ xor_ret;
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << arr[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = (1 << 16) + 5;
int n;
int ans;
int arr[MAXN];
int XOR(int a, int b) {
	cout << "XOR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int OR(int a, int b) {
	cout << "OR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int AND(int a, int b) {
	cout << "AND " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
void init() {
	int or_ret = OR(1, 2);
	int and_ret = AND(1, 2);
	int or_ret_1 = OR(1, 3);
	int and_ret_2 = AND(2, 3);
	for (int i = 31; i >= 0; i--) {
		if (and_ret & (1 << i)) {
			arr[1] |= (1 << i);
			arr[2] |= (1 << i);
		}
		else if (or_ret & (1 << i)) {
			// [1, 0] 또는 [0, 1]
			if (!(or_ret_1 & (1 << i))) {
				arr[2] |= (1 << i);
			}
			else {
				if (and_ret_2 & (1 << i)) {
					arr[1] |= (1 << i);
				}
				else {
					arr[2] |= (1 << i);
				}
			}
		}
	}
}
int main() {
	cin >> n;
	init();
	vector<int> q;
	for (int i = 3; i <= n; i++) {
		int xor_ret = XOR(1, i);
		arr[i] = arr[1] ^ xor_ret;
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << arr[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = (1 << 16) + 5;
int n;
int ans;
int arr[MAXN];
int XOR(int a, int b) {
	cout << "XOR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int OR(int a, int b) {
	cout << "OR " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
int AND(int a, int b) {
	cout << "AND " << a << " " << b << "\n";
	cin >> ans;
	return ans;
}
void init() {
	int or_ret = OR(1, 2);
	int and_ret = AND(1, 2);
	int or_ret_1 = OR(1, 3);
	int and_ret_1 = AND(1, 3);
	for (int i = 31; i >= 0; i--) {
		if (and_ret & (1 << i)) {
			arr[1] |= (1 << i);
			arr[2] |= (1 << i);
		}
		else if (!(and_ret & (1 << i)) && (or_ret & (1<<i))) {
			// [1, 0] 또는 [0, 1]
			if (and_ret_1 & (1 << i)) {
				arr[1] |= (1 << i);
			}
			else if (!(or_ret_1 & (1 << i))) {
				arr[2] |= (1 << i);
			}
		}
	}
	for (int i = 31; i >= 0; i--) {
		if (and_ret & (1 << i)) {
			arr[1] |= (1 << i);
			arr[2] |= (1 << i);
		}
		else if (!(and_ret & (1 << i)) && (or_ret & (1 << i))) {
			arr[1] |= (1 << i);
		}
	}
}
int main() {
	cin >> n;
	vector<int> q;
	for (int i = 3; i <= n; i++) {
		int xor_ret = XOR(1, i);
		arr[i] = arr[1] ^ xor_ret;
	}
	cout << "! ";
	for (int i = 1; i <= n; i++) cout << arr[i] << " ";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
//#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	//cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n+1, 1);

		ll a1,a2,a3;
		ll x1,x2,x3;

		cout<<"AND 1 2"<<endl;
		//cout.flush();
		cin>>a1;

		cout<<"AND 1 3"<<endl;
		//cout.flush();
		cin>>a2;

		cout<<"AND 2 3"<<endl;
		//cout.flush();
		cin>>a3;

		cout<<"XOR 1 2"<<endl;
		//cout.flush();
		cin>>x1;

		cout<<"XOR 1 3"<<endl;
		//cout.flush();
		cin>>x2;

		// Third XOR
		x3 = x1 ^ x2;

		ll s1 = x1 + 2*a1;
		ll s2 = x2 + 2*a2;
		ll s3 = x3 + 2*a3;

		v[1] = (s1 + s2 - s3) / 2;
		v[2] = (s1 + s3 - s2) / 2;
		v[3] = (s2 + s3 - s1) / 2;

		for(int i=4;i<=n;i++)
		{
			ll xr;
			cout<<"XOR "<<i - 1<<" "<<i<<endl;
			//cout.flush();
			cin>>xr;

			v[i] = xr ^ v[i-1];
		}

		cout<<"! ";
		for(int i=1;i<=n;i++) cout<<v[i]<<" ";
		cout<<endl;
		//cout.flush();
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	//cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n+1, 1);

		ll a1,a2,a3;
		ll x1,x2,x3;

		cout<<"AND 1 2";
		cout.flush();
		cin>>a1;

		cout<<"AND 1 3";
		cout.flush();
		cin>>a2;

		cout<<"AND 2 3";
		cout.flush();
		cin>>a3;

		cout<<"XOR 1 2";
		cout.flush();
		cin>>x1;

		cout<<"XOR 1 3";
		cout.flush();
		cin>>x2;

		// Third XOR
		x3 = x1 ^ x2;

		ll s1 = x1 + 2*a1;
		ll s2 = x2 + 2*a2;
		ll s3 = x3 + 2*a3;

		v[1] = (s1 + s2 - s3) / 2;
		v[2] = (s1 + s3 - s2) / 2;
		v[3] = (s2 + s3 - s1) / 2;

		for(int i=4;i<=n;i++)
		{
			ll xr;
			cout<<"XOR "<<i - 1<<" "<<i;
			cout.flush();
			cin>>xr;

			v[i] = xr ^ v[i-1];
		}

		cout<<"! ";
		for(int i=1;i<=n;i++) cout<<v[i]<<" ";
		cout.flush();
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	//cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n+1, 1);

		ll a1,a2,a3;
		ll x1,x2,x3;

		cout<<"AND 1 2"<<endl;
		cin>>a1;

		cout<<"AND 1 3"<<endl;
		cin>>a2;

		cout<<"AND 2 3"<<endl;
		cin>>a3;

		cout<<"XOR 1 2"<<endl;
		cin>>x1;

		cout<<"XOR 1 3"<<endl;
		cin>>x2;

		// Third XOR
		x3 = x1 ^ x2;

		ll s1 = x1 + 2*a1;
		ll s2 = x2 + 2*a2;
		ll s3 = x3 + 2*a3;

		v[1] = (s1 + s2 - s3) / 2;
		v[2] = (s1 + s3 - s2) / 2;
		v[3] = (s2 + s3 - s1) / 2;

		for(int i=4;i<=n;i++)
		{
			ll xr;
			cout<<"XOR "<<i - 1<<" "<<i<<endl;
			cin>>xr;

			v[i] = xr ^ v[i-1];
		}

		cout<<"! ";
		for(int i=1;i<=n;i++) cout<<v[i]<<" ";
		cout<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	//cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n+1, 1);

		ll a1,a2,a3;
		ll x1,x2,x3;

		cout<<"AND 1 2"<<endl;
		cin>>a1;

		cout<<"AND 1 3"<<endl;
		cin>>a2;

		cout<<"AND 2 3"<<endl;
		cin>>a3;

		cout<<"XOR 1 2"<<endl;
		cin>>x1;

		cout<<"XOR 1 3"<<endl;
		cin>>x2;

		// Third XOR
		x3 = x1 ^ x2;

		ll s1 = x1 + 2*a1;
		ll s2 = x2 + 2*a2;
		ll s3 = x3 + 2*a3;

		v[1] = (s1 + s2 - s3) / 2;
		v[2] = (s1 + s3 - s2) / 2;
		v[3] = (s2 + s3 - s1) / 2;

		for(int i=4;i<=n;i++)
		{
			ll xr;
			cout<<"XOR "<<i - 1<<" "<<i<<endl;
			cin>>xr;

			v[i] = xr ^ v[i-1];
		}

		cout<<"! ";
		for(int i=1;i<=n;i++) cout<<v[i]<<" "<<endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	//cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n+1, 1);

		ll a1,a2,a3;
		ll x1,x2,x3;

		cout<<"AND 1 2"<<endl;
		cout.flush();
		cin>>a1;

		cout<<"AND 1 3"<<endl;
		cout.flush();
		cin>>a2;

		cout<<"AND 2 3"<<endl;
		cout.flush();
		cin>>a3;

		cout<<"XOR 1 2"<<endl;
		cout.flush();
		cin>>x1;

		cout<<"XOR 1 3"<<endl;
		cout.flush();
		cin>>x2;

		// Third XOR
		x3 = x1 ^ x2;

		ll s1 = x1 + 2*a1;
		ll s2 = x2 + 2*a2;
		ll s3 = x3 + 2*a3;

		v[1] = (s1 + s2 - s3) / 2;
		v[2] = (s1 + s3 - s2) / 2;
		v[3] = (s2 + s3 - s1) / 2;

		for(int i=4;i<=n;i++)
		{
			ll xr;
			cout<<"XOR "<<i - 1<<" "<<i<<endl;
			cout.flush();
			cin>>xr;

			v[i] = xr ^ v[i-1];
		}

		cout<<"! ";
		for(int i=1;i<=n;i++) cout<<v[i]<<" ";
		cout<<endl;
		cout.flush();
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n;
ll a[10];
ll ans[1000010];

int main(void)
{
	scanf("%lld", &n);

	printf("XOR 1 2\n");
	fflush(stdout);

	scanf("%lld", &a[0]);

	printf("XOR 1 3\n");
	fflush(stdout);

	scanf("%lld", &a[1]);

	printf("XOR 1 4\n");
	fflush(stdout);

	scanf("%lld", &a[2]);

	printf("AND 2 3\n");
	fflush(stdout);

	scanf("%lld", &a[3]);

	printf("OR 2 4\n");
	fflush(stdout);

	scanf("%lld", &a[4]);

	printf("AND 3 4\n");
	fflush(stdout);

	scanf("%lld", &a[5]);

	for(ll i = 0 ; i < n ; i++)
	{
		ll A = i;
		ll B = (a[0] ^ i);
		ll C = (a[1] ^ i);
		ll D = (a[2] ^ i);

		if(A >= 0 && B >= 0 && C >= 0 && D >= 0 && A < n && B < n && C < n && D < n)
		{
			if((B & C) == a[3] && (B | D) == a[4] && (C & D) == a[5])
			{
				ans[1] = A;
				ans[2] = B;
				ans[3] = C;
				ans[4] = D;
				break;
			}
		}
	}

	for(ll i = 5 ; i <= n ; i++)
	{
		ll tmp;

		printf("XOR 4 %lld\n", i);
		fflush(stdout);

		scanf("%lld", &tmp);
		ans[i] = (tmp ^ ans[4]);
	}

	printf("! ");

	for(ll i = 1 ; i <= n ; i++)
		printf("%lld ", ans[i]);

	printf("\n");
	fflush(stdout);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n;
ll a[10];
ll ans[1000010];

int main(void)
{
	scanf("%lld", &n);

	printf("XOR 1 2\n");
	fflush(stdout);

	scanf("%lld", &a[0]);

	printf("XOR 1 3\n");
	fflush(stdout);

	scanf("%lld", &a[1]);

	printf("XOR 1 4\n");
	fflush(stdout);

	scanf("%lld", &a[2]);

	printf("AND 2 3\n");
	fflush(stdout);

	scanf("%lld", &a[3]);

	printf("XOR 2 4\n");
	fflush(stdout);

	scanf("%lld", &a[4]);

	printf("OR 3 4\n");
	fflush(stdout);

	scanf("%lld", &a[5]);

	for(ll i = 0 ; i < n ; i++)
	{
		ll A = i;
		ll B = (a[0] ^ i);
		ll C = (a[1] ^ i);
		ll D = (a[2] ^ i);

		if(A >= 0 && B >= 0 && C >= 0 && D >= 0 && A < n && B < n && C < n && D < n)
		{
			if((B & C) == a[3] && (B ^ D) == a[4] && (C | D) == a[5])
			{
				ans[1] = A;
				ans[2] = B;
				ans[3] = C;
				ans[4] = D;
				break;
			}
		}
	}

	for(ll i = 5 ; i <= n ; i++)
	{
		ll tmp;

		printf("XOR 4 %lld\n", i);
		fflush(stdout);

		scanf("%lld", &tmp);
		ans[i] = (tmp ^ ans[4]);
	}

	printf("! ");

	for(ll i = 1 ; i <= n ; i++)
		printf("%lld ", ans[i]);

	printf("\n");
	fflush(stdout);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n;
ll a[10];
ll ans[1000010];

int main(void)
{
	scanf("%lld", &n);

	printf("XOR 1 2\n");
	fflush(stdout);

	scanf("%lld", &a[0]);

	printf("XOR 1 3\n");
	fflush(stdout);

	scanf("%lld", &a[1]);

	printf("XOR 1 4\n");
	fflush(stdout);

	scanf("%lld", &a[2]);

	printf("AND 2 3\n");
	fflush(stdout);

	scanf("%lld", &a[3]);

	printf("OR 2 4\n");
	fflush(stdout);

	scanf("%lld", &a[4]);

	printf("XOR 3 4\n");
	fflush(stdout);

	scanf("%lld", &a[5]);

	for(ll i = 0 ; i < n ; i++)
	{
		ll A = i;
		ll B = (a[0] ^ i);
		ll C = (a[1] ^ i);
		ll D = (a[2] ^ i);

		if(A >= 0 && B >= 0 && C >= 0 && D >= 0 && A < n && B < n && C < n && D < n)
		{
			if((B & C) == a[3] && (B | D) == a[4] && (C ^ D) == a[5])
			{
				ans[1] = A;
				ans[2] = B;
				ans[3] = C;
				ans[4] = D;
				break;
			}
		}
	}

	for(ll i = 5 ; i <= n ; i++)
	{
		ll tmp;

		printf("XOR 4 %lld\n", i);
		fflush(stdout);

		scanf("%lld", &tmp);
		ans[i] = (tmp ^ ans[4]);
	}

	printf("! ");

	for(ll i = 1 ; i <= n ; i++)
		printf("%lld ", ans[i]);

	printf("\n");
	fflush(stdout);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n;
ll a[10];
ll ans[1000010];

int main(void)
{
	scanf("%lld", &n);

	printf("XOR 1 2\n");
	fflush(stdout);

	scanf("%lld", &a[0]);

	printf("XOR 1 3\n");
	fflush(stdout);

	scanf("%lld", &a[1]);

	printf("XOR 1 4\n");
	fflush(stdout);

	scanf("%lld", &a[2]);

	printf("XOR 2 3\n");
	fflush(stdout);

	scanf("%lld", &a[3]);

	printf("XOR 2 4\n");
	fflush(stdout);

	scanf("%lld", &a[4]);

	printf("XOR 3 4\n");
	fflush(stdout);

	scanf("%lld", &a[5]);

	for(ll i = 0 ; i < n ; i++)
	{
		ll A = i;
		ll B = (a[0] ^ i);
		ll C = (a[1] ^ i);
		ll D = (a[2] ^ i);
		if(A < n && B < n && C < n && D < n)
		{
			if((B ^ C) == a[3] && (B ^ D) == a[4] && (C ^ D) == a[5])
			{
				ans[1] = A;
				ans[2] = B;
				ans[3] = C;
				ans[4] = D;
				break;
			}
		}

	}

	for(ll i = 5 ; i <= n ; i++)
	{
		ll tmp;

		printf("XOR 1 %lld\n", i);
		fflush(stdout);

		scanf("%lld", &tmp);
		ans[i] = (tmp ^ ans[0]);
	}

	printf("! ");

	for(ll i = 1 ; i <= n ; i++)
		printf("%lld ", ans[i]);

	printf("\n");
	fflush(stdout);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n;
ll a[10];
ll ans[1000010];

int main(void)
{
	scanf("%lld", &n);

	printf("XOR 1 2\n");
	fflush(stdout);

	scanf("%lld", &a[0]);

	printf("XOR 1 3\n");
	fflush(stdout);

	scanf("%lld", &a[1]);

	printf("XOR 1 4\n");
	fflush(stdout);

	scanf("%lld", &a[2]);

	printf("XOR 2 3\n");
	fflush(stdout);

	scanf("%lld", &a[3]);

	printf("XOR 2 4\n");
	fflush(stdout);

	scanf("%lld", &a[4]);

	printf("XOR 3 4\n");
	fflush(stdout);

	scanf("%lld", &a[5]);

	for(ll i = 0 ; i < n ; i++)
	{
		ll A = i;
		ll B = (a[0] ^ i);
		ll C = (a[1] ^ i);
		ll D = (a[2] ^ i);

		if(A >= 0 && B >= 0 && C >= 0 && D >= 0 && A < n && B < n && C < n && D < n)
		{
			if((B ^ C) == a[3] && (B ^ D) == a[4] && (C ^ D) == a[5])
			{
				ans[1] = A;
				ans[2] = B;
				ans[3] = C;
				ans[4] = D;
				break;
			}
		}
	}

	for(ll i = 5 ; i <= n ; i++)
	{
		ll tmp;

		printf("XOR 1 %lld\n", i);
		fflush(stdout);

		scanf("%lld", &tmp);
		ans[i] = (tmp ^ ans[1]);
	}

	printf("! ");

	for(ll i = 1 ; i <= n ; i++)
		printf("%lld ", ans[i]);

	printf("\n");
	fflush(stdout);

	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef double ld;
#define MAX 5000000000000000000LL
#define MIN -5000000000000000000LL

ll n;
ll a[10];
ll ans[1000010];

int main(void)
{
	scanf("%lld", &n);

	printf("XOR 1 2\n");
	fflush(stdout);

	scanf("%lld", &a[0]);

	printf("XOR 1 3\n");
	fflush(stdout);

	scanf("%lld", &a[1]);

	printf("XOR 1 4\n");
	fflush(stdout);

	scanf("%lld", &a[2]);

	printf("XOR 2 3\n");
	fflush(stdout);

	scanf("%lld", &a[3]);

	printf("XOR 2 4\n");
	fflush(stdout);

	scanf("%lld", &a[4]);

	printf("XOR 3 4\n");
	fflush(stdout);

	scanf("%lld", &a[5]);

	for(ll i = 0 ; i < n ; i++)
	{
		ll A = i;
		ll B = (a[0] ^ i);
		ll C = (a[1] ^ i);
		ll D = (a[2] ^ i);

		if(A >= 0 && B >= 0 && C >= 0 && D >= 0 && A < n && B < n && C < n && D < n)
		{
			if((B ^ C) == a[3] && (B ^ D) == a[4] && (C ^ D) == a[5])
			{
				ans[1] = A;
				ans[2] = B;
				ans[3] = C;
				ans[4] = D;
			}
		}
	}

	for(ll i = 5 ; i <= n ; i++)
	{
		ll tmp;

		printf("XOR 4 %lld\n", i);
		fflush(stdout);

		scanf("%lld", &tmp);
		ans[i] = (tmp ^ ans[4]);
	}

	printf("! ");

	for(ll i = 1 ; i <= n ; i++)
		printf("%lld ", ans[i]);

	printf("\n");
	fflush(stdout);

	return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    long n; cin>>n;
    vector<long> nums(n, 0);
    for(long i=1;i<n;i++) {
        cout<<"XOR 1 "<<(i+1)<<endl;
        cout.flush();
        cin>>nums[i];
    }
    unordered_map<long, long> um;
    for(long i=1;i<n;i++) {
        if(nums[i]==0) {
            cout<<"AND 1 "<<(i+1)<<endl;
            cout.flush();
            cin>>nums[0];
            break;
        }
        if(um.count(nums[i])) {
            long j = um[nums[i]];
            cout<<"AND "<<(i+1)<<" "<<(j+1)<<endl;
            cout.flush();
            long x; cin>>x;
            nums[0] = x^nums[i];
            break;
        }
    }
    cout<<"! "<<nums[0];
    for(long i=1;i<n;i++) cout<<" "<<(nums[i]^nums[0]);
    cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    long long n; cin>>n;
    vector<long long> a(n, 0);
    for(long i=1;i<n;i++) {
        cout<<"XOR 1 "<<(i+1)<<endl;
        cout.flush();
        cin>>a[i];
    }
    long long x, y, z, u, v, w;
    cout<<"AND 1 2"<<endl;
    cout.flush();
	cin>>x;
	cout<<"AND 1 3"<<endl;
    cout.flush();
	cin>>y;
	cout<<"AND 2 3"<<endl;
    cout.flush();
	cin>>z;
	u=2*x+a[1];
	v=2*y+(a[1]^a[2]);
	w=2*z+a[2];
	u=(u+v+w)/2-w;
	cout<<"! "<<u<<" ";
    for(long i=1;i<n;i++) cout<<" "<<(a[i]^u);
    cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> nums(n, 0);
    for(int i=1;i<n;i++) {
        cout<<"XOR 1 "<<(i+1)<<endl;
        cout.flush();
        cin>>nums[i];
    }
    unordered_map<int, int> um;
    for(int i=1;i<n;i++) {
        if(nums[i]==0) {
            cout<<"AND 1 "<<(i+1)<<endl;
            cout.flush();
            cin>>nums[0];
            break;
        }
        if(um.count(nums[i])) {
            int j = um[nums[i]];
            cout<<"AND "<<(i+1)<<" "<<(j+1)<<endl;
            cout.flush();
            int x; cin>>x;
            nums[0] = x^nums[i];
            break;
        }
    }
    cout<<"! "<<nums[0];
    for(int i=1;i<n;i++) cout<<" "<<(nums[i]^nums[0]);
    cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    long n; cin>>n;
    vector<long> a(n, 0);
    for(long i=1;i<n;i++) {
        cout<<"XOR 1 "<<(i+1)<<endl;
        cout.flush();
        cin>>a[i];
    }
    long x, y, z, u, v, w;
    cout<<"AND 1 2"<<endl;
    cout.flush();
	cin>>x;
	cout<<"AND 1 3"<<endl;
    cout.flush();
	cin>>y;
	cout<<"AND 2 3"<<endl;
    cout.flush();
	cin>>z;
	u=2*x+a[1];
	v=2*y+(a[1]^a[2]);
	w=2*z+a[2];
	u=(u+v+w)/2-w;
	cout<<"! "<<u<<" ";
    for(long i=1;i<n;i++) cout<<" "<<(a[i]^u);
    cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    int n; cin>>n;
    vector<int> nums(n, 0);
    for(int i=1;i<n;i++) {
        cout<<"XOR 0 "<<i<<endl;
        cout.flush();
        cin>>nums[i];
    }
    unordered_map<int, int> um;
    for(int i=1;i<n;i++) {
        if(nums[i]==0) {
            cout<<"AND 0 "<<i<<endl;
            cout.flush();
            cin>>nums[0];
            break;
        }
        if(um.count(nums[i])) {
            int j = um[nums[i]];
            cout<<"AND "<<i<<" "<<j<<endl;
            cout.flush();
            int x; cin>>x;
            nums[0] = x^nums[i];
            break;
        }
    }
    cout<<"! "<<nums[0];
    for(int i=1;i<n;i++) cout<<" "<<(nums[i]^nums[0]);
    cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    long long n; cin>>n;
    vector<long long> a(n, 0);
    for(long i=1;i<n;i++) {
        cout<<"XOR "<<i<<" "<<(i+1)<<endl;
        cout.flush();
        cin>>a[i];
    }
    long long x, y, z, u, v, w;
    cout<<"AND 1 2"<<endl;
    cout.flush();
	cin>>x;
	cout<<"AND 1 3"<<endl;
    cout.flush();
	cin>>y;
	cout<<"AND 2 3"<<endl;
    cout.flush();
	cin>>z;
	u=2*x+a[1];
	v=2*y+(a[1]^a[2]);
	w=2*z+a[2];
	u=(u+v+w)/2-w;
	cout<<"! "<<u;
    for(long i=1;i<n;i++) {
        u^=a[i];
        cout<<" "<<u;
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main(){
    long n; cin>>n;
    vector<long> nums(n, 0);
    for(long i=1;i<n;i++) {
        cout<<"XOR 1 "<<(i+1)<<endl;
        cout.flush();
        cin>>nums[i];
    }
    unordered_map<long, long> um;
    for(long i=1;i<n;i++) {
        if(nums[i]==0) {
            cout<<"AND 1 "<<(i+1)<<endl;
            cout.flush();
            cin>>nums[0];
            break;
        }
        if(um.count(nums[i])) {
            long j = um[nums[i]];
            cout<<"AND "<<(i+1)<<" "<<(j+1)<<endl;
            cout.flush();
            long x; cin>>x;
            nums[0] = x^nums[i];
            break;
        }
        um[nums[i]] = i;
    }
    cout<<"! "<<nums[0];
    for(long i=1;i<n;i++) cout<<" "<<(nums[i]^nums[0]);
    cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
#define rint register unsigned long long
int n,xval[1000050],xpo,xo[1000050],xsum[1000050],po[1000050];
bool f=0;

signed main(){
	cin>>n;
	po[0]=1;
	for(register int i=2;i<=n;++i){
		cout<<"XOR "<<i-1<<" "<<i<<endl;
		cout.flush();
		cin>>xo[i-1];
		xsum[i]=xsum[i-1]^xo[i-1];
		if(!f&&po[xsum[i]]){
			cout<<"OR "<<po[xsum[i]]<<" "<<i<<endl;
				cout.flush();
			cin>>xval[i]; xpo=i; f=1;
		}
		else po[xsum[i]]=i;
	}
	if(!f){
		for(rint i=1;i<=n;++i){
			if(xsum[i]==n-1){
				int x1,x2;
				cout<<"AND "<<1<<" "<<(i==n?n-1:n)<<endl;
				cout.flush();
				cin>>x1;
				cout<<"AND "<<i<<" "<<(i==n?n-1:n)<<endl;
				cout.flush();
				cin>>x2;
				xpo=(i==n?n-1:n); xval[(i==n?n-1:n)]=x1|x2;
				break;
			}
		}
	}
	for(rint i=xpo-1;i;--i)
		xval[i]=xval[i+1]^xo[i];
	for(rint i=xpo+1;i<=n;++i)
		xval[i]=xval[i-1]^xo[i-1];
	cout<<"!";
	for(rint i=1;i<=n;++i)
		cout<<" "<<xval[i];
	cout<<endl;
	return 0;
}


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

int a[105][105];
int n,m,k,minc;

void solve1(int x[15]){
	int cnt,tot;
	tot = 0;
	for (int i = 1; i <= m; i++){
		if (a[1][i] != x[i])
			cnt++;
	}
	for (int i = 2; i <= n; i++){
		cnt = 0;
		for (int j = 1; j <= m; j++){
			if (a[i][j] != x[j])
				cnt++;
		}
		tot += min(cnt, m - cnt);
	}
	if (tot <= k){
		if (tot < minc)
			minc = tot;
	}
}

void solve2(){
	int cnt,tot;
	for (int p = 1; p <= n; p++){
		tot = 0;
		for (int i = 1; i <= n; i++){
			cnt = 0;
			for (int j = 1; j <= m; j++){
				if (a[i][j] != a[p][j])
					cnt++;
			}
			tot += min(cnt, m - cnt);
		}
		if (tot <= k){
			if (tot < minc)
				minc = tot;
		}
	}
	for (int p = 1; p <= m; p++){
		tot = 0;
		for (int j = 1; j <= m; j++){
			cnt = 0;
			for (int i = 1; i <= n; i++){
				if (a[i][j] != a[i][p])
					cnt++;
			}
			tot += min(cnt, n - cnt);
		}
		if (tot <= k){
			if (tot < minc)
				minc = tot;
		}
	}
}

void brute(){
	int temp,cnt,temp1;
	int x[15];
	temp = 1;
	for (int i = 1; i <= m; i++)
		temp *= 2;
	for (int i = 0; i < temp; i++){
		temp1 = i;
		for (int j = 1; j <= m; j++)
			x[j] = 0;
		cnt = 0;
		while (temp1 > 0){
			x[++cnt] = temp1 & 1;
			temp1 >>= 1;
		}
		solve1(x);
	}
}

int main(){
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	minc = 10000;
	if (max(n, m) <= k)
		brute();
	else
		solve2();
	if (minc == 10000)
		cout << -1 << endl;
	else
		cout << minc << endl;
	return 0;
}


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

int a[105][105];
int n,m,k,minc;

void solve1(int x[15]){
	int cnt,tot;
	tot = 0;
	for (int i = 2; i <= n; i++){
		cnt = 0;
		for (int j = 1; j <= m; j++){
			if (a[i][j] != x[j])
				cnt++;
		}
		tot += min(cnt, m - cnt);
	}
	if (tot <= k){
		if (tot < minc)
			minc = tot;
	}
}

void solve2(){
	int cnt,tot;
	for (int p = 1; p <= n; p++){
		tot = 0;
		for (int i = 1; i <= n; i++){
			cnt = 0;
			for (int j = 1; j <= m; j++){
				if (a[i][j] != a[p][j])
					cnt++;
			}
			tot += min(cnt, m - cnt);
		}
		if (tot <= k){
			if (tot < minc)
				minc = tot;
		}
	}
	for (int p = 1; p <= m; p++){
		tot = 0;
		for (int j = 1; j <= m; j++){
			cnt = 0;
			for (int i = 1; i <= n; i++){
				if (a[i][j] != a[i][p])
					cnt++;
			}
			tot += min(cnt, n - cnt);
		}
		if (tot <= k){
			if (tot < minc)
				minc = tot;
		}
	}
}

void brute(){
	int temp,cnt;
	int x[15];
	temp = 1;
	for (int i = 1; i <= m; i++)
		temp *= 2;
	for (int i = 0; i < temp; i++){
		for (int j = 1; j <= m; j++)
			x[j] = 0;
		cnt = 0;
		while (temp > 0){
			x[++cnt] = temp & 1;
			temp >>= 1;
		}
		solve1(x);
	}
}

int main(){
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	minc = 10000;
	if (max(n, m) <= k)
		brute();
	else
		solve2();
	if (minc == 10000)
		cout << -1 << endl;
	else
		cout << minc << endl;
	return 0;
}


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

int a[105][105];
int n,m,k,minc;

void solve1(int x[15]){
	int cnt,tot;
	tot = 0;
	for (int i = 1; i <= m; i++){
		if (a[1][i] != x[i])
			tot++;
	}
	for (int i = 2; i <= n; i++){
		cnt = 0;
		for (int j = 1; j <= m; j++){
			if (a[i][j] != x[j])
				cnt++;
		}
		tot += min(cnt, m - cnt);
	}
	if (tot <= k){
		if (tot < minc)
			minc = tot;
	}
}

void solve2(){
	int cnt,tot;
	for (int p = 1; p <= n; p++){
		tot = 0;
		for (int i = 1; i <= n; i++){
			cnt = 0;
			for (int j = 1; j <= m; j++){
				if (a[i][j] != a[p][j])
					cnt++;
			}
			tot += min(cnt, m - cnt);
		}
		if (tot <= k){
			if (tot < minc)
				minc = tot;
		}
	}
	for (int p = 1; p <= m; p++){
		tot = 0;
		for (int j = 1; j <= m; j++){
			cnt = 0;
			for (int i = 1; i <= n; i++){
				if (a[i][j] != a[i][p])
					cnt++;
			}
			tot += min(cnt, n - cnt);
		}
		if (tot <= k){
			if (tot < minc)
				minc = tot;
		}
	}
}

void brute(){
	int temp,cnt,temp1;
	int x[15];
	temp = 1;
	for (int i = 1; i <= m; i++)
		temp *= 2;
	for (int i = 0; i < temp; i++){
		temp1 = i;
		for (int j = 1; j <= m; j++)
			x[j] = 0;
		cnt = 0;
		while (temp1 > 0){
			x[++cnt] = temp1 & 1;
			temp1 >>= 1;
		}
		solve1(x);
	}
}

int main(){
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin >> a[i][j];
		}
	}
	minc = 10000;
	if (max(n, m) <= k)
		brute();
	else
		solve2();
	if (minc == 10000)
		cout << -1 << endl;
	else
		cout << minc << endl;
	return 0;
}


#include <bits/stdc++.h>
#define maxn 105
int a[maxn][maxn], f[maxn];
using namespace std;
int main() {
    int n, m, k, ans = 0x7fffffff;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            cin >> a[i][j];
    if(n > 10) {
        for(int i = 1; i <= n; i++) {
            int tans = 0;
            for(int j = 1; j <= n; j++) {
                int p = 0;
                for(int r = 1; r <= m; r++) p += (a[j][r] == a[i][r]);
                tans += min(p, m - p);
            }
            ans = min(ans, tans);
        }
    } else {
        for(int i = 0; i < (1 << n); i++) {
            for(int j = 1; j <= n; j++) f[j] = ((i >> (j - 1)) & 1);
            int tans = 0;
            for(int j = 1; j <= m; j++) {
                int p = 0;
                for(int r = 1; r <= n; r++) p += (a[r][j] == f[r]);
                tans += min(p, n - p);
            }
            ans = min(ans, tans);
        }
    }
    if(ans <= k) printf("%d\n", ans); else printf("-1\n");
    return 0;
}


/*
By day I sleep, at night I weep!

Ooh Death, come near me!
Be the one for me, be the one who stays.
My rivers are frozen, and mischosen,
and the shadows around me sickens my heart.

Ooh Death, come near me,
and stay (by my side). Hear my silent cry!
In sadness I'm veiled, to the cross I am nailed,
and the pain around me freezes my world.
My cold world...

In life I've failed,
for years I've wailed.
Frozen in time... left behind...
The rapture of grief is all to find...
The rapture of grief is all!

Behind the shadow of life the lost hopes are grieving.
I seek the night and hope to find love...
So I drown in the silence of lifes short eternity.
The tears fills the void in my heart astray...

Embrace me now, delightful ease!
Give me a world of wonderous peace!
Calm the desperate scream in my heart!

Ooh Death, come near me,
save me from this empty, cold world!
Ooh Life, you have killed me,
so spare me from this couldron of misery!

In life I cry, away I fly...
Chosen to fall within these walls.
The rapture of grief is all to find
The rapture of grief is all...

Ooh, shed a tear for the loss of innocense,
for the forsaken spirits who aches... in us.
Cry for the heart who surrenders to pain,
for the solitude of those left behind!

Behold the pain and sorrow of the world,
dream of a place away from this nightmare.
Give us love and unity, under the heart of night.
Oh Death, come near us, and give us life!
*/

//#pragma comment(linker, "/STACK:16777216")
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash

#define  INF 100000000
#define eps 1e-11
//#define M_PI 3.141592653589793
//#define mx 1000000000000ll
#define bs 1000000007
#define bsize 256

using namespace std;

long n,k,ans,ar[200][200],s,m;
long v1,v2,t1,t2;

int main(){
//freopen("partition.in","r",stdin);
//freopen("partition.out","w",stdout);
//freopen("C:/input.txt","r",stdin);
//freopen("C:/output.txt","w",stdout);
ios_base::sync_with_stdio(0);
//cin.tie(0);

cin>>n>>m>>k;
for (int i=1;i<=n;i++)
 for (int j=1;j<=m;j++)
  cin>>ar[i][j];

ans=k+1;

if (m<=10)
{
 for (int mask=0;mask<(1<<m);mask++)
 {
  s=0;
  for (int j=0;j<m;j++)
   {if (ar[1][j+1]>0&&((mask&(1<<j))==0))++s;
   if (ar[1][j+1]==0&&((mask&(1<<j))>0))++s;}
  for (int i=2;i<=n;i++){t1=t2=0;
   for (int j=1;j<=m;j++)
   {
    v1=(mask&(1<<(j-1)));
    v2=ar[i][j];
    if (v1>1)v1=1;
    if (v1!=v2)++t1;else ++t2;
   }s+=min(t1,t2);}
   ans=min(ans,s);
 }
}
else
{
 for (int i=1;i<=n;i++)
 {
   s=0;
   for (int j=1;j<=n;j++)
    {t1=t2=0;
    for (int q=1;q<=m;q++)
    {
     if (ar[j][q]!=ar[i][q])++t1;else ++t2;
    }
    s+=min(t1,t2);
    }
   ans=min(ans,s);
 }
}
//cout<<ans<<endl;
if (ans>k)ans=-1;
cout<<ans<<endl;

cin.get();cin.get();
return 0;}


#include <bits/stdc++.h>

#define MAXN 100
#define INF (int)1e9

using namespace std;

int n, m, k, res = INF;
int a[MAXN][MAXN];
char b[MAXN][MAXN];
char x[MAXN], y[MAXN];
int bin1[MAXN], bin2[MAXN];
char temp;
bool exit1;

int cmp1( int* g, int* h )
{
    int ret = 0;
    for( int i = 0; i < m; i++ )
    {
        ret += ( g[i] != h[i] );
    }

    return ret;
}

int main()
{
    scanf( "%d%d%d", &n, &m, &k );

    for( int i = 0; i < n; i++ )
    {
        for( int j = 0; j < m; j++ )
        {
            scanf( "%d", &a[i][j] );
        }
    }

//    for( int i = 0; i < n; i++ )
//    {
////        scanf( "%c", &temp );
//        for( int j = 0; j < m; j++ )
//        {
//            printf( "%c", a[i][j]);
//        }
//        printf( "\n" );
//    }

    if( n <= k )
    {
        // brute the mofo
        for( int h = 0; h < ( 1 << n ); h++ )
        {
            // extract binary digits into a char array
            for( int j = 0; j < n; j++ )
            {
                y[h] = ( 1 >> j ) & 1;
            }

            // for each brute, try applying it (or its complement)
            for( int i = 0; i < n; i++ )
            {
                // fixiraj 1 red
                memcpy( bin1, a[i], sizeof( int ) * m );
                memcpy( bin2, a[i], sizeof( int ) * m );
                for( int j = 0; j < m; j++ )
                {
                    bin2[j] ^= 1;
                }
                int currRes = 0;

                for( int j = 0; j < n; j++ )
                {
                    // izmenjaj sve ostale tako da sto manje izmena ima
                    currRes += min( cmp1( a[j], bin1 ), cmp1( a[j], bin2 ) );

                    // -1 res
                    if( currRes > k )
                        break;
                }

                if( currRes < res )
                    res = currRes;
            }
        }
    }
    else // n > k
    {
        for( int i = 0; i < n; i++ )
        {
            // fixiraj 1 red
            memcpy( bin1, a[i], sizeof( int ) * m );
            memcpy( bin2, a[i], sizeof( int ) * m );
            for( int j = 0; j < m; j++ )
            {
                bin2[j] ^= 1;
//                printf( "%d", bin2[j] );
            }
//            printf( "\n" );
            int currRes = 0;

            exit1 = 0;
            for( int j = 0; j < n; j++ )
            {
                // izmenjaj sve ostale tako da sto manje izmena ima
                currRes += min( cmp1( a[j], bin1 ), cmp1( a[j], bin2 ) );

                // -1 res
                if( currRes > k )
                {
                    exit1 = 1;
                    break;
                }
            }
//            printf( "cR %d\n", currRes );

            if( currRes < res )
                res = currRes;
        }
    }

    if( res <= k )
    {
        printf( "%d\n", res );
    }
    else
    {
        printf( "-1\n" );
    }

    return 0;
}


#include <bits/stdc++.h>

#define MAXN 100
#define INF (int)1e9

using namespace std;

int n, m, k, res = INF;
int a[MAXN][MAXN];
char b[MAXN][MAXN];
char x[MAXN], y[MAXN];
int bin1[MAXN], bin2[MAXN];
char temp;
bool exit1;

int cmp1( int* g, int* h )
{
    int ret = 0;
    for( int i = 0; i < m; i++ )
    {
        ret += ( g[i] != h[i] );
    }

    return ret;
}

int cmp2( int c, int* h )
{
    int ret = 0;
    for( int i = 0; i < n; i++ )
    {
        ret += a[i][c] != h[i];
    }

    return ret;
}

int main()
{
    scanf( "%d%d%d", &n, &m, &k );

    for( int i = 0; i < n; i++ )
    {
        for( int j = 0; j < m; j++ )
        {
            scanf( "%d", &a[i][j] );
        }
    }

//    for( int i = 0; i < n; i++ )
//    {
////        scanf( "%c", &temp );
//        for( int j = 0; j < m; j++ )
//        {
//            printf( "%c", a[i][j]);
//        }
//        printf( "\n" );
//    }

    if( n <= k )
    {
        // brute the mofo
        for( int h = 0; h < ( 1 << n ); h++ )
        {
            // extract binary digits into a char array
            for( int j = 0; j < n; j++ )
            {
                y[j] = ( h >> j ) & 1;
            }

            // for each brute, try applying it (or its complement)
            for( int i = 0; i < m; i++ )
            {
                // fixiraj 1 kolonu
                for( int j = 0; j < n; j++ )
                {
                    bin1[j] = y[j];
                    bin2[j] = y[j] ^ 1;
//                    printf( "%d ", bin1[j] );
                }
//                printf( "\n" );
                int currRes = 0;

                for( int j = 0; j < m; j++ )
                {
                    // izmenjaj sve ostale tako da sto manje izmena ima
                    currRes += min( cmp2( j, bin1 ), cmp2( j, bin2 ) );

                    // -1 res
                    if( currRes > k )
                        break;
                }
    //            printf( "cR %d\n", currRes );

                if( currRes < res )
                    res = currRes;
            }
        }
    }
    else // n > k
    {
        for( int i = 0; i < n; i++ )
        {
            // fixiraj 1 red
            memcpy( bin1, a[i], sizeof( int ) * m );
            memcpy( bin2, a[i], sizeof( int ) * m );
            for( int j = 0; j < m; j++ )
            {
                bin2[j] ^= 1;
//                printf( "%d", bin2[j] );
            }
//            printf( "\n" );
            int currRes = 0;

            for( int j = 0; j < n; j++ )
            {
                // izmenjaj sve ostale tako da sto manje izmena ima
                currRes += min( cmp1( a[j], bin1 ), cmp1( a[j], bin2 ) );

                // -1 res
                if( currRes > k )
                    exit1 = 1;
            }
//            printf( "cR %d\n", currRes );

            if( currRes < res )
                res = currRes;
        }
    }

    if( res <= k )
    {
        printf( "%d\n", res );
    }
    else
    {
        printf( "-1\n" );
    }

    return 0;
}

/*
3 10 7
0 1 0 0 1 0 1 0 0 0
0 0 1 1 0 0 0 1 0 1
1 0 1 1 1 0 1 1 0 0
*/


#include "iostream"
#include "cstdio"
#include "cstring"
#include "math.h"
#include "algorithm"
using namespace std;
#define FOR(START,END,COUR) for(COUR = START;COUR<=END;++COUR)
typedef long long ll;

int n,m,k,key,MK,MKEY;
int MAP[110][110];
int ii,jj;

void dfssolve(int pos,int step){
    int temp[110];
    int cnt,i,j;
    if(pos>n){
        key =1;
        k=k<step?k:step;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        if(MAP[pos][i]!=MAP[pos-1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos-1][i];
        }
    }
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos-1][i]){
            cnt++;
            MAP[pos][i]=MAP[pos-1][i]&1;
        }
    }
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfssolveup(int pos,int step){
    int cnt,i,j;
    int temp[110];
    if(pos<1){
        MKEY=1;
        MK=step<MK?step:MK;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        if(MAP[pos][i]!=MAP[pos+1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos+1][i];
        }
    }
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);

    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos+1][i]){
            cnt++;
            MAP[pos][i]=MAP[pos+1][i]&1;
        }
    }
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfs(int pos,int step){
    if(k<step)return ;
    if(pos==m){
        dfssolve(2,step);
        MAP[1][pos]^=1;
        dfssolve(2,step+1);
        MAP[1][pos]^=1;
    }else {
        dfs(pos+1,step);
        MAP[1][pos]^=1;
        dfs(pos+1,step+1);
        MAP[1][pos]^=1;
    }
}

int main()
{
    cin>>n>>m>>k;
    key =0;
    if(n<m){
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[jj][ii];
        swap(n,m);
    }else {
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[ii][jj];
    }
    if(n<=k){
        dfs(1,0);
    }else {
        FOR(1,n,ii){
            MK=10;MKEY=0;
            dfssolveup(ii-1,0);
            //cout<<'*'<<MK<<endl;
            if(MKEY){
                dfssolve(ii+1,MK);
            }
            //cout<<k<<' '<<ii<<endl;
        }
    }
    if(key)
    cout<<k<<endl;
    else cout<<-1<<endl;
    return 0;
}


#include "iostream"
#include "cstdio"
#include "cstring"
#include "math.h"
#include "algorithm"
using namespace std;
#define FOR(START,END,COUR) for(COUR = START;COUR<=END;++COUR)
typedef long long ll;

int n,m,k,key,MK,MKEY;
int MAP[110][110];
int ii,jj;

void dfssolve(int pos,int step){
    int temp[110];
    int cnt,i,j;
    if(step>k)return;
    if(pos>n){
        key =1;
        k=k<step?k:step;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        if(MAP[pos][i]!=MAP[pos-1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos-1][i];
        }
    }
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos-1][i]){
            cnt++;
            MAP[pos][i]=MAP[pos-1][i]^1;
        }
    }
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfssolveup(int pos,int step){
    int cnt,i,j;
    int temp[110];
    if(pos<1){
        MKEY=1;
        MK=step<MK?step:MK;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        //cout<<pos<<'*'<<i<<'&'<<MAP[pos][i]<<endl;
        if(MAP[pos][i]!=MAP[pos+1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos+1][i];
        }
    }
    //cout<<cnt<<endl;
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);

    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos+1][i]){
            cnt++;
            MAP[pos][i]=MAP[pos+1][i]^1;
        }
    }
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfs(int pos,int step){
    if(k<step)return ;
    if(pos==m){
        dfssolve(2,step);
        MAP[1][pos]^=1;
        dfssolve(2,step+1);
        MAP[1][pos]^=1;
    }else {
        dfs(pos+1,step);
        MAP[1][pos]^=1;
        dfs(pos+1,step+1);
        MAP[1][pos]^=1;
    }
}

int main()
{
    cin>>n>>m>>k;
    key =0;
    if(n<m){
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[jj][ii];
        swap(n,m);
    }else {
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[ii][jj];
    }
    if(n<=k){
        dfs(1,0);
    }else {
        FOR(1,n,ii){
            MK=k;MKEY=0;
            dfssolveup(ii-1,0);
            //cout<<'*'<<MK<<endl;
            if(MKEY){
                dfssolve(ii+1,MK);
            }
        }
    }
    if(key)
    cout<<k<<endl;
    else cout<<-1<<endl;
    return 0;
}


#include "iostream"
#include "cstdio"
#include "cstring"
#include "math.h"
#include "algorithm"
using namespace std;
#define FOR(START,END,COUR) for(COUR = START;COUR<=END;++COUR)
typedef long long ll;

int n,m,k,key,MK,MKEY;
int MAP[110][110];
int ii,jj;

void dfssolve(int pos,int step){
    int temp[110];
    int cnt,i,j;
    if(pos>n){
        key =1;
        k=k<step?k:step;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        if(MAP[pos][i]!=MAP[pos-1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos-1][i];
        }
    }
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos-1][i]){
            cnt++;
            MAP[pos][i]=MAP[pos-1][i]&1;
        }
    }
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfssolveup(int pos,int step){
    int cnt,i,j;
    int temp[110];
    if(pos<1){
        MKEY=1;
        MK=step<MK?step:MK;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        if(MAP[pos][i]!=MAP[pos+1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos+1][i];
        }
    }
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);

    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos+1][i]){
            cnt++;
            MAP[pos][i]=MAP[pos+1][i]&1;
        }
    }
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfs(int pos,int step){
    if(k<step)return ;
    if(pos==m){
        dfssolve(2,step);
        MAP[1][pos]&=1;
        dfssolve(2,step+1);
        MAP[1][pos]&=1;
    }else {
        dfs(pos+1,step);
        MAP[1][pos]&=1;
        dfs(pos+1,step+1);
        MAP[1][pos]&=1;
    }
}

int main()
{
    cin>>n>>m>>k;
    key =0;
    if(n<m){
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[jj][ii];
        swap(n,m);
    }else {
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[ii][jj];
    }
    if(n<=k){
        dfs(1,0);
    }else {
        FOR(1,n,ii){
            MK=10;MKEY=0;
            dfssolveup(ii-1,0);
            //cout<<'*'<<MK<<endl;
            if(MKEY){
                dfssolve(ii+1,MK);
            }
            //cout<<k<<' '<<ii<<endl;
        }
    }
    if(key)
    cout<<k<<endl;
    else cout<<-1<<endl;
    return 0;
}


#include "iostream"
#include "cstdio"
#include "cstring"
#include "math.h"
#include "algorithm"
using namespace std;
#define FOR(START,END,COUR) for(COUR = START;COUR<=END;++COUR)
typedef long long ll;

int n,m,k,key,MK,MKEY;
int MAP[110][110];
int ii,jj;

void dfssolve(int pos,int step){
    int temp[110];
    int cnt,i,j;
    if(pos>n){
        key =1;
        k=k<step?k:step;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        if(MAP[pos][i]!=MAP[pos-1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos-1][i];
        }
    }
    //if(pos==2)cout<<cnt<<MAP[pos][1]<<MAP[pos][2]<<MAP[pos][3]<<endl;
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos-1][i]){
            cnt++;
        }MAP[pos][i]=(MAP[pos-1][i]^1);
    }
    //if(pos==2)cout<<cnt<<MAP[pos][1]<<MAP[pos][2]<<MAP[pos][3]<<endl;
    if(step+cnt<=k)
    dfssolve(pos+1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfssolveup(int pos,int step){
    int cnt,i,j;
    int temp[110];
    if(pos<1){
        MKEY=1;
        MK=step<MK?step:MK;
        return ;
    }
    cnt=0;
    FOR(1,m,i){
        temp[i]=MAP[pos][i];
        if(MAP[pos][i]!=MAP[pos+1][i]){
                cnt++;
                MAP[pos][i]=MAP[pos+1][i];
        }
    }
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);

    cnt=0;
    FOR(1,m,i){
        if(temp[i]==MAP[pos+1][i]){
            cnt++;
        }MAP[pos][i]=(MAP[pos+1][i]^1);
    }
    if(step+cnt<=k)
    dfssolveup(pos-1,step+cnt);
    FOR(1,m,i)MAP[pos][i]=temp[i];
}

void dfs(int pos,int step){
    if(k<step)return ;
    if(pos==m){
        dfssolve(2,step);
        MAP[1][pos]^=1;
        dfssolve(2,step+1);
        MAP[1][pos]^=1;
    }else {
        dfs(pos+1,step);
        MAP[1][pos]^=1;
        dfs(pos+1,step+1);
        MAP[1][pos]^=1;
    }
}

int main()
{
    cin>>n>>m>>k;
    key =0;
    if(n<m){
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[jj][ii];
        swap(n,m);
    }else {
        FOR(1,n,ii)
        FOR(1,m,jj)cin>>MAP[ii][jj];
    }
    if(n<=k){
        dfs(1,0);
    }else {
        FOR(1,n,ii){
            MK=10;MKEY=0;
            dfssolveup(ii-1,0);
            //cout<<'*'<<MK<<endl;
            if(MKEY){
                dfssolve(ii+1,MK);
            }
            //cout<<k<<' '<<ii<<endl;
        }
    }
    if(key)
    cout<<k<<endl;
    else cout<<-1<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fr(a,b,c) for(int a = b; a < c; a++)
#define rp(a,b) fr(a,0,b)
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scs(a) scanf("%s", a)
#define cl(a,b) memset(a,b,sizeof(a))

#define st first
#define nd second
#define mp make_pair

typedef long long ll;

#define maxn 110

int n, m, k;
int a[maxn][maxn];
bitset<maxn> b[maxn];
bitset<maxn> td;

int pd[maxn][maxn][2][12];
int mark[maxn][maxn][2][12], passo;

void print(bitset<maxn> &msk, int j) {
    printf("> ");
    rp(i,j) printf("%d", (int)msk[i]);
    puts("");
}

int go(int i, int j, bool c, int q) {
    int &r = pd[i][j][c][q];
    if (mark[i][j][c][q] == passo) return r;
    r = -1;
    mark[i][j][c][q] = passo;
    if (i >= n) return r = q;

    bitset<maxn> x = b[0]&td;

    if (c) x.flip();

    int err = (x^(b[i]&td)).count();
    if (err <= q) {
        r = max(r, go(i+1, j, c, q-err));
    }

    x = (x.flip()&td);
    err = (x^(b[i]&td)).count();
    if (err <= q) {
        r = max(r, go(i+1, j, c, q-err));
    }
    return r;
}

int res;
void bt(int j, int q) {
    if (j > 0) {
        //printf("(%d %d) ", j, q);
        //print(b[0], j);
        passo++;
        int tmp = go(1,j,0,q);
        if (tmp == -1) return;
        if (j >= m) {
            res = min(res, k - tmp);
            return;
        }
    }
    td.set(j);

    bt(j+1,q);
    b[0].flip(j);
    bt(j+1,q-1);
    b[0].flip(j);

    td.reset(j);
}

int main() {
    cl(mark,0); passo = 0;
    sc3(n,m,k);
    rp(i,n) {
        b[i].reset();
        rp(j,m) sc(a[i][j]), b[i][j] = a[i][j];
    }
    td.reset();
    res = 100;
    bt(0,k);
    if (res > k) puts("-1");
    else printf("%d\n", res);
}


#include<iostream>
using namespace std;

int mat[105][105];
int n,m,k;

int n_t(){
    int ans=20000;
    for(int i=0;i<n;++i){
        int tmp=0;
        for(int t=0;t<n;++t){
            int rec1=0;
            int rec2=0;
            for(int k=0;k<m;++k){
                if(mat[i][k]!=mat[t][k])rec1++;
                if(mat[i][k]==mat[t][k])rec2++;
            }
            tmp+=min(rec1,rec2);
        }
        ans=min(ans,tmp);
    }
    return ans;
}
/*
int t_n(){
    int pos=(1<<m);
    int ans=20000;
    for(int i=0;i<pos;++i){
        int tmp=0;
        for(int t=0;t<n;++t){
            int rec1=0;
            int rec2=0;
            for(int j=0;j<m;++j){
                int rec=pos&(1<<j);
                if(rec!=(mat[t][j]<<j))rec1++;
                else rec2++;
            }
            tmp+=min(rec1,rec2);
        }
        ans=min(ans,tmp);
    }
    return ans;
}
*/
int t_n(){
    int pos=(1<<n);
//  cout<<"pos="<<pos<<' '<<n<<endl;
    int ans=20000;
    for(int i=0;i<pos;++i){
        int tmp=0;
//      cout<<"########"<<endl;
        for(int t=0;t<m;++t){
    //      for(int kk=0;kk<n;++kk)cout<<mat[kk][t]<<' ';
    //      cout<<endl;
            int rec1=0;
            int rec2=0;
            for(int j=0;j<n;++j){
                int rec=i&(1<<j);
    //          cout<<"rec="<<rec<<endl;
                if(rec==(mat[j][t]<<j))rec1++;
                else rec2++;
            }
            if(rec1+rec2!=n){cout<<"false"<<endl;return 0;}
            tmp+=min(rec1,rec2);
    //      cout<<tmp<<endl;
        }
    //  cout<<"~~~~~~"<<endl;
    //  if(tmp==8)cout<<i<<' '<<tmp<<endl;
        ans=min(ans,tmp);
    }
    return ans;
}

int main(){
//  freopen("data.txt","r",stdin);
    cin>>n>>m>>k;
    for(int i=0;i<n;++i){
        for(int t=0;t<m;++t){
            cin>>mat[i][t];
        }
    }
//  cout<<n<<' '<<m<<' '<<k<<endl;
    int ans=20000;
    if(n>k){
        ans=n_t();
    }
    if(k>=n){
        ans=t_n();
    }
//  cout<<ans<<endl;
    if(ans>k)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


#include<iostream>
using namespace std;

int mat[105][105];
int n,m,k;

int n_t(){
    int ans=20000;
    for(int i=0;i<n;++i){
        int tmp=0;
        for(int t=0;t<n;++t){
            int rec1=0;
            int rec2=0;
            for(int k=0;k<m;++k){
                if(mat[i][k]!=mat[t][k])rec1++;
                if(mat[i][k]==mat[t][k])rec2++;
            }
            tmp+=min(rec1,rec2);
        }
        ans=min(ans,tmp);
    }
    return ans;
}

int t_n(){
    int pos=(1<<m);
    int ans=20000;
    for(int i=0;i<pos;++i){
        int tmp=0;
        for(int t=0;t<n;++t){
            int rec1=0;
            int rec2=0;
            for(int j=0;j<m;++j){
                int rec=pos&(1<<j);
                if(rec!=(mat[t][j]<<j))rec1++;
                else rec2++;
            }
            tmp+=min(rec1,rec2);
        }
        ans=min(ans,tmp);
    }
    return ans;
}

int main(){
//  freopen("data.txt","r",stdin);
    cin>>n>>m>>k;
    for(int i=0;i<n;++i){
        for(int t=0;t<m;++t){
            cin>>mat[i][t];
        }
    }
    int ans=20000;
    if(n>k){
        ans=n_t();
    }
    if(k>=n){
        ans=n_t();
    }
    if(ans>k)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <cstring>
#define tr 1000000007
#define mp make_pair
#define pb push_back
#define tA 555
#define tB 666
#define AorB 777
typedef long long ll;
using namespace std;
ll a[300][300],b[300],c[300],z,cnt,tmp,l,r,n,m,x,y,k,j,p,k1,k2,i,cur,rez;
vector <ll> f;

ll Abs(ll x)
{
 if (x < 0) return -x;
 return x;
}

int main()
{
    cin >> n >> m >> k;
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            cin >> a[i][j];
    if (n <= k)
    {
          ll rez = n*m;
          for (i = 0; i < (1<<n); i++)
          {
              ll sum = 0;
              for (j = 0; j < n; j++)
                  if (i&(1<<j)) b[j] = 1;
                     else b[j] = 0;
              for (j = 0; j < m; j++)
              {
                  ll tmp = 0;
                  for (y = 0; y < n; y++)
                      tmp += (b[y]^a[y][j]);
                  tmp = min(tmp,n-tmp);
                  sum += tmp;
              }
              rez = min(rez,sum);
          }
          if (rez <= k) cout << rez << endl;
             else cout << -1 << endl;
    } else
    {
          rez = m*n;
          for (i = 0; i < m; i++)
          {
              ll sum = 0;
              for (j = 0; j < n; j++)
                  b[j] = a[j][i];
              for (j = 0; j < m; j++)
              {
                  ll tmp = 0;
                  for (y = 0; y < n; y++)
                      tmp += (b[y]^a[y][j]);
                  tmp = min(tmp,n-tmp);
                  //cout << i << " " << j << " " << tmp << endl;
                  sum += tmp;
              }
              rez = min(rez,sum);
          }
          //cout << rez << endl;
          if (rez <= k) cout << rez << endl;
             else cout << -1 << endl;
    }
   return 0;
}


#pragma GCC diagnostic ignored "-Wwrite-strings"
//#pragma GCC diagnostic ignored "-Wc++11-extensions"

#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <climits>
#include "stdarg.h"
#include <bitset> //http://stackoverflow.com/questions/4048749/bitwise-operations-on-vectorbool //http://www.drdobbs.com/the-standard-librarian-bitsets-and-bit-v/184401382
#include <numeric> //http://stackoverflow.com/questions/6743003/how-calculate-sum-of-values-in-stdvectorint
#include <iomanip> // cout << fixed << setprecision(8);

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<PII> VPII;
typedef vector<PDD> VPDD;
typedef vector <VI> VVI;
typedef vector<VD> VVD;
typedef vector <string> VS;
typedef vector <bool> VB;

#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i,n) for(int i=0; i<(n); ++i)
#define ALL(X) (X).begin(),(X).end()
#define SZ(X) (int)(X).size()
#define FORE(it,X) for(__typeof((X).begin()) it=(X).begin(); it!=(X).end();++it)

#define CE cout << endl;
#define CL cout << "--------------------------------------" << endl;
#define ASF assert(false);
#define V vector
#define DQ deque
#define PQ priority_queue

template <class T, class U>
ostream & operator << (ostream &out, const pair<T,U> &A) {
  out << A.ST << "_" << A.ND; return out;
}

template<template<typename, typename> class ContainerT, typename ValueT> //http://cboard.cprogramming.com/cplusplus-programming/145441-stl-container-template-argument.html
ostream & operator << (ostream &out, const ContainerT<ValueT, std::allocator<ValueT> > &A) {
  FORE(i, A) out << *i << " "; return out;
}

template<template<typename, typename> class ContainerT, typename ValueT, typename ValueU>
ostream & operator << (ostream &out, const ContainerT<pair<ValueT, ValueU>, std::allocator<pair<ValueT, ValueU> > > &A) {
  FORE(i, A) out << *i << " "; return out;
}

#define VA_NARGS_IMPL(_1,_2,_3,_4,_5,_6,_7,_8,N,...) N
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1)

#define P_(a)                       #a << ": " << a
#define P__(a)                      " | " << P_(a)
#define P1(a)                       cout << P_(a) << endl;
#define P2(a, b)                    cout << P_(a) << P__(b) << endl;
#define P3(a, b, c)                 cout << P_(a) << P__(b) << P__(c) << endl;
#define P4(a, b, c, d)              cout << P_(a) << P__(b) << P__(c) << P__(d) << endl;
#define P5(a, b, c, d, e)           cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << endl;
#define P6(a, b, c, d, e, f)        cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << endl;
#define P7(a, b, c, d, e, f, g)     cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << P__(g) << endl;
#define P8(a, b, c, d, e, f, g, h)  cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << P__(g) << P__(h) << endl;

#define P_IMPL2(count, ...) P ## count (__VA_ARGS__)
#define P_IMPL(count, ...) P_IMPL2(count, __VA_ARGS__)
#define P(...) P_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__)

template<class T> void mini(T &a, const T &b) {if(b<a)a=b;}
template<class T> void maxi(T &a, const T &b) {if(b>a)a=b;}

int N, M, K, ans;
V<VI> A;

int dist(const VI &standard, const VI &target) {
  assert(standard.size() == target.size() and standard.size() == M);
  int ret = 0;
  REP(i, M) ret += standard[i] != target[i];
  return min(ret, M-ret);
}

bool noHope(const VI &standard) {
  int curAns = 0;
  REP(i, N) {
    int diff = 0;
    REP(j, standard.size()) diff += A[i][j] != standard[j];
    curAns += min(diff, (int)standard.size()-diff);
    if(curAns > K or curAns >= ans) return true;
  }
  return false;
}

void dfs(VI &standard) {
  /*if(standard.size()%3 == 0 and noHope(standard)) return;*/
  if(standard.size() == M) {
    int curAns = 0;
    REP(j, N) curAns += dist(standard, A[j]);
    mini(ans, curAns);
  }
  else {
    standard.push_back(0); dfs(standard); standard.pop_back();
    standard.push_back(1); dfs(standard); standard.pop_back();
  }
}

LL solve() {
  cin >> N >> M >> K;
  A = V<VI>(N, VI(M));
  ans = INT_MAX;
  REP(i, N) REP(j, M) cin >> A[i][j];
  if(N < M) {
    V<VI> A_(M, VI(N));
    REP(i, N) REP(j, M) A_[j][i] = A[i][j];
    A = A_;
    int tmp = N; N = M; M = tmp;
  }
  if(M < 10) {
    VI start;
    dfs(start);
  }
  else {
    REP(i, N) {
      VI standard = A[i];
      int curAns = 0;
      REP(j, N) curAns += dist(standard, A[j]);
      mini(ans, curAns);
    }
  }
  if(ans == INT_MAX or ans > K) return -1;
  return ans;
}

int main() {
  /*int T; cin >> T; REP(i, T)*/
  cout << solve() << endl;
  return 0;
}


#pragma GCC diagnostic ignored "-Wwrite-strings"
//#pragma GCC diagnostic ignored "-Wc++11-extensions"

#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <climits>
#include "stdarg.h"
#include <bitset> //http://stackoverflow.com/questions/4048749/bitwise-operations-on-vectorbool //http://www.drdobbs.com/the-standard-librarian-bitsets-and-bit-v/184401382
#include <numeric> //http://stackoverflow.com/questions/6743003/how-calculate-sum-of-values-in-stdvectorint
#include <iomanip> // cout << fixed << setprecision(8);

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<PII> VPII;
typedef vector<PDD> VPDD;
typedef vector <VI> VVI;
typedef vector<VD> VVD;
typedef vector <string> VS;
typedef vector <bool> VB;

#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i,n) for(int i=0; i<(n); ++i)
#define ALL(X) (X).begin(),(X).end()
#define SZ(X) (int)(X).size()
#define FORE(it,X) for(__typeof((X).begin()) it=(X).begin(); it!=(X).end();++it)

#define CE cout << endl;
#define CL cout << "--------------------------------------" << endl;
#define ASF assert(false);
#define V vector
#define DQ deque
#define PQ priority_queue

template <class T, class U>
ostream & operator << (ostream &out, const pair<T,U> &A) {
  out << A.ST << "_" << A.ND; return out;
}

template<template<typename, typename> class ContainerT, typename ValueT> //http://cboard.cprogramming.com/cplusplus-programming/145441-stl-container-template-argument.html
ostream & operator << (ostream &out, const ContainerT<ValueT, std::allocator<ValueT> > &A) {
  FORE(i, A) out << *i << " "; return out;
}

template<template<typename, typename> class ContainerT, typename ValueT, typename ValueU>
ostream & operator << (ostream &out, const ContainerT<pair<ValueT, ValueU>, std::allocator<pair<ValueT, ValueU> > > &A) {
  FORE(i, A) out << *i << " "; return out;
}

#define VA_NARGS_IMPL(_1,_2,_3,_4,_5,_6,_7,_8,N,...) N
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1)

#define P_(a)                       #a << ": " << a
#define P__(a)                      " | " << P_(a)
#define P1(a)                       cout << P_(a) << endl;
#define P2(a, b)                    cout << P_(a) << P__(b) << endl;
#define P3(a, b, c)                 cout << P_(a) << P__(b) << P__(c) << endl;
#define P4(a, b, c, d)              cout << P_(a) << P__(b) << P__(c) << P__(d) << endl;
#define P5(a, b, c, d, e)           cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << endl;
#define P6(a, b, c, d, e, f)        cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << endl;
#define P7(a, b, c, d, e, f, g)     cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << P__(g) << endl;
#define P8(a, b, c, d, e, f, g, h)  cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << P__(g) << P__(h) << endl;

#define P_IMPL2(count, ...) P ## count (__VA_ARGS__)
#define P_IMPL(count, ...) P_IMPL2(count, __VA_ARGS__)
#define P(...) P_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__)

template<class T> void mini(T &a, const T &b) {if(b<a)a=b;}
template<class T> void maxi(T &a, const T &b) {if(b>a)a=b;}

int N, M, K, ans;
V<VI> A;

int dist(const VI &standard, const VI &target) {
  assert(standard.size() == target.size() and standard.size() == M);
  int ret = 0;
  REP(i, M) ret += standard[i] != target[i];
  return min(ret, M-ret);
}

bool noHope(const VI &standard) {
  int curAns = 0;
  REP(i, N) {
    int diff = 0;
    REP(j, standard.size()) diff += A[i][j] != standard[j];
    curAns += min(diff, (int)standard.size()-diff);
    if(curAns > K or curAns >= ans) return true;
  }
  return false;
}

void dfs(VI &standard) {
  /*if(standard.size()%3 == 0 and noHope(standard)) return;*/
  if(standard.size() == M) {
    int curAns = 0;
    REP(j, N) curAns += dist(standard, A[j]);
    mini(ans, curAns);
  }
  else {
    standard.push_back(0); dfs(standard); standard.pop_back();
    standard.push_back(1); dfs(standard); standard.pop_back();
  }
}

LL solve() {
  cin >> N >> M >> K;
  A = V<VI>(N, VI(M));
  ans = INT_MAX;
  REP(i, N) REP(j, M) cin >> A[i][j];
  if(N < M) {
    V<VI> A_(M, VI(N));
    REP(i, N) REP(j, M) A_[j][i] = A[i][j];
    A = A_;
    int tmp = N; N = M; M = tmp;
  }
  if(M <= 10) {
    VI start;
    dfs(start);
  }
  else {
    REP(i, N) {
      VI standard = A[i];
      int curAns = 0;
      REP(j, N) curAns += dist(standard, A[j]);
      mini(ans, curAns);
    }
  }
  if(ans == INT_MAX or ans > K) return -1;
  return ans;
}

int main() {
  /*int T; cin >> T; REP(i, T)*/
  cout << solve() << endl;
  return 0;
}


#pragma GCC diagnostic ignored "-Wwrite-strings"
//#pragma GCC diagnostic ignored "-Wc++11-extensions"

#include <vector>
#include <map>
#include <set>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <climits>
#include "stdarg.h"
#include <bitset> //http://stackoverflow.com/questions/4048749/bitwise-operations-on-vectorbool //http://www.drdobbs.com/the-standard-librarian-bitsets-and-bit-v/184401382
#include <numeric> //http://stackoverflow.com/questions/6743003/how-calculate-sum-of-values-in-stdvectorint
#include <iomanip> // cout << fixed << setprecision(8);

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef vector<double> VD;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<PII> VPII;
typedef vector<PDD> VPDD;
typedef vector <VI> VVI;
typedef vector<VD> VVD;
typedef vector <string> VS;
typedef vector <bool> VB;

#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i,n) for(int i=0; i<(n); ++i)
#define ALL(X) (X).begin(),(X).end()
#define SZ(X) (int)(X).size()
#define FORE(it,X) for(__typeof((X).begin()) it=(X).begin(); it!=(X).end();++it)

#define CE cout << endl;
#define CL cout << "--------------------------------------" << endl;
#define ASF assert(false);
#define V vector
#define DQ deque
#define PQ priority_queue

template <class T, class U>
ostream & operator << (ostream &out, const pair<T,U> &A) {
  out << A.ST << "_" << A.ND; return out;
}

template<template<typename, typename> class ContainerT, typename ValueT> //http://cboard.cprogramming.com/cplusplus-programming/145441-stl-container-template-argument.html
ostream & operator << (ostream &out, const ContainerT<ValueT, std::allocator<ValueT> > &A) {
  FORE(i, A) out << *i << " "; return out;
}

template<template<typename, typename> class ContainerT, typename ValueT, typename ValueU>
ostream & operator << (ostream &out, const ContainerT<pair<ValueT, ValueU>, std::allocator<pair<ValueT, ValueU> > > &A) {
  FORE(i, A) out << *i << " "; return out;
}

#define VA_NARGS_IMPL(_1,_2,_3,_4,_5,_6,_7,_8,N,...) N
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1)

#define P_(a)                       #a << ": " << a
#define P__(a)                      " | " << P_(a)
#define P1(a)                       cout << P_(a) << endl;
#define P2(a, b)                    cout << P_(a) << P__(b) << endl;
#define P3(a, b, c)                 cout << P_(a) << P__(b) << P__(c) << endl;
#define P4(a, b, c, d)              cout << P_(a) << P__(b) << P__(c) << P__(d) << endl;
#define P5(a, b, c, d, e)           cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << endl;
#define P6(a, b, c, d, e, f)        cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << endl;
#define P7(a, b, c, d, e, f, g)     cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << P__(g) << endl;
#define P8(a, b, c, d, e, f, g, h)  cout << P_(a) << P__(b) << P__(c) << P__(d) << P__(e) << P__(f) << P__(g) << P__(h) << endl;

#define P_IMPL2(count, ...) P ## count (__VA_ARGS__)
#define P_IMPL(count, ...) P_IMPL2(count, __VA_ARGS__)
#define P(...) P_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__)

template<class T> void mini(T &a, const T &b) {if(b<a)a=b;}
template<class T> void maxi(T &a, const T &b) {if(b>a)a=b;}

int N, M, K, ans;
V<VI> A;

int dist(const VI &standard, const VI &target) {
  assert(standard.size() == target.size() and standard.size() == M);
  int ret = 0;
  REP(i, M) ret += standard[i] != target[i];
  return min(ret, M-ret);
}

void dfs(VI &standard) {
  if(standard.size() == M) {
    int curAns = 0;
    REP(j, N) curAns += dist(standard, A[j]);
    mini(ans, curAns);
  }
  else {
    standard.push_back(0); dfs(standard); standard.pop_back();
    standard.push_back(1); dfs(standard); standard.pop_back();
  }
}

LL solve() {
  cin >> N >> M >> K;
  A = V<VI>(N, VI(M));
  ans = INT_MAX;
  REP(i, N) REP(j, M) cin >> A[i][j];
  if(N > M) {
    V<VI> A_(M, VI(N));
    REP(i, N) REP(j, M) A_[i][j] = A[j][i];
    A = A_;
    int tmp = N; N = M; M = tmp;
  }
  if(M < 10) {
    VI start;
    dfs(start);
  }
  else {
    REP(i, N) {
      VI standard = A[i];
      int curAns = 0;
      REP(j, N) curAns += dist(standard, A[j]);
      mini(ans, curAns);
    }
  }
  if(ans == INT_MAX or ans > K) return -1;
  return ans;
}

int main() {
  /*int T; cin >> T; REP(i, T)*/
  cout << solve() << endl;
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;

const int maxN = 100 + 10;
int a[maxN][maxN],n,m,k;
int b[maxN][maxN];

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m >> k;
    for (int i = 0 ; i < n ; i++)
        for (int j = 0 ; j < m ; j++)
            cin >> a[i][j];

    int res = 2e9;
    if (n <= 10 && m <= 10)
    {
        for (int row = 0 ; row < (1 << m) ; row++)
        {
            for (int col = 0 ; col < (1 << n) ; col++)
            {
                int cost = 0;
                for (int j = 0 ; j < m ; j++)
                    b[0][j] = ((row >> j) & 1);

                for (int i = 1 ; i < n ; i++)
                    b[i][0] = ((col >> i) & 1);

                for (int i = 1 ; i < n ; i++)
                    for (int j = 1 ; j < m ; j++)
                        b[i][j] = b[0][j] ^ b[i][0] ^ b[0][0];

                for (int i = 0 ; i < n ; i++)
                    for (int j = 0 ; j < m ; j++)
                        cost += (a[i][j] != b[i][j]);

                res = min(res, cost);
            }
        }
        if (res > k)
            res = -1;
        cout << res << endl;
        return 0;
    }

    if (m > 10) //ye sotooni hast ke taghir nemikone
    {
        for (int fix = 0 ; fix < m ; fix++) //sotooni ke taghir nemikone
        {
            int cost = 0;
            for (int col = 0 ; col < m ; col++)
            {
                if (col == fix)
                    continue;

                int dif = 0;
                for (int i = 0 ; i < n ; i++)
                    dif += (a[i][fix] != a[i][col]); //sotoone col tabdil be mask she

                cost += min(dif, n - dif);
            }
            res = min(res, cost);
        }
        if (res > k)
            res = -1;
        cout << res << endl;
        return 0;
    }

    if (n > 10) //ye satri hast ke taghir nemikone
    {
        for (int fix = 0 ; fix < n ; fix++) //satri ke taghir nemikone
        {
            int cost = 0;
            for (int row = 0 ; row < n ; row++)
            {
                if (row == fix)
                    continue;

                int dif = 0;
                for (int i = 0 ; i < m ; i++)
                    dif += (a[fix][i] != a[row][i] );

                cost += min(dif, m - dif);
            }
            res = min(res, cost);
        }
        if (res > k)
            res = -1;
        cout << res << endl;
        return 0;
    }

    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

int om[100][100];
int tmp;
int req;
int k;
int r;
int c;

int getans()
{
	int ans = 2147483647;
	for (int key = 0;key < r;key++)
	{
		req = 0;
		for (int i = 0;i < r;i++)
		{
			tmp = 0;
			for (int j = 0;j < c;j++)
				tmp += (om[i][j] == om[key][j]);
			req += min(tmp, c-tmp);
		}
		ans = min(ans, req);
	}
	for (int key = 0;key < c;key++)
	{
		req = 0;
		for (int i = 0;i < c;i++)
		{
			tmp = 0;
			for (int j = 0;j < r;j++)
				tmp += (om[j][i] == om[j][key]);
			req += min(tmp, r-tmp);
		}
		ans = min(ans, req);
	}
	return ans;
}

int main()
{
	int ans = 2147483647;
	scanf("%d%d%d", &r, &c, &k);
	for (int i = 0;i < r;i++) for (int j = 0;j < c;j++)
		scanf("%d", &om[i][j]);
	if (r <= 10)
	{ // have enough changes, might want to just modify every column
		int orig = 0;
		for (int i = 0;i < r;i++)
			orig += (om[i][0] << i);
		for (int key = 0;key < (1<<r);key++)
		{
			int temp = 0;
			for (int i = 0;i < r;i++)
			{
				temp += (((orig & (1 << i)) ^ (key & (1 << i))) >> i);
				om[i][0] = (key & (1 << i)) >> i;
			}
			temp += getans();
			if (temp < ans)
				ans = temp;
		}
		if (ans <= k)
			printf("%d\n", ans);
		else
			printf("-1\n");
		return 0;
	}
	ans = getans();
	if (ans <= k)
		printf("%d\n", ans);
	else
		printf("-1\n");
	return 0;
}


#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

const int maxn = 128;
const int inf = 0x3f3f3f3f;
int n,m,k;
int a[maxn][maxn];
int solveC(int c)
{
	int ans = 0;
	for(int j = 0; j < m; ++j) {
		int cost = 0;
		for(int i = 0; i < n; ++i) {
			cost += (a[i][j] == a[i][c] ? 0 : 1);
		}
		ans += min(cost,n-cost);
	}
	return ans;
}
int solveR(int mask)
{
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int cost = 0;
		for(int j = 0; j < m; ++j) {
			cost += (a[i][j] == (1&(mask>>j)) ? 0 : 1);
		}
		ans += min(cost,m-cost);
	}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
			scanf("%d",&a[i][j]);
	int ans = inf;
	if(k < m) {
		for(int j = 0; j < m; ++j) {
			ans = min(ans,solveC(j));
		}
	} else {	//m <= k <= 10
		for(int mask = 0; mask < (1 << m); ++mask) {
			ans = min(ans,solveR(mask));
		}
	}
	if(ans <= k) {
		printf("%d\n",ans);
	} else {
		printf("-1\n");
	}
}


#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

const int maxn = 1024;
const int inf = 0x3f3f3f3f;
int n,m,k;
int a[maxn][maxn];
int solveC(int c)
{
	int ans = 0;
	for(int j = 0; j < m; ++j) {
		int cost = 0;
		for(int i = 0; i < n; ++i) {
			cost += (a[i][j] == a[i][c] ? 0 : 1);
		}
		ans += min(cost,n-cost);
	}
	return ans;
}
int solveR(int mask)
{
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int cost = 0;
		for(int j = 0; j < m; ++j) {
			cost += (a[i][j] == ((1<<j)&mask) ? 0 : 1);
		}
		ans += min(cost,m-cost);
	}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j)
			scanf("%d",&a[i][j]);
	int ans = inf;
	if(k < m) {
		for(int i = 0; i < m; ++i) {
			ans = min(ans,solveC(i));
		}
	} else {	//m <= k <= 10
		for(int mask = 0; mask < (1 << m); ++mask) {
			ans = min(ans,solveR(mask));
		}
	}
	if(ans <= k) {
		printf("%d\n",ans);
	} else {
		printf("-1\n");
	}
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<iomanip>
#include<climits>
#include<string.h>
#include<numeric>
#include<cmath>
#include<stdlib.h>
#include<vector>
#include<stack>
#include<set>
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mp            make_pair
#define INF 1e7
#define MAXN 100010
#define maxn 100010
#define Mod 1000007
#define N 110
using namespace std;
typedef long long LL;

int G[N][N];

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	FOR(i, 1, n) FOR(j, 1, m) cin >> G[i][j];
	int ans = INF,sum, t;
	if (n > k) {
		FOR (x,1,n) {
			sum = 0;
			FOR(i, 1, n) {
				t = 0;
				FOR(j , 1, m)
					t += G[i][j]^G[x][j];
			   	sum += min(t,m-t);
			}
			ans = min(ans, sum);
		}
	}
	else {
		REP(x, 1<<n) {
			sum = 0;
			FOR(j, 1, m) {
				t = 0;
				FOR(i , 1, n)
					t += G[i][j]^((x>>(i-1))&1);
				sum += min(t,n-t);

			}
			ans = min(sum, ans);
		}
	}
	if (ans > k) ans = -1;
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<iomanip>
#include<climits>
#include<string.h>
#include<numeric>
#include<cmath>
#include<stdlib.h>
#include<vector>
#include<stack>
#include<set>
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mp            make_pair
#define INF 1e7
#define MAXN 100010
#define maxn 100010
#define Mod 1000007
#define N 110
using namespace std;
typedef long long LL;

int G[N][N];

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	FOR(i, 1, n) FOR(j, 1, m) cin >> G[i][j];
	int ans = INF,sum, t;
	if (n < k) {
		FOR(x, 1, n) {
			sum = 0;
			FOR(i, 1, n) {
				t = 0;
			   	FOR(j, 1, m)
					t += G[i][j]^G[x][j];
				sum += min(t, m-t-1);
			}
			ans = min(ans,sum);
		}
	} else {
		REP(x,1<<n) {
			sum = 0;
			FOR(j,1,m) {
				t = 0;
				FOR(i, 1, n)
					t += G[i][j]^((x>>i)&1);
				sum += min(t,n-t-1);
			}
			ans = min(ans, sum);
		}
	}
	if (ans > k) ans = -1;
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<iomanip>
#include<climits>
#include<string.h>
#include<numeric>
#include<cmath>
#include<stdlib.h>
#include<vector>
#include<stack>
#include<set>
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mp            make_pair
#define INF 1e7
#define MAXN 100010
#define maxn 100010
#define Mod 1000007
#define N 110
using namespace std;
typedef long long LL;

int G[N][N];

int main()
{
	int n, m, k;
	cin >> n >> m >> k;
	FOR(i, 1, n) FOR(j, 1, m) cin >> G[i][j];
	int ans = INF,sum, t;
	if (n < k) {
		FOR(x, 1, n) {
			sum = 0;
			FOR(i, 1, n) {
				t = 0;
			   	FOR(j, 1, m)
					t += G[i][j]^G[x][j];
				sum += min(t, n-t);
			}
			ans = min(ans,sum);
		}
	} else {
		REP(x,1<<n) {
			sum = 0;
			FOR(j,1,m) {
				t = 0;
				FOR(i, 1, n)
					t += G[i][j]^((x>>i)&1);
				sum += min(t,n-t);
			}
			ans = min(ans, sum);
		}
	}
	if (ans > k) puts("-1");
	else cout << ans << endl;
	return 0;
}


#include <iostream>

int t[10000];
int main(){
  int n, m, k;
  std::cin >> n >> m >> k;
  for (int i=0; i<n; i++){
    for (int j=0; j<m; j++){
      std::cin >> t[1000*i+j];
    }
  }
  int ans=1000000;
  for (int j=0; j<m; j++){
    int dc=0;
    for (int j2=0; j2<m; j2++){
      int c=0;
      for (int i=0; i<n; i++){
	if (t[1000*i+j]==t[1000*i+j2]) c++;
      }
      dc+=std::min(c, n-c);
    }
    ans=std::min(ans, dc);
  }
  if (ans>k){
    std::cout << -1;
  }else{
    std::cout << ans;
  }

}