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

typedef vector<vector<int>> matrix;

matrix operator*(const matrix &A, const matrix &B) {
	const int n = A.size();
	const int m = B[0].size();

	matrix res(n, vector<int>(m, 0));
	for(int i = 0; i < n; ++i) {
		for(int k = 0; k < B.size(); ++k) {
			for(int j = 0; j < m; ++j) {
				res[i][j] ^= A[i][k] & B[k][j];
			}
		}
	}
	return res;
}

matrix power(matrix A, int x) {
	const int n = A.size();
	matrix res(n, vector<int>(n, 0));
	for(int i = 0; i < n; ++i) res[i][i] = 1;

	while(x > 0) {
		if(x & 1) res = res * A;
		A = A * A;
		x >>= 1;
	}
	return res;
}

vector<int> gauss_jordan(matrix A, const vector<int> &b) {
	const int n = A.size();
	for(int i = 0; i < n; ++i) {
		A[i].emplace_back(b[i]);
	}

	int j = 0;
	for(int i = 0; i < n; ++i) {
		int pivot = i;

		while(!A[pivot][j]) {
			if(++pivot == n) {
				pivot = i;
				if(++j > n) assert(false);
			}
		}

		A[i].swap(A[pivot]);

		for(int k = 0; k < n; ++k) {
			if(i == k) continue;
			if(A[k][j]) {
				for(int l = j; l <= n; ++l) {
					A[k][l] ^= A[i][l];
				}
			}
		}
		++j;
	}

	vector<int> res(n);
	for(int i = 0; i < n; ++i) {
		res[i] = A[i][n];
	}
	return res;
}

int rank_of(matrix A) {
	const int n = A.size();
	const int m = A[0].size();

	int res = 0;
	for(int i = 0, j = 0; i < n && j < m; ++i) {
		int pivot = i;

		while(!A[pivot][j]) {
			if(++pivot == n) {
				pivot = i;
				if(++j == m) return res;
			}
		}

		A[i].swap(A[pivot]);

		for(int k = i + 1; k < n; ++k) {
			if(A[k][j]) {
				for(int l = j + 1; l < m; ++l) {
					A[k][l] ^= A[i][l];
				}
			}
		}

		++j;
		++res;
	}
	return res;
}

int rank_of(matrix A, const vector<int> &b) {
	const int n = A.size();
	for(int i = 0; i < n; ++i) {
		A[i].emplace_back(b[i]);
	}
	return rank_of(move(A));
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	matrix A(n, vector<int>(n));
	for(auto &row : A) {
		for(auto &e : row) {
			cin >> e;
		}
	}

	vector<int> b(n);
	for(auto &e : b) cin >> e;

	int t;
	cin >> t;

	A = power(move(A), t);

	const int rank_A = rank_of(A);
	const int rank_Ab = rank_of(A, b);

	if(rank_A != rank_Ab) {
		cout << "none" << endl;
	}
	else if(rank_A < n) {
		cout << "ambiguous" << endl;
	}
	else {
		const auto ans = gauss_jordan(move(A), b);
		for(int i = 0; i < n; ++i) {
			cout << ans[i] << (i + 1 == n ? '\n' : ' ');
		}
	}

	return EXIT_SUCCESS;
}