#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;

template<int N>
struct SquareMatrix_F2{
    vector<bitset<N>> matrix;
    SquareMatrix_F2(vector<bitset<N>> &a):matrix(a){}
    SquareMatrix_F2(vector<vector<int>> &a):SquareMatrix_F2(){
        int n = a.size();
        int m = a[0].size();
        for(int i=0; i<min(n, N); i++){
            for(int j=0; j<min(m, N); j++){
                matrix[i][j] = a[i][j];
            }
        }
    }
    SquareMatrix_F2(int a):SquareMatrix_F2(){
        if(a == 1){
            for(int i=0; i<N; i++){
                matrix[i][i] = 1;
            }
        }
    }
    SquareMatrix_F2(){
        matrix.resize(N);
    }

    bitset<N>& operator [](int n){
        return matrix[n];
    }
    SquareMatrix_F2 transpose() const{
        SquareMatrix_F2 res;
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                res[i][j] = matrix[j][i];
            }
        }
        return res;
    }
    SquareMatrix_F2 operator +(const SquareMatrix_F2 &a) const{
        SquareMatrix_F2 res;
        for(int i=0; i<N; i++){
            res[i] = matrix[i] ^ a[i];
        }
        return res;
    }
    SquareMatrix_F2 operator *(const SquareMatrix_F2 &a) const{
        SquareMatrix_F2 res;
        SquareMatrix_F2 t = a.transpose();
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                bitset<N> tmp = matrix[i] & t[j];
                res[i][j] = tmp.count() % 2;
            }
        }
        return res;
    }

    SquareMatrix_F2 pow(long long int p){
        SquareMatrix_F2 res(1);
        for(int i=63; i>=0; i--){
            res = res*res;
            if((1LL<<i & p) != 0){
                res = res*matrix;
            }
        }
        return res;
    }

    // -1: no solution, 0: unique solution, 1: multiple
    pair<int, bitset<N>> solve_linear_eq(const bitset<N> &right, int varc){
        vector<bitset<N+1>> g(N);
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                g[i][j] = matrix[i][j];
            }
            g[i][N] = right[i];
        }
        for(int i=0,p=0; i<N and p<N; i++,p++){
            for(int j=i+1; j<N; j++){
                if(g[j][p] == 1) swap(g[i], g[j]);
            }
            if(g[i][p] == 0){
                i--;
                continue;
            }
            for(int j=0; j<N; j++){
                if(j!=i and g[j][p]==1){
                    g[j] ^= g[i];
                }
            }
        }
    
        bool has_sol = true;
        bool unique = true;
        bitset<N> res, decided;
        for(int i=varc-1; i>=0; i--){
            int right = g[i][N];
            vector<int> vars;
            if(g[i][i]==0) unique = false;
            for(int j=0; j<N; j++){
                if(g[i][j]==1){
                    if(decided[j]==1 and res[j]==1){
                        right ^= 1;
                    }else if(decided[j]==0){
                        vars.push_back(j);
                    }
                }
            }
            for(int j: vars){
                res[j] = 0;
                decided[j] = 1;
            }
            if(right==1){
                if(vars.empty()){
                    has_sol = false;
                    break;
                }else{
                    res[vars[0]] = 1;
                }
            }
        }
        int status = (!has_sol)? -1: (unique)? 0: 1;
        return make_pair(status, res);
    }
};

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> a[i][j];
        }
    }
    SquareMatrix_F2<300> m(a);
    bitset<300> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        v[i] = tmp;
    }
    int t;
    cin >> t;
    auto ret = m.pow(t).solve_linear_eq(v, n);
    if(ret.first == -1){
        cout << "none" << endl;
    }else if(ret.first == 1){
        cout << "ambiguous" << endl;
    }else{
        for(int i=0; i<n-1; i++){
            cout << ret.second[i] << " ";
        }
        cout << ret.second[n-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3444