#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int c, int ans = 1) {
  for (; b; b >>= 1, a = (long long)a * a % c)
    if (b & 1) ans = (long long)ans * a % c;
  return ans;
}
const int mod = 1000000007;
int inv(int u) {
  return u < 2 ? u : (long long)mod / u * (mod - inv(mod % u)) % mod;
}
int N;
int f[11111][222], g[11111], M = 105;
int I[11111], id[222][222];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
int calc(int R) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++)
      if (f[i][M + j]) {
        if (!j) break;
        swap(I[i], I[i + j]);
        for (int k = i; k <= i + M && k < N; k++) {
          swap(f[k][M + j - (k - i)], f[k][M - (k - i)]);
        }
        break;
      }
    if (!f[i][M]) continue;
    int first = inv(f[i][M]);
    for (int j = 0; j < M; j++)
      f[i][M + j] = (long long)f[i][M + j] * first % mod;
    g[i] = (long long)g[i] * first % mod;
    for (int k = i + 1; k <= i + M && k < N; k++)
      if (f[k][M - (k - i)]) {
        long long c = (mod - f[k][M - (k - i)]) % mod;
        for (int j = 0; j < M; j++)
          f[k][M + j - (k - i)] =
              (f[k][M + j - (k - i)] + c * f[i][M + j]) % mod;
        g[k] = (g[i] * c + g[k]) % mod;
      }
  }
  for (int i = N - 1; i >= 0; i--)
    if (f[i][M]) {
      for (int j = i - 1; j >= i - M && j > 0; j--) {
        if (f[j][M + (i - j)])
          g[j] = (g[j] - (long long)f[j][M + (i - j)] * g[i]) % mod;
      }
      if (I[i] == R) return (g[i] + mod) % mod;
    }
  assert(0);
  return 0;
}
int main() {
  int R, a[4], sum = 0;
  cin >> R;
  for (int i = 0; i < 4; i++) cin >> a[i], sum += a[i];
  for (int i = 0; i < 4; i++) a[i] = (long long)a[i] * inv(sum) % mod;
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++) {
      if (i * i + j * j > R * R) continue;
      id[i + R][j + R] = N++;
    }
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++) {
      if (i * i + j * j > R * R) continue;
      int u = id[i + R][j + R];
      f[u][M] = 1;
      g[u] = 1;
      for (int k = 0; k < 4; k++) {
        int ii = i + dx[k], jj = j + dy[k];
        if (ii * ii + jj * jj > R * R) continue;
        f[u][M + id[ii + R][jj + R] - u] = mod - a[k];
      }
    }
  iota(I, I + N, 0);
  cout << calc(id[R][R]) << endl;
  return 0;
}
