#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}



typedef vector<ll> Row;
typedef vector<Row> Matrix;

Matrix G;
Matrix mul(const Matrix& A, const Matrix& B) {
    Matrix res(A.size(), Row(B[0].size(), 0));
    REP(i, A.size()) REP(j, B[0].size()) REP(k, B.size()) {
        if ( A[i][k] && B[k][j] ) res[i][j] = (res[i][j] + A[i][k] * B[k][j]) % 2;
    }
    return res;
}
Matrix E(const int n) {
    Matrix res(n, Row(n, 0));
    REP(i, n) res[i][i] = 1;
    return res;
}
Matrix power(const Matrix& A, const ll n) {
    Matrix x = A;
    Matrix res = E(A.size());
    for (ll i = 1; i <= n; i <<= 1) {
        if (i & n) {
            res = mul(res, x);
        }
        x = mul(x, x);
    }
    return res;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n; cin >> n;
    Matrix G(n, Row(n)); cin >> G;
    vector<ll> b(n); cin >> b;
    ll T; cin >> T;
    vector<bool> used(n, false);
    G = power(G, T);
    REP(i, n) {
        int pos = -1;
        REP(j, n) {
            if (used[j]) continue;
            if (G[j][i]) {
                pos = j;
            }
        }
        if (pos < 0) continue;
        REP(j, n) {
            if (j == pos) continue;
            if (G[j][i] == 0) continue;
            REP(k, n) {
                G[j][k] = (G[j][k] + G[pos][k]) % 2;
            }
            b[j] = (b[j] + b[pos]) % 2;
        }
        REP(j, n) {
            if (j != pos && G[j][i]) {
                assert(false);
                cout << i << " " << j << " " << pos << " " << G[pos][i] << endl;
            }
        }
        used[pos] = true;
    }
    int flag = 0;
    REP(i, n) {
        bool f = false;
        REP(j, n) {
            if ( G[i][j] ) {
                f = true;
            }
        }
        if (!f) {
            if ( b[i] == 0 ) {
                flag = max(flag, 1);
            }
            else {
                flag = 2;
            }
        }
    }
    if (flag == 2) {
        cout << "none" << endl;
    }
    else if (flag == 1) {
        cout << "ambiguous" << endl;
    }
    else {
        vector<int> ans(G.size());
        REP(i, b.size()) {
            REP(j, G.size()) {
                if ( G[i][j] ) {
                    ans[j] = b[i];
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5828