#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<int> a(100, -1);
  vector<double> dp(100, 1.0);
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++) {
      int x;
      cin >> x;
      if (x == 0) continue;
      a[10 * (9 - i) + (i & 1 ? j : 9 - j)] =
          10 * (9 - i + x) + ((i - x) & 1 ? j : 9 - j);
    }
  dp[99] = 0.0;
  dp[98] = dp[97] = dp[96] = dp[95] = dp[94] = 6.0;
  for (int i = 93; i >= 0; i--)
    for (int j = i + 1; j < i + 7; j++)
      dp[i] += (a[j] == -1 ? dp[j] : min(dp[j], dp[a[j]])) / 6.0;
  ;
  cout << setprecision(20) << dp[0] << "\n";
}
