#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}
template <typename T>
bool chmax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}
const long long P = 1000000007;
long long qpow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) (r *= a) %= P;
    (a *= a) %= P;
    b >>= 1;
  }
  return r;
}
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int maxN = 8000;
int R, a[4];
map<pair<int, int>, int> f;
int of[maxN];
vector<long long> G[maxN];
long long s[maxN], b[maxN];
int main() {
  cin >> R;
  for (int i = 0; i < 4; ++i) cin >> a[i];
  long long sum = accumulate(a, a + 4, 0);
  for (int i = 0; i < 4; ++i) a[i] = a[i] * qpow(sum, P - 2) % P;
  for (int x = -R - 10; x <= R + 10; ++x)
    for (int y = -R - 10; y <= R + 10; ++y)
      if (x * x + y * y <= R * R) f.emplace(pair<int, int>(x, y), f.size());
  int n = f.size();
  memset(G, 0, sizeof(G));
  for (auto p : f) {
    int x = p.first.first, y = p.first.second;
    int id = p.second;
    of[id] = max(0, id - 2 * R - 5);
    G[id].assign(min(n, id + 2 * R + 5) - of[id], 0);
    G[id][id - of[id]] = 1;
    for (int i = 0; i < 4; ++i) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx * nx + ny * ny <= R * R) {
        (G[id][f[pair<int, int>(nx, ny)] - of[id]] -= a[i]) %= P;
      }
    }
    b[id] = 1;
  }
  for (int i = 0; i < n; ++i) {
    assert(G[i][i - of[i]] != 0);
    for (int j = i + 1; j < n; ++j)
      if (of[j] <= i) {
        long long coef = qpow(G[i][i - of[i]], P - 2) * G[j][i - of[j]] % P;
        if (coef == 0) continue;
        for (int k = i; k < of[i] + (int)G[i].size(); ++k)
          (G[j][k - of[j]] -= G[i][k - of[i]] * coef) %= P;
        (b[j] -= b[i] * coef) %= P;
      }
  }
  for (int i = n - 1; i >= 0; --i) {
    for (int j = i + 1; j < of[i] + (int)G[i].size(); ++j)
      (b[i] -= s[j] * G[i][j - of[i]]) %= P;
    s[i] = b[i] * qpow(G[i][i - of[i]], P - 2) % P;
  }
  long long ans = s[f[pair<int, int>(0, 0)]];
  ans = (ans % P + P) % P;
  cout << ans << endl;
  return 0;
}
