#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
int r = (n - 1) / 2;
int c = (m - 1) / 2;
cout << r * c << "\n";
string s;
cin >> s;
if(s == "No")
return 0;
for(int i = 1; i < n; i++)
for(int j = 1; j < m; j++)
if(i % 2 == 0 && j % 2 == 0)
cout << i << " " << j << "\n";
if(c % 2 == 1)
{
cout << 1 << " " << 1 << "\n";
for(int i = 0; i < r; i++)
{
if(i % 2 == 0)
{
for(int j = 0; j < c; j++)
{
if(j % 2 == 0)
cout << 2 * i + 3 << " " << 2 * j + 3 << "\n";
else
cout << 2 * i + 1 << " " << 2 * j + 3 << "\n";
}
}
else
{
for(int j = c - 1; j >= 0; j--)
{
if(j % 2 != c % 2)
cout << 2 * i + 3 << " " << 2 * j + 1 << "\n";
else
cout << 2 * i + 1 << " " << 2 * j + 1 << "\n";
}
}
}
}
else if(r % 2 == 1)
{
cout << 1 << " " << 1 << "\n";
for(int j = 0; j < c; j++)
{
if(j % 2 == 0)
{
for(int i = 0; i < r; i++)
{
if(i % 2 == 0)
cout << 2 * i + 3 << " " << 2 * j + 3 << "\n";
else
cout << 2 * i + 3 << " " << 2 * j + 1 << "\n";
}
}
else
{
for(int i = r - 1; i >= 0; i--)
{
if(i % 2 != r % 2)
cout << 2 * i + 1 << " " << 2 * j + 3 << "\n";
else
cout << 2 * i + 1 << " " << 2 * j + 1 << "\n";
}
}
}
}
else
{
if(r == 0 || c == 0)
{
cout << "1 1\n";
return 0;
}
cout << 1 << " " << 3 << "\n";
for(int i = 0; i < r; i++)
{
if(i % 2 == 0)
{
for(int j = 1; j < c; j++)
{
if(j % 2 == 1)
cout << 2 * i + 3 << " " << 2 * j + 3 << "\n";
else
cout << 2 * i + 1 << " " << 2 * j + 3 << "\n";
}
}
else
{
for(int j = c - 1; j >= 1; j--)
{
if(j % 2 != c % 2)
cout << 2 * i + 3 << " " << 2 * j + 1 << "\n";
else
cout << 2 * i + 1 << " " << 2 * j + 1 << "\n";
}
}
}
for(int i = r - 1; i >= 0; i--)
{
if(i % 2 != r % 2)
cout << 2 * i + 1 << " " << 1 << "\n";
else
cout << 2 * i + 1 << " " << 3 << "\n";
}
}
return 0;
}