#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    if (m==2)
    {
        if (n==2) 
        {
            int x,y,x2,y2;
            cin >>x>>y>>x2>>y2;
            if (x!=y && x2!=y2) cout <<0;
            else cout <<3<<endl<<2<<" "<<5<<endl<<4<<" "<<2<<endl<<2<<" "<<4; 
        }
    } 
    else cout <<0;
}
