#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, F = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') F = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  return x * F;
}
int add(int a, int b) {
  return (a + b >= 1000000007) ? a + b - 1000000007 : a + b;
}
int dec(int a, int b) { return (a - b < 0) ? a - b + 1000000007 : a - b; }
int mul(int a, int b) { return 1LL * a * b % 1000000007; }
int fst_pow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
int inv(int a) { return fst_pow(a, 1000000007 - 2); }
int R, sump, cnt, p[100 + 5];
int id[100 + 5][100 + 5], fun[8000 + 5][8000 + 5], ans[8000 + 5], D;
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
pair<int, int> pos[100 * 100 + 5];
double pabs(double x) { return (x < 0) ? -x : x; }
int Gauss(int m, int n) {
  int r = 1, c = 1;
  for (; r <= m && c <= n; r++, c++) {
    if (!fun[r][c]) return -1;
    int v = inv(fun[r][c]);
    for (int i = c; i <= min(c + D, n); i++) fun[r][i] = mul(fun[r][i], v);
    fun[r][n + 1] = mul(fun[r][n + 1], v);
    for (int i = r + 1; i <= min(r + D, m); i++)
      if (fun[i][c]) {
        v = fun[i][c];
        for (int j = c; j <= min(c + D, n); j++)
          fun[i][j] = dec(fun[i][j], mul(fun[r][j], v));
        fun[i][n + 1] = dec(fun[i][n + 1], mul(fun[r][n + 1], v));
      }
  }
  for (int i = r; i <= m; i++)
    if (fun[i][n + 1]) return -1;
  if (c < n) return n - c;
  for (int i = n; i >= 1; i--) {
    int v = fun[i][n + 1];
    for (int j = i + 1; j <= min(n, i + D); j++)
      v = dec(v, mul(ans[j], fun[i][j]));
    ans[i] = v;
  }
  return 0;
}
int main() {
  R = read();
  for (int i = 0; i < 4; i++) p[i] = read(), sump += p[i];
  for (int i = 0; i < 4; i++) p[i] = mul(p[i], inv(sump));
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++)
      if (i * i + j * j <= R * R) {
        id[i + 50][j + 50] = ++cnt;
        pos[cnt] = pair<int, int>(i, j);
      }
  for (int i = 1; i <= cnt; i++) {
    fun[i][i] = dec(0, 1), fun[i][cnt + 1] = dec(0, 1);
    for (int k = 0; k < 4; k++) {
      int nx = pos[i].first + dx[k], ny = pos[i].second + dy[k];
      if (id[nx + 50][ny + 50]) fun[i][id[nx + 50][ny + 50]] = p[k];
    }
  }
  D = (R << 1) + 1;
  Gauss(cnt, cnt);
  printf("%d", ans[id[50][50]]);
}
