#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
template <typename T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, 1) : 0;
}
template <typename T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, 1) : 0;
}
inline void solve(), read();
const string file = "";
signed main() {
  if (file != "") {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  read();
  solve();
  return 0;
}
const long long R = 1e9 + 7;
const long long MAXC = 52;
const long long MAXN = 7850;
long long binpow(long long n, long long p) {
  n %= R;
  if (p == 0) {
    return 1;
  }
  if (p == 1) {
    return n;
  }
  long long ans = binpow(n, p / 2);
  ans = ans * ans % R;
  if (p % 2 == 1) {
    ans = ans * n % R;
  }
  return ans;
}
long long inv(long long n) { return binpow(n, R - 2); }
long long r, a[4], p[4];
int M[MAXN][MAXN];
vector<pair<long long, long long> > dirs = {{-1, 0}, {0, -1}, {+1, 0}, {0, +1}};
long long zero, fake;
long long id[2 * MAXC][2 * MAXC];
void build() {
  long long cnt = 0;
  for (long long x = -r; x <= r; x++) {
    for (long long y = -r; y <= r; y++) {
      if (x * x + y * y <= r * r) {
        id[x + MAXC][y + MAXC] = ++cnt;
      }
    }
  }
  zero = id[MAXC][MAXC];
  fake = ++cnt;
  for (long long x = -r; x <= r; x++) {
    for (long long y = -r; y <= r; y++) {
      long long v = id[x + MAXC][y + MAXC];
      if (!v) {
        continue;
      }
      M[v][fake] = 1;
      M[v][v] = R - 1;
      for (long long i = 0; i < 4; i++) {
        pair<long long, long long> d = dirs[i];
        long long x_ = x + d.first, y_ = y + d.second;
        long long u = id[x_ + MAXC][y_ + MAXC];
        if (!u) {
          continue;
        }
        M[v][u] = p[i];
      }
    }
  }
}
void gauss() {
  for (long long i = 0; i < fake; i++) {
    vector<long long> near;
    for (long long j = 0; j < fake; j++) {
      if (M[i][j]) {
        near.push_back(j);
      }
    }
    near.push_back(fake);
    long long mi = inv(M[i][i]);
    for (long long q : near) {
      M[i][q] = (M[i][q] * 1ll * mi) % R;
    }
    for (long long j = i; j < fake; j++) {
      if (M[j][i] == 0 || i == j) {
        continue;
      }
      long long k = M[j][i];
      for (long long q : near) {
        M[j][q] = (M[j][q] + R - M[i][q] * 1ll * k % R) % R;
      }
    }
    if (M[zero][i] && zero != i) {
      long long k = M[zero][i];
      for (long long q : near) {
        M[zero][q] = (M[zero][q] + R - M[i][q] * 1ll * k % R) % R;
      }
    }
  }
}
inline void solve() {
  build();
  gauss();
  long long ans = (R - M[zero][fake]) % R;
  cout << ans << "\n";
}
inline void read() {
  cin >> r;
  long long s = 0;
  for (long long i = 0; i < 4; i++) {
    cin >> a[i];
    s += a[i];
  }
  s = inv(s);
  for (long long i = 0; i < 4; i++) {
    p[i] = a[i] * s % R;
  }
}
