#include
#include<bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n>>m;
int a[n+1][m+1];
string s="";
for(int i=1;i<=n;i++)
{
cin>>s;
for(int j=1;j<=m;j++)
a[i][j]=s[j-1]-48;
}
int q;
cin>>q;
for(int z=0;z<q;z++)
{
int x1=0,x2=0,y1=0,y2=0;
cin>>x1>>y1>>x2>>y2;
for(int i=x1;i<=x2;i++)
for(int j=y1;j<=y2;j++)
{
if(a[i][j]==0)
a[i][j]=1;
else
a[i][j]=0;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
{
cout<<a[i][j];
}
cout<<endl;
}
return 0;
}
Please do help why is this TLE, but similar programs of others were accepted.