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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define rrep(i, j) for(int i=(j)-1; i >= 0; i--)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define rrepeat(i, j, k) for(int i = (k)-1; i >= (int)(j); i--)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

const double EPS = 1e-8;

template<class T>
using matrix = vector<vector<T>>;

template<class T>
matrix<T> operator * (const matrix<T> &a, const matrix<T> &b) {
    assert(a.size() > 0 and a[0].size() == b.size() and b[0].size() > 0);
    matrix<T> ret(a.size(), vector<T>(b[0].size()));
    rep(r, ret.size()) rep(i, a[r].size()) rep(c, ret[r].size()) {
        ret[r][c] += a[r][i] * b[i][c];
        ret[r][c] %= 2;
    }
    return ret;
}

template<class T>
matrix<T> mat_pow(matrix<T> a,ll n) {
    if(n == 0) {
        auto b = a;
        rep(i, b.size()) rep(j, b[i].size()) b[i][j] = i == j;
        return b;
    }
    if(n%2 == 1) return a * mat_pow(a, n-1);
    auto t = mat_pow(a, n / 2);
    return t * t;
}

template<class T> 
int rank_of(vector<vector<T>> &A, vector<T> b) {
    int N = A.size();
    assert(b.size() == N);
    vector<vector<T>> Ab(N, vector<T>(N + 1));
    rep(i, N) rep(j, N) Ab[i][j] = A[i][j];
    rep(i, N) Ab[i][N] = b[i];


    //debug(A);
    //debug(b);
    // debug(Ab);
    
    int M = N + 1;
    int rank = 0;
    int num_zero = 0;
    rep(m, M) { // ?¨?        
        int n = m - num_zero;
        if(n == N) break;
        T max_n = n;
        repeat(nn, n + 1, N) if(Ab[n][m] < Ab[nn][m]) max_n = nn;
        swap(Ab[n], Ab[max_n]);
        num_zero += Ab[n][m] == 0;
        rank += Ab[n][m] != 0;
        if(Ab[n][m] != 0) {
            repeat(nn, n + 1, N) {
                if(Ab[nn][m]) {
                    repeat(mm, m, M) Ab[nn][mm] ^= Ab[n][mm];
                }
            }
        }
    }
    // debug(Ab);
    return rank;
}

template<class T> 
tuple<bool, vector<vector<T>>> inverse(vector<vector<T>> &AA) {
    int N = AA.size(), M = AA[0].size() * 2;
    assert(N * 2 == M);
    vector<vector<T>> A(N, vector<T>(M));
    rep(n, N) rep(m, N) {
        A[n][m] = AA[n][m];
        A[n][N + m] = n == m;
    }
    
    rep(m, N) { // ???????¶????
        int n = m;
        T max_n = n;
        repeat(nn, n + 1, N) if(abs(A[n][m]) < abs(A[nn][m])) max_n = nn;
        swap(A[n], A[max_n]);
        T div = A[n][m];
        if(div == 0) return make_tuple(false, vector<vector<T>>());
        assert(div == 1);
        rep(mm, M) A[n][mm] /= div;
        repeat(nn, n + 1, N) {
            T prod = A[nn][m] / div;
            if(prod) repeat(mm, m, M) A[nn][mm] ^= A[n][mm] * prod;
        }
    }
    rep(i, N) if(A[i][i] == 0) return make_tuple(false, vector<vector<T>>());
    // ?????´????????????????????????
    rrep(m, N) {
        rrep(n, N) {
            if(m == n) continue;
            if(abs(A[n][m]) != 0) {
                int k = A[n][m] / A[m][m];
                repeat(i, m, M) A[n][i] ^= A[m][i] * k;
            }
        }
    }
    vector<vector<T>> inv(N, vector<T>(N));
    rep(n, N) rep(m, N) inv[n][m] = A[n][N + m];
    return make_tuple(true, inv);
}

class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<vector<int>> A(N, vector<int>(N)); cin >> A;
        vector<int> b(N); cin >> b;
        int T; cin >> T;
        auto inversed = inverse(A);
        bool ok = get<0>(inversed);
        auto At = mat_pow(A, T);
        if(ok) {
            matrix<int> bb(N, vector<int>(1));
            rep(i, N) bb[i][0] = b[i];
            auto ans = mat_pow(get<1>(inversed), T) * bb;
            rep(i, N) cout << ans[i][0] << (i == N - 1 ? "\n" : " ");
        } else {        
            int rank1 = rank_of(At, b);
            int rank2 = rank_of(At, vector<int>(N));            
            cout << (rank1 == rank2 ? "ambiguous" : "none") << endl;
        }
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}

Measured memory_bytes: 18940