#include <bits/stdc++.h>
using namespace std;
const int N = 8005, R = 55, mod = 1e9 + 7;
inline int Mod(int x) { return x < mod ? x : x - mod; }
inline int fp(int a, int b) {
  int tot = 1;
  for (; b; a = 1ll * a * a % mod, b >>= 1)
    if (b & 1) tot = 1ll * tot * a % mod;
  return tot;
}
inline int INV(int x) { return fp(x, mod - 2); }
int r, p1, p2, p3, p4, invp, id[R << 1][R << 1], n, a[N][N];
inline int& ID(int x, int y) { return id[x + r][y + r]; }
inline int Guass() {
  int d = r << 1, goal = ID(0, 0);
  for (int i = 1; i <= n; ++i) {
    int inv = INV(a[i][i]);
    for (int j = i + 1; j <= i + d && j <= n; ++j)
      if (a[j][i]) {
        int div = 1ll * a[j][i] * inv % mod;
        for (int k = i; k <= i + d && k <= n; ++k)
          a[j][k] = Mod(a[j][k] + mod - 1ll * a[i][k] * div % mod);
        a[j][n + 1] = Mod(a[j][n + 1] + mod - 1ll * a[i][n + 1] * div % mod);
      }
  }
  for (int i = n; i >= goal; --i) {
    a[i][n + 1] = 1ll * a[i][n + 1] * INV(a[i][i]) % mod;
    for (int j = i - 1; j >= goal; --j)
      a[j][n + 1] = Mod(a[j][n + 1] + mod - 1ll * a[j][i] * a[i][n + 1] % mod);
  }
  return a[goal][n + 1];
}
int main() {
  scanf("%d%d%d%d%d", &r, &p1, &p2, &p3, &p4);
  invp = INV(Mod(Mod(p1 + p2) + Mod(p3 + p4)));
  p1 = 1ll * p1 * invp % mod;
  p2 = 1ll * p2 * invp % mod;
  p3 = 1ll * p3 * invp % mod;
  p4 = 1ll * p4 * invp % mod;
  for (int x = -r; x <= r; ++x)
    for (int y = -r; y <= r; ++y)
      if (x * x + y * y <= r * r) ID(x, y) = ++n;
  for (int x = -r; x <= r; ++x)
    for (int y = -r; y <= r; ++y)
      if (ID(x, y)) {
        int u = ID(x, y);
        a[u][u] = a[u][n + 1] = mod - 1;
        if (ID(x - 1, y)) a[u][ID(x - 1, y)] = p1;
        if (ID(x, y - 1)) a[u][ID(x, y - 1)] = p2;
        if (ID(x + 1, y)) a[u][ID(x + 1, y)] = p3;
        if (ID(x, y + 1)) a[u][ID(x, y + 1)] = p4;
      }
  printf("%d\n", Guass());
  return 0;
}
