#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
struct point
{
int r,c;
}now;
point st[20];
bool graph[6][6] = {false};
char s;
bool falg = false;
int sum;
bool check()
{
int i,j;
for( i = 1; i<5; i++)
for( j = 1; j<5; j++)
if(graph[i][j] == false)
return false;
return true;
}
void flip(int x, int y)
{
int i,j;
for( i = 1; i < 5; i++)
graph[x][i] = !graph[x][i];
for( j = 1; j< 5; j++)
graph[j][y] = !graph[j][y];
graph[x][y] = !graph[x][y];
}
void dfs( int x, int y, int step)
{
if(step == sum)
{
falg = check();
return ;
}
if( falg || x == 5)
return ;
flip(x,y);
if(y < 4)
{
dfs(x,y+1,step+1);
now.r = x;
now.c = y;
st[step] = now;
}
else
{
dfs(x+1,1,step+1);
now.r = x;
now.c = y;
st[step] = now;
}
flip(x,y);
if(y < 4)
dfs(x,y+1,step);
else
dfs(x+1,1,step);
}
int main()
{
sum = 0;
falg = false;
int i,j;
for( i = 1; i<5; i++)
for( j = 1; j<5; j++)
{
cin>>s;
if(s == '+')
graph[i][j] = false;
else
graph[i][j] = true;
// cout<<graph[i][j]<<endl;
}
for(sum = 0; sum<=16; sum++)
{
dfs(1,1,0);
if(falg)
break;
}
cout<<sum<<endl;
for( i = 0 ; i< sum; i++)
{
cout<<st[i].r<<" "<<st[i].c<<endl;
}
}
#include <stdio.h>
#include <string.h>
using namespace std;
struct point
{
int r,c;
}now;
point st[20];
bool graph[6][6] = {false};
char s;
bool falg = false;
int sum;
bool check()
{
int i,j;
for( i = 1; i<5; i++)
for( j = 1; j<5; j++)
if(graph[i][j] == false)
return false;
return true;
}
void flip(int x, int y)
{
int i,j;
for( i = 1; i < 5; i++)
graph[x][i] = !graph[x][i];
for( j = 1; j< 5; j++)
graph[j][y] = !graph[j][y];
graph[x][y] = !graph[x][y];
}
void dfs( int x, int y, int step)
{
if(step == sum)
{
falg = check();
return ;
}
if( falg || x == 5)
return ;
flip(x,y);
if(y < 4)
{
dfs(x,y+1,step+1);
now.r = x;
now.c = y;
st[step] = now;
}
else
{
dfs(x+1,1,step+1);
now.r = x;
now.c = y;
st[step] = now;
}
flip(x,y);
if(y < 4)
dfs(x,y+1,step);
else
dfs(x+1,1,step);
}
int main()
{
sum = 0;
falg = false;
int i,j;
for( i = 1; i<5; i++)
for( j = 1; j<5; j++)
{
cin>>s;
if(s == '+')
graph[i][j] = false;
else
graph[i][j] = true;
// cout<<graph[i][j]<<endl;
}
for(sum = 0; sum<=16; sum++)
{
dfs(1,1,0);
if(falg)
break;
}
cout<<sum<<endl;
for( i = 0 ; i< sum; i++)
{
cout<<st[i].r<<" "<<st[i].c<<endl;
}
}