#include<bits/stdc++.h>
using namespace std;
int x,y,vis[40][40];
int dx[]={-2,-1, 1, 2, 2, 2, 2, 1,-1,-2,-1, 1};
int dy[]={-2,-2,-2,-2,-1, 1, 2, 2, 2, 2, 1,-1};
struct qwer{
int x;
int y;
};
queue<qwer>b;
int main(){
for(int ASDFGHJKL=0;ASDFGHJKL<2;ASDFGHJKL++){
cin>>x>>y;
while(!b.empty())b.pop();
memset(vis,0,sizeof(vis));
qwer a;
a.x=x;
a.y=y;
b.push(a);
while(!b.empty()){
a=b.front();
if(a.x==1&&a.y==1){
cout<<vis[a.x][a.y]<<endl;
for(int i=1;i<40;i++){
for(int j=1;j<40;j++){
cout<<setw(3)<<vis[i][j];
}
cout<<endl;
}
break;
}
for(int i=0;i<12;i++){
if((vis[a.x+dx[i]][a.y+dy[i]]==0&&a.x+dx[i]>0)&&a.y+dy[i]>0){
qwer c;
c.x=a.x+dx[i];
c.y=a.y+dy[i];
b.push(c);
vis[a.x+dx[i]][a.y+dy[i]]=vis[a.x][a.y]+1;
}
}
b.pop();
}
}
return 0;
}