#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
const int N = 200200, M = 12, L = 4;
#define inf 0x3f3f3f3f
int a, b;
int c[L][L], p[M], vis[L][L];
int B[L][L] = {{0,0,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,1}};
vector <pair<int ,int>> v1, v2, v3, v4;
int main(){
// freopen("the.in", "r", stdin);
// freopen("the.out", "w", stdout);
for (int i = 1; i <= 3; i ++)
for (int j = 1; j <= 3; j ++)
cin >> c[i][j];
for (int i = 1; i <= 9; i ++) p[i] = i;
// for (int i = 1; i <= 9; i ++) {
// int x = ((p[i] + 2) / 3);
// cout << (p[i] + 2)/ 3 << '\n';
// int y = (p[i] % 3) + (p[i] % 3 == 0) * 3;
// cout << x << ' ' << y << '\n';
// }
// cout << (7 + 2)/ 3 << '\n';
do{
int flag = 0;
memset(vis, 0, sizeof vis);
for (int i = 1; i <= 9; i ++) {
int x = ((p[i] + 2) / 3);
int y = (p[i] % 3) + (p[i] % 3 == 0) * 3;
vis[x][y] = 1;
v1.clear();v2.clear();
v3.clear();v4.clear();
for (int j = 1; j <= 3; j ++)
for (int k = 1; k <= 3; k ++) {
if (j == x && k == y) continue;
if (j == x) v1.push_back({j, k});
if (k == y) v2.push_back({j, k});
if (!B[x][y]) continue;
if ((x + y) == (j + k))
v3.push_back({j, k});
if ((x - y) == (j - k))
v4.push_back({j, k});
}
if (vis[v1[0].first][v1[0].second]&&vis[v1[1].first][v1[1].second]&&c[v1[0].first][v1[0].second]==c[v1[1].first][v1[1].second]&&c[x][y]!=c[v1[1].first][v1[1].second]) flag = 1;
if (vis[v2[0].first][v2[0].second]&&vis[v2[1].first][v2[1].second]&&c[v2[0].first][v2[0].second]==c[v2[1].first][v2[1].second]&&c[x][y]!=c[v2[1].first][v2[1].second]) flag = 1;
if (!B[x][y]) continue;
if (v3.size() && vis[v3[0].first][v3[0].second]&&vis[v3[1].first][v3[1].second]&&c[v3[0].first][v3[0].second]==c[v3[1].first][v3[1].second]&&c[x][y]!=c[v3[1].first][v3[1].second]) flag = 1;
if (v4.size() && vis[v4[0].first][v4[0].second]&&vis[v4[1].first][v4[1].second]&&c[v4[0].first][v4[0].second]==c[v4[1].first][v4[1].second]&&c[x][y]!=c[v4[1].first][v4[1].second]) flag = 1;
}
if (flag) a ++;
b ++;
}
while(next_permutation(p + 1, p + 9 + 1));
double ans = 1.0 * (b - a) / b;
printf("%.11lf\n", ans);
return 0;
}