/* written by Pankaj Kumar. country:-INDIA */ #include using namespace std; typedef long long ll ; typedef set> spi; typedef set> spl; typedef vector> vpi; typedef vector vi; typedef vector vl; typedef vector vb; typedef vector vc; typedef vector> vpl; typedef vector vs; typedef mapmi; typedef map ml; typedef set ss; typedef setsc; typedef set si; typedef set sl; #define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); // define values. #define mod 1e9+7LL #define phi 1.618 /* Bit-Stuff */ #define get_set_bits(a) (__builtin_popcount(a)) #define get_set_bitsll(a) ( __builtin_popcountll(a)) #define get_trail_zero(a) (__builtin_ctz(a)) #define get_lead_zero(a) (__builtin_clz(a)) #define get_parity(a) (__builtin_parity(a)) /* Abbrevations */ #define ff first #define ss second #define mp make_pair #define line cout<>arr[i]; // Some print #define no cout<<"NO"<>test;while(test--) // sort #define all(V) (V).begin(),(V).end() #define srt(V) sort(all(V)) #define srtGreat(V) sort(all(V),greater()) // function ll power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p; } return res; } /* ascii value A=65,Z=90,a=97,z=122 1=49 */ /* -----------------------------------------------------------------------------------*/ // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); void solve() { int n, m; cin >> n >> m; vector s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } vector> v(1005, vector(1005)); int q; cin >> q; while (q--) { int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; v[x1][y1]++; v[x1][y2 + 1]--; v[x2 + 1][y1]++; v[x2 + 1][y2 + 1]--; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { v[i][j] += v[i][j - 1]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { v[i][j] += v[i - 1][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (v[i + 1][j + 1] % 2 == 0) { cout << s[i][j]; } else { cout << ((s[i][j] - '0') ^ 1); } } cout << '\n'; } } int main() { pan solve(); }