#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}
template <typename T>
inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}
template <typename T>
inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}
const int N = 55;
const int M = 7850;
const int mod = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int n, m, p[4], ans[M], a[M][M];
vector<pair<int, int> > all;
inline int Qow(int x, int y) {
  int r = 1;
  for (; y; y >>= 1, x = 1LL * x * x % mod) {
    if (y & 1) {
      r = 1LL * r * x % mod;
    }
  }
  return r;
}
int main() {
  Read(m);
  for (int i = -m; i <= m; ++i) {
    for (int j = -m; j <= m; ++j) {
      if (i * i + j * j <= m * m) {
        all.push_back(make_pair(i, j));
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < 4; ++i) {
    Read(p[i]), sum += p[i];
  }
  sum = Qow(sum, mod - 2);
  for (int i = 0; i < 4; ++i) {
    p[i] = 1LL * p[i] * sum % mod;
  }
  n = all.size();
  for (int i = 0; i < n; ++i) {
    int x = all[i].first, y = all[i].second;
    a[i][i] = a[i][n] = 1;
    for (int j = 0; j < 4; ++j) {
      int u = x + dx[j], v = y + dy[j];
      if (u * u + v * v <= m * m) {
        a[i][lower_bound(all.begin(), all.end(), make_pair(u, v)) -
             all.begin()] = mod - p[j];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    vector<int> t = {n};
    int u = min(i + (m << 1) + 5, n);
    for (int j = i; j < u; ++j) {
      if (a[i][j]) {
        t.push_back(j);
      }
    }
    int inv = Qow(a[i][i], mod - 2);
    for (int j = i + 1; j < u; ++j) {
      if (a[j][i]) {
        int mul = 1LL * a[j][i] * inv % mod;
        for (auto k : t) {
          a[j][k] = (a[j][k] - 1LL * mul * a[i][k] % mod + mod) % mod;
        }
      }
    }
  }
  for (int i = n - 1; ~i; --i) {
    int val = a[i][n];
    for (int j = i + 1; j < n; ++j) {
      val = (val - 1LL * ans[j] * a[i][j] % mod + mod) % mod;
    }
    ans[i] = 1LL * val * Qow(a[i][i], mod - 2) % mod;
  }
  printf(
      "%d\n",
      ans[lower_bound(all.begin(), all.end(), make_pair(0, 0)) - all.begin()]);
  return 0;
}
