#include <bits/stdc++.h>
using namespace std;
const int maxn = 13, n = 10;
const double INF = 1e17;
pair<int, int> a[maxn], v[maxn][maxn];
double dp[maxn][maxn][2];
pair<int, int> pre(const pair<int, int> &p) {
  if (p.first & 1)
    return p.second == n ? pair<int, int>(p.first + 1, n)
                         : pair<int, int>(p.first, p.second + 1);
  else
    return p.second == 1 ? pair<int, int>(p.first + 1, 1)
                         : pair<int, int>(p.first, p.second - 1);
}
pair<int, int> nxt(const pair<int, int> &p) {
  if (p.first & 1)
    return p.second == 1 ? pair<int, int>(p.first - 1, 1)
                         : pair<int, int>(p.first, p.second - 1);
  else
    return p.second == n ? pair<int, int>(p.first - 1, n)
                         : pair<int, int>(p.first, p.second + 1);
}
int main() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int x;
      scanf("%d", &x);
      if (x) v[i][j] = pair<int, int>(i - x, j);
    }
  }
  for (pair<int, int> i(1, 2); i.first <= n; i = pre(i)) {
    int cnt = 0;
    pair<int, int> x = nxt(i);
    for (int j = 1; j <= 6 && x.first >= 1 && x.second >= 1; j++, x = nxt(x))
      a[++cnt] = x;
    for (int j = 1; j <= cnt; j++)
      dp[i.first][i.second][0] +=
          min(dp[a[j].first][a[j].second][0], dp[a[j].first][a[j].second][1]);
    dp[i.first][i.second][0] = (dp[i.first][i.second][0] + 6) / cnt;
    dp[i.first][i.second][1] = INF;
    pair<int, int> j = v[i.first][i.second];
    if (j.first)
      dp[i.first][i.second][1] =
          min(dp[i.first][i.second][1], dp[j.first][j.second][0]);
  }
  printf("%.10lf\n", dp[n][1][0]);
  return 0;
}
