typedef unsigned long long ull; ull z; p[100],N; idx(n){ int r,i; for(i=0;i<16;++i)(z>>4*i&15)==n?r=15-i:0; return r; } yoko(r,a){ ull m=0xffff000000000000ull>>16*(r&=3); if(a&=3){ z=~m&z|m&(z>>4*a|z<<4*(4-a)); p[N++]=0<<4|r<<2|a; } } tate(c,b){ ull m=0xf000f000f000f000ull>>4*(c&=3); if(b&=3){ z=~m&z|m&(z>>16*b|z<<16*(4-b)); p[N++]=1<<4|c<<2|b; } } main(i,j){ for(i=0;i<16;++i&3||getchar()){ z=z<<4|getchar()-1&15; } for(i=0;i<15;++i){ for(;i!=(j=idx(i));){ if(i<12){ if((i&3)==(j&3)){ yoko(j>>2,1); j=j&12|j+1&3; } tate(j,3-(j>>2)); tate(i,3-(i>>2)); yoko(3,i-j); tate(i,(i>>2)-3); tate(j,(j>>2)-3); }else{ tate(j,3); yoko(3,2); tate(j,1); yoko(3,1); tate(j,3); yoko(3,1); tate(j,1); yoko(3,1); } } } printf("%d\n",N); for(i=0;i>4],p[i]>>2&3,p[i]&3); }