/*
 * 2624.cc: Graph Automata Player
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 300;

typedef long long ll;

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

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

typedef bool BoolVec[MAX_N];

enum { ST_OK, ST_NA, ST_MANY };

struct BoolMatrix {
  int n;
  bool m[MAX_N][MAX_N];
  
  BoolMatrix(): n(0) {}
  BoolMatrix(int _n): n(_n) {};

  void init() { memset(m, 0, sizeof(m)); }
  void unit() {
    init();
    for (int i = 0; i < n; i++) m[i][i] = 1;
  }
  
  BoolMatrix operator+(const BoolMatrix& m0) {
    BoolMatrix mm(n);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) mm.m[i][j] = m[i][j] ^ m0.m[i][j];
    return mm;
  }

  BoolMatrix operator*(const BoolMatrix& m0) {
    BoolMatrix mm(n);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        mm.m[i][j] = 0;
        for (int k = 0; k < n; k++) mm.m[i][j] ^= m[i][k] & m0.m[k][j];
    }
    return mm;
  }

  BoolMatrix pow(int e) {
    BoolMatrix mm(n), m0 = *this;
    mm.unit();

    while (e > 0) {
      if (e & 1) mm = mm * m0;
      m0 = m0 * m0;
      e >>= 1;
    }
    return mm;
  }

  void solve(BoolVec &v, int &st) {
    st = ST_OK;

    for (int i = 0; i < n; i++) {
      if (! m[i][i])
	for (int j = i + 1; j < n; j++)
	  if (m[j][i]) {
	    for (int k = i; k < n; k++)
	      swap(m[i][k], m[j][k]);
	    swap(v[i], v[j]);
	    break;
	  }

      if (m[i][i])
	for (int j = i + 1; j < n; j++)
	  if (m[j][i]) {
	    for (int k = i; k < n; k++) m[j][k] ^= m[i][k];
	    v[j] ^= v[i];
	  }
    }
  
    for (int i = n - 1; i >= 0; i--) {
      if (m[i][i]) {
	for (int j = i - 1; j >= 0; j--)
	  if (m[j][i]) m[j][i] = false, v[j] ^= v[i];
      }
      else {
	bool ex = false;
	for (int j = i + 1; ! ex && j < n; j++) ex |= m[i][j];
	if (! ex && v[i]) {
	  st = ST_NA;
	  return;
	}
	st = ST_MANY;
      }
    }
  }

  void print() {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) printf("%d ", m[i][j]);
      putchar('\n');
    }
  }
};

/* global variables */

/* subroutines */

BoolVec v;

/* main */

int main() {
  int n;
  cin >> n;

  BoolMatrix a(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a.m[i][j];

  for (int i = 0; i < n; i++) cin >> v[i];

  int t;
  cin >> t;

  BoolMatrix at = a.pow(t);

  int st;
  at.solve(v, st);
  //at.print(); printf("st=%d\n", st);

  if (st == ST_OK) {
    for (int i = 0; i < n; i++) {
      if (i) putchar(' ');
      printf("%d", v[i]);
    }
    putchar('\n');
  }
  else
    cout << (st == ST_NA ? "none" : "ambiguous") << endl;
  return 0;
}