#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9 + 7;
int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b) { return 1ll * a * b % Mod; }
void Add(int &a, int b) { a = add(a, b); }
void Dec(int &a, int b) { a = dec(a, b); }
void Mul(int &a, int b) { a = mul(a, b); }
int ksm(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, Mul(a, a))
    if (b & 1) Mul(ans, a);
  return ans;
}
const int N = 105;
int R, p1, p2, p3, p4;
int lm[N], k[N][N][N], b[N][N], a[N][N];
int main() {
  cin >> R >> p1 >> p2 >> p3 >> p4;
  int s = p1 + p2 + p3 + p4;
  s = ksm(s, Mod - 2);
  Mul(p1, s), Mul(p2, s), Mul(p3, s), Mul(p4, s);
  int T = R + 2;
  for (int i = -R; i <= R; i++) {
    lm[i + T] = sqrt(R * R - i * i);
    k[T - lm[i + T]][i + T][i + R] = 1;
  }
  int ip3 = ksm(p3, Mod - 2);
  for (int i = -R + 1; i <= R + 1; i++)
    for (int j = -R; j <= R; j++)
      if (i > -lm[j + T] && i <= lm[j + T] + 1) {
        for (int l = 0; l <= 2 * R; l++) {
          int &c = k[i + T][j + T][l];
          c = k[i + T - 1][j + T][l];
          Dec(c, mul(p2, k[i + T - 1][j + T - 1][l]));
          Dec(c, mul(p4, k[i + T - 1][j + T + 1][l]));
          Dec(c, mul(p1, k[i + T - 2][j + T][l]));
          Mul(c, ip3);
        }
        int &c = b[i + T][j + T];
        c = b[i + T - 1][j + T];
        Dec(c, mul(p2, b[i + T - 1][j + T - 1]));
        Dec(c, mul(p4, b[i + T - 1][j + T + 1]));
        Dec(c, mul(p1, b[i + T - 2][j + T]));
        Dec(c, 1), Mul(c, ip3);
      }
  for (int i = -R; i <= R; i++) {
    for (int l = 0; l <= 2 * R; l++)
      a[i + R][l] = k[T + lm[i + T] + 1][i + T][l];
    a[i + R][R * 2 + 1] = dec(0, b[T + lm[i + T] + 1][i + T]);
  }
  int n = 2 * R;
  for (int i = 0; i <= n; i++) {
    int k = i;
    while (!a[k][i] && k < n) ++k;
    if (k ^ i) swap(a[i], a[k]);
    int iv = ksm(a[i][i], Mod - 2);
    for (int j = i + 1; j <= n; j++) {
      int co = mul(a[j][i], iv);
      for (int k = i; k <= n + 1; k++) Dec(a[j][k], mul(a[i][k], co));
    }
  }
  for (int i = n; ~i; i--) {
    Mul(a[i][n + 1], ksm(a[i][i], Mod - 2));
    for (int j = i - 1; ~j; j--) Dec(a[j][n + 1], mul(a[j][i], a[i][n + 1]));
  }
  int ans = b[T][T];
  for (int i = 0; i <= n; i++) Add(ans, mul(k[T][T][i], a[i][n + 1]));
  cout << ans;
  return 0;
}
