Language: C++

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-8;

long long int N, M, K, H, W, L, R;


struct box {
	int sy, sx, gy, gx;
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> H >> W;
	vector<vector<int>>v(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> v[i][j];
		}
	}
	vector<box>ans;
	for (int i = 0; i < H; i++) {
		if (i % 2) {
			for (int j = W - 1; j > 0; j--) {
				if (v[i][j] % 2) ans.emplace_back(i, j, i, j - 1);
			}
			if (v[i][0] % 2&&i+1!=H)ans.emplace_back(i, 0, i + 1, 0);
		}
		else {
			for (int j = 0; j < W; j++) {
				if (v[i][j] % 2)ans.emplace_back(i, j, i, j + 1);
			}
			if (v[i][W - 1] % 2 && i + 1 != H)ans.emplace_back(i, W - 1, i + 1, W - 1);
		}
	}
	cout << ans.size() << endl;
	for (auto i : ans) {
		cout << i.sy << " " << i.sx << " " << i.gy << " " << i.gx << endl;
	}
	return 0;
}

Compiler output:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = box; _Args = {int&, int&, int&, int}; _Tp = box]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = box; _Args = {int&, int&, int&, int}; _Tp = box; allocator_type = std::allocator<box>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&, int&, int}; _Tp = box; _Alloc = std::allocator<box>; reference = box&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:48:38:   required from here
   48 |                                 if (v[i][j] % 2) ans.emplace_back(i, j, i, j - 1);
      |                                                  ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'box::box(int)'
a.cc:29:8: note: candidate: 'box::box()'
   29 | struct box {
      |        ^~~
a.cc:29:8: note:   candidate expects 0 arguments, 1 provided
a.cc:29:8: note: candidate: 'constexpr box::box(const box&)'
a.cc:29:8: note:   no known conversion for argument 1 from 'int' to 'const box&'
a.cc:29:8: note: candidate: 'constexpr box::box(box&&)'
a.cc:29:8: note:   no known conversion for argument 1 from 'int' to 'box&&'
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = box; _Args = {int&, int, int, int}; _Tp = box]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = box; _Args = {int&, int, int, int}; _Tp = box; allocator_type = std::allocator<box>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int, int, int}; _Tp = box; _Alloc = std::allocator<box>; reference = box&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:50:44:   required from here
   50 |                         if (v[i][0] % 2&&i+1!=H)ans.emplace_back(i, 0, i + 1, 0);
      |                                                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'box::box(int)'
a.cc:29:8: note: candidate: 'box::box()'
   29 | struct box {
      |        ^~~
a.cc:29:8: note:   candidate expects 0 arguments, 1 provided
a.cc:29:8: note: candidate: 'constexpr box::box(const box&)'
a.cc:29:8: note:   no known conversion for argument 1 from 'int' to 'const box&'
a.cc:29:8: note: candidate: 'constexpr box::box(box&&)'
a.cc:29:8: note:   no known conversion for argument 1 from 'int' to 'box&&'
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = box; _Args = {int&, long long int, int, long long int}; _Tp = box]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = box; _Args = {int&, long long int, int, long long int}; _Tp = box; allocator_type = std::allocator<box>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, long long int, int, long long int}; _Tp = box; _Alloc = std::allocator<box>; reference = box&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:56:54:   required from here
   56 |                         if (v[i][W - 1] % 2 && i + 1 != H)ans.emplace_back(i, W - 1, i + 1, W - 1);
      |                                                           ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'box::box(long long int)'
a.cc:29:8: note: candidate: 'box::box()'
   29 | struct box {
      |        ^~~
a.cc:29:8: note:   candidate expects 0 arguments, 1 provided
a.cc:29:8: note: candidate: 'constexpr box::box(const box&)'
a.cc:29:8: note:   no known conversion for argument 1 from 'long long int' to 'const box&'
a.cc:29:8: note: candidate: 'constexpr box::box(box&&)'
a.cc:29:8: note:   no known conversion for argument 1 from 'long long int' to 'box&&'