Language: C++

#include<bits/stdc++.h>
using namespace std;
             
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> Pi;
typedef map<ll,ll> mi;
             
template<class T> T nrem(T x,T y){return ((x%y)+y)%y;}
             
#define For(i,a,n) for(int i=a;i<n;++i)
#define For0(i,n) for(int i=0;i<n;++i)
#define For1(i,n) for(int i=1;i<=n;++i)
#define Forl0(i,n) for(ll i=0;i<n;++i)
#define Forl1(i,n) for(ll i=1;i<=n;++i)
#define fi freopen("input.txt","r",stdin);
#define fo freopen("output.txt","w",stdout);
#define pb push_back
#define mp make_pair
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cs 200005
#define pi acos(-1)
#define INF (int)INFINITY
void in()
    {
         #ifndef ONLINE_JUDGE
         freopen("input.txt", "r", stdin);
         freopen("output.txt", "w", stdout);
        #endif
    }

int a[505][505];
int visit[505][505];

int main()
{  
    IOS
    in();
    
    int h,w;
    cin>>h>>w;
    
    vector<pair<pair<int,int>,pair<int,int>>>ans;

    For1(i,h)
    For1(j,w)    
    cin>>a[i][j];


    For1(i,h)
    For1(j,w)
    {
       if(a[i][j]%2==1&&visit[i][j]==0)
       {
          visit[i][j]=1;
          a[i][j]-=1;

          if(a[i-1][j]%2&&i-1>=1)
          {
              a[i-1][j]+=1;
              ans.pb(mp(mp(i,j),mp(i-1,j)));
          }
          else if(a[i][j-1]%2&&j-1>=1)
          {
             a[i][j-1]+=1;
              ans.pb(mp(mp(i,j),mp(i,j-1)));    
          }
          
          else if(a[i+1][j]%2&&i+1<=h)
          {
             a[i+1][j]+=1;
              ans.pb(mp(mp(i,j),mp(i+1,j)));    
          }
          
          else if(a[i][j+1]%2&&j+1<=w)
          {
             a[i][j+1]+=1;
              ans.pb(mp(mp(i,j),mp(i,j+1)));    
          }
          else if(i+1<=h)
          {
               a[i+1][j]+=1;
              ans.pb(mp(mp(i,j),mp(i+1,j)));   
          }
          else if(j+1<=w)
          {
              a[i][j+1]+=1;
              ans.pb(mp(mp(i,j),mp(i,j+1)));  
          }
       }   
    }
    
   cout<<ans.size()<<endl;
    For0(i,ans.size())
    cout<<ans[i].first.first<<" "<<ans[i].first.second<<" "<<ans[i].second.first<<" "<<ans[i].second.second<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:25: error: reference to 'visit' is ambiguous
   55 |        if(a[i][j]%2==1&&visit[i][j]==0)
      |                         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:35:5: note:                 'int visit [505][505]'
   35 | int visit[505][505];
      |     ^~~~~
a.cc:57:11: error: reference to 'visit' is ambiguous
   57 |           visit[i][j]=1;
      |           ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:35:5: note:                 'int visit [505][505]'
   35 | int visit[505][505];
      |     ^~~~~