/*
方法1:数组存储
*/
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 5;
char g[N][N],backup[N][N];
int get(int x,int y){
return x * 4 + y;
}
void turn_one(int x,int y){
if(g[x][y] == '+') g[x][y] = '-';
else g[x][y] = '+';
}
void turn_all(int x,int y){
for(int i = 0;i < 4;++i){
turn_one(i,y);
turn_one(x,i);
}
turn_one(x,y);
}
int main(){
for(int i = 0;i < 4;++i) cin >> g[i];
vector<PII> res;
for(int op = 0;op < 1 << 16;++op){
vector<PII> temp;
memcpy(backup,g,sizeof g);
for(int i = 0;i < 4;++i){
for(int j = 0;j < 4;++j){
if(op >> get(i,j) & 1){
temp.push_back({i,j});
turn_all(i,j);
}
}
}
bool has_closed = false;
for(int i = 0;i < 4;++i){
for(int j = 0;j < 4;++j){
if(g[i][j] == '+') has_closed = true;
}
}
if(has_closed == false){
if(res.empty() || res.size() > temp.size()) res = temp;
}
memcpy(g,backup,sizeof g);
}
cout << res.size() << endl;
for(int i = 0;i < res.size();++i){
cout << res[i].x + 1 << ' ' << res[i].y + 1 << endl;
}
return 0;
}
方法二:位运算
*/
/*#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define x first
#define y second
typedef pair<int, int> PII;
const int N = 100;
int c[N][N];
int get(int x,int y){
return x * 4 + y;
}
int main(){
for(int i = 0;i < 4;++i){
for(int j = 0;j < 4;++j){
for(int k = 0;k < 4;++k)
c[i][j] += (1 << get(i,k)) + (1 << get(k,j));
c[i][j] -= 1 << get(i,j);
}
}
int state = 0;
for(int i = 0;i < 4;++i){
string line;
cin >> line;
for(int j = 0;j < 4;++j){
if(line[j] == '+') state += 1 << get(i,j);
}
}
vector<PII> path;
for(int i = 0;i < 1 << 16;++i){
int now = state;
vector<PII> temp;
for(int j = 0;j < 16;++j){
if(i >> j & 1){
int x = j / 4;
int y = j % 4;
now ^= c[x][y];
temp.push_back({x,y});
}
}
if(!now && (path.empty() || path.size() > temp.size())) path = temp;
}
cout << path.size() << endl;
for(int i = 0;i < path.size();++i){
cout << path[i].x + 1 << ' ' << path[i].y + 1 << endl;
}
return 0;
}