#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T>& operator--(vector<T>& v) {
  for (auto& i : v) --i;
  return v;
}
template <typename T>
vector<T>& operator++(vector<T>& v) {
  for (auto& i : v) ++i;
  return v;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& i : v) is >> i;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& i : v) os << i << ' ';
  return os;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
template <typename T, typename U>
void umin(T& a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
void umax(T& a, U b) {
  if (a < b) a = b;
}
const int n = 10;
int main() {
  vector<vector<int>> f(n, vector<int>(n));
  vector<vector<long double>> res(n, vector<long double>(n, 0));
  cin >> f;
  vector<pair<int, int>> snake;
  int x = 0, y = n - 1;
  int dx = 1;
  for (int i = 0; i < n * n; ++i) {
    snake.emplace_back(y, x);
    if (x + 1 == n && dx == 1 || x - 1 == -1 && dx == -1) {
      --y;
      dx *= -1;
    } else {
      x += dx;
    }
  }
  reverse(snake.begin(), snake.end());
  for (int i = 1; i < snake.size(); ++i) {
    int cnt = 0;
    for (int j = 1; j <= 6; ++j) {
      if (i - j < 0) break;
      ++cnt;
      auto [y, x] = snake[i - j];
      res[snake[i].first][snake[i].second] +=
          min(res[y][x], res[y - f[y][x]][x]);
    }
    res[snake[i].first][snake[i].second] =
        (res[snake[i].first][snake[i].second] + 6) / cnt;
  }
  cout << fixed << setprecision(20) << res[n - 1][0] << '\n';
  return 0;
}
