#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

const int IINF = INT_MAX;

int extgcd(int a,int b,int& x,int& y){
  int d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  } else x = 1,y = 0;
  return d;
}

int mod_inv(int a,int m) {
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

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

vector<vector<int> > multi(const vector<vector<int> >& A,const vector<vector<int> >& B){
  vector<vector<int> > C(A.size(),vector<int>(B[0].size()));
  for(int i=0;i<C.size();++i)
    for(int j=0;j<C[i].size();++j)
      for(int k=0;k<A[i].size();++k)
        C[i][j] += ( A[i][k] * B[k][j] );
  return C;
}

vector<vector<int> > mod_multi(const vector<vector<int> >& A,const vector<vector<int> >& B,int mod){
  vector<vector<int> > C(A.size(),vector<int>(B[0].size()));
  for(int i=0;i<C.size();++i)
    for(int j=0;j<C[i].size();++j)
      for(int k=0;k<A[i].size();++k)
        ( C[i][j] += ( A[i][k] * B[k][j] ) % mod ) %= mod;
  return C;
}

vector<int> mod_multi(const vector<vector<int> >& A,const vector<int>& B,int mod) {
  vector<int> ret(A.size());
  for(int i=0;i<A.size();++i)
    for(int j=0;j<A[0].size();++j)
      ( ret[i] += ( ( A[i][j]*B[j] ) % mod ) ) %= mod;
  return ret;
}


vector<vector<int> > mod_pow(const vector<vector<int> >& A,int e,int mod) {
  return !e?identity(A.size()):(e%2?mod_multi(A,mod_pow(A,e-1,mod),mod):mod_pow(mod_multi(A,A,mod),e/2,mod));
}

vector<vector<int> > pow(const vector<vector<int> >& A,int e) {
  return !e?identity(A.size()):(e%2?multi(A,pow(A,e-1)):pow(multi(A,A),e/2));
}


bool inv_matrix(vector<vector<double> > &A,vector<vector<double> > &res){
  int n = A.size();
  vector<vector<double> > B(n,vector<double>(n+n));
  rep(i,n) rep(j,n) B[i][j] = A[i][j], B[i][n+j] = ( i == j );
  rep(x,n){
    int pivot = x;
    REP(j,x,n) if( abs(B[j][x]) > abs(B[pivot][x]) ) { pivot = j; break; }
    swap(B[x],B[pivot]);
    if( abs(B[x][x]) < EPS ) return false;
    if( abs(B[x][x]) > EPS ) {
      rep(j,n) if( j != x ) {
        double t = B[j][x] / B[x][x];
        if( !equals(t,0.0) ) REP(k,x,n+n) B[j][k] = B[j][k] - B[x][k] * t;
      }
      double t = 1.0 / B[x][x];
      REP(j,x,n+n) B[x][j] *= t;
    }
  }
  res.clear();
  res.resize(n,vector<double>(n));
  rep(i,n) rep(j,n) res[i][j] = B[i][n+j];
  return true;
}

bool mod_inv_matrix(vector<vector<int> > &A,int m,vector<vector<int> > &res){
  int n = A.size();
  vector<vector<int> > B(n,vector<int>(n+n));
  rep(i,n) rep(j,n) B[i][j] = A[i][j], B[i][n+j] = ( i == j );
  rep(x,n){
    int pivot = -1;
    REP(j,x,n) if( B[j][x] ) { pivot = j; break; }
    //if( pivot == -1 ) continue;
    if( pivot == -1 ) return false;
    swap(B[x],B[pivot]);
    rep(j,n) if( j != x ) {
      int t = B[j][x] * mod_inv(B[x][x],m) % m;
      if( t ) REP(k,x,n+n) B[j][k] = ( ( B[j][k] - B[x][k] * t ) % m + m ) % m;
    }
    int t = mod_inv(B[x][x],m);
    REP(j,x,n+n) B[x][j] = ( B[x][j] * t ) % m;
  }

  res.clear();
  res.resize(n,vector<int>(n));
  rep(i,n) rep(j,n) res[i][j] = B[i][n+j];
  return true;
}

int rank(vector<vector<int> > A,int mod) {
  int H = A.size(), W = A[0].size();
  int r = 0;
  rep(x,W) {  
    int pivot = IINF;
    REP(y,r,H) if(A[y][x]) {
      pivot = y;
      break;
    }
    if( pivot == IINF )continue;
    swap(A[r],A[pivot]);
    REP(y,r+1,H) {
	  int value = A[y][x] * mod_inv(A[r][x],mod) % mod;
	  if(value) REP(x2,x,W) A[y][x2] = ((A[y][x2] - A[r][x2] * value)%mod + mod ) % mod; 
	}
    r++;
  }
  return r;
}

void printer(vector<vector<int> > &A){
  rep(i,A.size()){
    rep(j,A[i].size()){
      cout << A[i][j] << " ";
    } puts("");
  }
}

int main(){
  int n,phase;
  scanf("%d",&n);
  vector<vector<int> > A(n,vector<int>(n));
  vector<int> b(n);
  rep(i,n) rep(j,n) scanf("%d",&A[i][j]);
  rep(i,n) scanf("%d",&b[i]);
  scanf("%d",&phase);

  A = mod_pow(A,phase,2);
  //printer(A);
  vector<vector<int> > Ab(n,vector<int>(n+1));
  rep(i,n) rep(j,n) Ab[i][j] = A[i][j];
  rep(i,n) Ab[i][n] = b[i];
  int rankA  = rank(A,2);
  int rankAb = rank(Ab,2);
  //cout << rankA << " ?= " << rankAb << endl;
  if( rankA != rankAb ) { puts("none"); return 0; }
  if( rankA != n      ) { puts("ambiguous"); return 0; }

  vector<vector<int> > invA;
  mod_inv_matrix(A,2,invA);
  vector<int> x = mod_multi(invA,b,2);

  rep(i,x.size()) {
    if( i ) printf(" ");
    cout << x[i];
  } puts("");

  /*
  vector<vector<int> > invA;
  if( !mod_inv_matrix(A,2,invA) ) {
    puts("none");
    return 0;
  }

  vector<vector<int> > Ab(n,vector<int>(n+1));
  rep(i,n) rep(j,n) Ab[i][j] = A[i][j];
  rep(i,n) Ab[i][n] = b[i];
  rep(i,Ab.size()) {
    rep(j,Ab[i].size()){
      cout << Ab[i][j] << " ";
    } puts("");
  }
  int rankA  = rank(A,2);
  int rankAb = rank(Ab,2);
  cout << rankA << " ?= " << rankAb << endl;
  if( rankA != rankAb ) puts("none");

  invA = mod_pow(invA,phase,2);

  vector<int> x = mod_multi(invA,b,2);

  rep(i,x.size()) {
    if( i ) printf(" ");
    cout << x[i];
  } puts("");
  */

  return 0;
}

Measured memory_bytes: 11564