#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int MOD = 1000000007;
int r, tot, a[5], b[8150][8150], p[5];
int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
map<pair<int, int>, int> q;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    (x *= 10) += ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long fast_power(long long x, long long k) {
  int res = 1;
  while (k) {
    if (k & 1) res = 1ll * res * x % MOD;
    x = 1ll * x * x % MOD;
    k >>= 1;
  }
  return res;
}
inline bool in_map(int x, int y) { return !(abs(x * x + y * y) > r * r); }
inline bool onedge(int x, int y) {
  if (in_map(x, y)) return 0;
  for (register int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (in_map(xx, yy)) return 1;
  }
  return 0;
}
void gauss() {
  int inv;
  for (register int i = 1; i <= tot; i++) {
    inv = fast_power(b[i][i], MOD - 2);
    for (register int j = i + 1; j <= tot + 1; j++)
      b[i][j] = 1ll * b[i][j] * inv % MOD;
    b[i][i] = 1;
    for (register int j = i + 1, lim = min(tot, i + 2 + 2 * r); j <= lim; j++) {
      for (register int k = i + 1, lim = min(tot, i + 2 + 2 * r); k <= lim; k++)
        b[j][k] = (b[j][k] - 1ll * b[j][i] * b[i][k] % MOD + MOD) % MOD;
      b[j][tot + 1] =
          (b[j][tot + 1] - 1ll * b[j][i] * b[i][tot + 1] % MOD + MOD) % MOD;
      b[j][i] = 0;
    }
  }
  for (register int i = tot; i >= 1; i--)
    for (register int j = tot; j > i; j--)
      b[i][tot + 1] =
          (b[i][tot + 1] - 1ll * b[i][j] * b[j][tot + 1] % MOD + MOD) % MOD,
                 b[i][j] = 0;
}
void init() {
  for (register int i = -r - 1; i <= r + 1; i++)
    for (register int j = -r - 1; j <= r + 1; j++)
      if (onedge(i, j) || in_map(i, j)) q[make_pair(i, j)] = ++tot;
  for (register int i = 1; i <= 4; i++)
    p[i] = 1ll * a[i] *
           fast_power(((long long)a[1] + a[2] + a[3] + a[4]) % MOD, MOD - 2) %
           MOD;
  for (register int i = -r - 1; i <= r + 1; i++)
    for (register int j = -r - 1; j <= r + 1; j++) {
      if (onedge(i, j))
        b[q[make_pair(i, j)]][q[make_pair(i, j)]] = 1;
      else if (in_map(i, j)) {
        long long sum = 0;
        for (register int k = 0; k < 4; k++) {
          int x = dx[k] + i, y = dy[k] + j;
          sum = 1ll * (sum + p[k + 1]) % MOD;
          b[q[make_pair(i, j)]][q[make_pair(x, y)]] = p[k + 1];
        }
        b[q[make_pair(i, j)]][tot + 1] = MOD - sum;
        b[q[make_pair(i, j)]][q[make_pair(i, j)]] = MOD - 1;
      }
    }
}
signed main() {
  r = read();
  for (register int i = 1; i <= 4; i++) a[i] = read();
  init();
  gauss();
  printf("%d\n", b[q[make_pair(0, 0)]][tot + 1]);
  return 0;
}
