#include<bits/stdc++.h>
#define ll long long
#define ldb long double
#define fi first
#define se second
#define sza(a) (int)a.size()
#define pir pair<int,int>
#define pirll pair<ll,ll>
using namespace std;
int a[5][5],arr[5][5],cnt[5][5];
bool is_equal(int n){
for (int i = 1 ; i <= n ; i++)
for (int j = 1 ; j <= n ; j++)
if (a[i][j] != cnt[i][j]) return 0;
return 1;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n = 4,N = 16;
for (int i = 1 ; i <= n ; i++)
for (int j = 1 ; j <= n ; j++) cin >> a[i][j];
for (int curmask = 0 ; curmask < (1 << N) ; curmask++){
int mask = curmask;
for (int i = 1 ; i <= n ; i++){
for (int bit = 0 ; bit < n ; bit++)
arr[i][bit + 1] = (((1 << bit) & mask) > 0) ? 1 : 0;
mask >>= n;
}
memset(cnt,0,sizeof(cnt));
for (int i = 1 ; i <= n ; i++)
for (int j = 1 ; j <= n ; j++)
for (int x = -1 ; x <= 1 ; x++)
for (int y = -1 ; y <= 1 ; y++)
if (x != 0 || y != 0)
cnt[i][j] += arr[i + x][j + y];
if (is_equal(n)){
for (int i = 1 ; i <= n ; i++){
for (int j = 1 ; j <= n ; j++) cout << arr[i][j] << " ";
cout << "\n";
}
break;
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBsZGIgbG9uZyBkb3VibGUKI2RlZmluZSBmaSBmaXJzdAojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIHN6YShhKSAoaW50KWEuc2l6ZSgpCiNkZWZpbmUgcGlyIHBhaXI8aW50LGludD4KI2RlZmluZSBwaXJsbCBwYWlyPGxsLGxsPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGFbNV1bNV0sYXJyWzVdWzVdLGNudFs1XVs1XTsKCmJvb2wgaXNfZXF1YWwoaW50IG4pewoJZm9yIChpbnQgaSA9IDEgOyBpIDw9IG4gOyBpKyspCg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