#include using namespace std; const int INF = 0x3f3f3f3f; typedef long long LL; const int N = 10; char g[N][N]; int dx[] = {-1, 0, 1, 0}; //上右下左 int dy[] = {0, 1, 0, -1}; //上右下左 int main() { int x1, y1, x2, y2; for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) { cin >> g[i][j]; if (g[i][j] == 'C') x1 = i, y1 = j; if (g[i][j] == 'F') x2 = i, y2 = j; } int cd = 0, fd = 0; int cnt = 0; while (true) { int tx = x1 + dx[cd], ty = y1 + dy[cd]; if (tx >= 10 || tx < 0 || ty >= 10 || ty < 0 || g[tx][ty] == '*') cd = (cd + 1) % 4; else x1 = tx, y1 = ty; tx = x2 + dx[fd], ty = y2 + dy[fd]; if (tx >= 10 || tx < 0 || ty >= 10 || ty < 0 || g[tx][ty] == '*') fd = (fd + 1) % 4; else x2 = tx, y2 = ty; cnt++; if (x1 == x2 && y1 == y2) { printf("%d", cnt); break; } if (cnt > 100000) { printf("0"); break; } } return 0; }