#include <bits/stdc++.h>
using namespace std;
int n, w1, w2, w3, w4, tot, m, i, j, k, a[7855][7855], id1[105][105], f[7855],
    cnt, mod = 1e9 + 7;
void inc(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
void dec(int &x, int y) {
  x -= y;
  if (x < 0) x += mod;
}
int qp(int x, int y) {
  int z = 1;
  while (y) {
    if (y & 1) z = 1ll * z * x % mod;
    x = 1ll * x * x % mod;
    y /= 2;
  }
  return z;
}
int id(int x, int y) {
  if (x * x + y * y > n * n) return cnt;
  return id1[x + n][y + n];
}
int main() {
  scanf("%d%d%d%d%d", &n, &w1, &w2, &w3, &w4);
  tot = (0ll + w1 + w2 + w3 + w4) % mod;
  w1 = 1ll * qp(tot, mod - 2) * w1 % mod;
  w2 = 1ll * qp(tot, mod - 2) * w2 % mod;
  w3 = 1ll * qp(tot, mod - 2) * w3 % mod;
  w4 = 1ll * qp(tot, mod - 2) * w4 % mod;
  for (i = -n; i <= n; i++) {
    for (j = -n; j <= n; j++)
      if (i * i + j * j <= n * n) {
        id1[i + n][j + n] = ++cnt;
      }
  }
  cnt++;
  for (i = -n; i <= n; i++) {
    for (j = -n; j <= n; j++)
      if (i * i + j * j <= n * n) {
        a[id(i, j)][id(i, j)] = a[id(i, j)][cnt + 1] = 1;
        dec(a[id(i, j)][id(i - 1, j)], w1);
        dec(a[id(i, j)][id(i, j - 1)], w2);
        dec(a[id(i, j)][id(i + 1, j)], w3);
        dec(a[id(i, j)][id(i, j + 1)], w4);
      }
  }
  a[cnt][cnt] = 1;
  for ((i) = 1; (i) <= (cnt); ++(i)) {
    for ((j) = (i + 1); (j) <= (cnt); ++(j))
      if (a[j][i]) {
        int t = 1ll * (mod - a[j][i]) * qp(a[i][i], mod - 2) % mod;
        for ((k) = (i); (k) <= (min(cnt, i + n + n + 2)); ++(k)) {
          a[j][k] = (a[j][k] + 1ll * t * a[i][k]) % mod;
        }
        for ((k) = (cnt + 1); (k) <= (cnt + 1); ++(k)) {
          a[j][k] = (a[j][k] + 1ll * t * a[i][k]) % mod;
        }
      }
  }
  for ((i) = (cnt); (i) >= 1; --(i)) {
    for ((j) = (i + 1); (j) <= (cnt); ++(j)) {
      dec(a[i][cnt + 1], 1ll * f[j] * a[i][j] % mod);
    }
    f[i] = 1ll * a[i][cnt + 1] * qp(a[i][i], mod - 2) % mod;
  }
  cout << f[id(0, 0)] << endl;
  return 0;
}
