#include <bits/stdc++.h>
using namespace std;
int in(char &c) { return scanf("%c", &c); }
int in(char s[]) { return scanf("%s", s); }
int in(int &x) { return scanf("%d", &x); }
int in(long long &x) { return scanf("%lld", &x); }
int in(double &x) { return scanf("%lf", &x); }
int in(pair<int, int> &p) { return scanf("%d%d", &p.first, &p.second); }
int in(pair<long long, long long> &p) {
  return scanf("%lld%lld", &p.first, &p.second);
}
int in(pair<double, double> &p) { return scanf("%lf%lf", &p.first, &p.second); }
int in(long double &a) { return scanf("%Lf", &a); }
int in(int &x, long long &y) { return scanf("%d%lld", &x, &y); }
int in(long long &x, int &y) { return scanf("%lld%d", &x, &y); }
int in(int &x, int &y) { return scanf("%d%d", &x, &y); }
int in(long long &x, long long &y) { return scanf("%lld%lld", &x, &y); }
int in(char s[], int &n) { return scanf("%s%d", s, &n); }
int in(int &n, char s[]) { return scanf("%d%s", &n, s); }
int in(char a[], char b[]) { return scanf("%s%s", a, b); }
int in(double &x, double &y) { return scanf("%lf%lf", &x, &y); }
int in(int &n, char s[], char t[]) { return scanf("%d%s%s", &n, s, t); }
int in(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); }
int in(long long &x, long long &y, long long &z) {
  return scanf("%lld%lld%lld", &x, &y, &z);
}
int in(double &x, double &y, double &z) {
  return scanf("%lf%lf%lf", &x, &y, &z);
}
int in(int &x, int &y, int &z, int &k) {
  return scanf("%d%d%d%d", &x, &y, &z, &k);
}
int in(long long &x, long long &y, long long &z, long long &k) {
  return scanf("%lld%lld%lld%lld", &x, &y, &z, &k);
}
int in(double &x, double &y, double &z, double &k) {
  return scanf("%lf%lf%lf%lf", &x, &y, &z, &k);
}
const int N = 1e4 + 10, M = 7845 + 10, mod = 1e9 + 7;
const double eps = 1e-6, Pi = acos(-1.0);
int R, p[4], mat[M][M], ans[M], Hash[N], ncnt, zero[N];
int nextx[] = {-1, 0, 1, 0, 0};
int nexty[] = {0, -1, 0, 1, 0};
int dis(int x, int y) { return (x * x) + (y * y); }
int getId(int x, int y) {
  int t = (x + R) * (R << 1 | 1) + (y + R);
  return Hash[t] ? Hash[t] : Hash[t] = ++ncnt;
}
long long quick_pow(long long a, long long x) {
  long long ans = 1;
  a %= mod;
  while (x) {
    if (x & 1) ans = (ans * a) % mod;
    x >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
long long inv(long long x) { return quick_pow(x, mod - 2); }
int Guass(int n) {
  int flag = 1;
  for (int i = 1; i <= n; i++) {
    int tmp = inv(mat[i][i]);
    for (int j = i; j <= n + 1; j++) mat[i][j] = 1ll * mat[i][j] * tmp % mod;
    for (int j = i + 1, t1 = 1; j <= n && t1 <= (R << 1 | 1); j++, t1++) {
      tmp = mat[j][i];
      if (tmp) {
        mat[j][n + 1] =
            (mat[j][n + 1] - 1ll * tmp * mat[i][n + 1] % mod + mod) % mod;
        for (int k = i, t2 = 1; k <= n && t2 <= (R << 1 | 1); k++, t2++)
          mat[j][k] = (mat[j][k] - 1ll * mat[i][k] * tmp % mod + mod) % mod;
      }
    }
  }
  ans[n] = mat[n][n + 1];
  for (int i = n - 1; i >= 1; i--) {
    ans[i] = mat[i][n + 1];
    for (int j = i + 1; j <= n; j++)
      ans[i] = (ans[i] - 1ll * mat[i][j] * ans[j] % mod + mod) % mod;
  }
  int id = getId(0, 0);
  return ans[id];
}
int main() {
  in(R);
  int s = 0;
  for (int i = 0; i < 4; i++) {
    in(p[i]);
    s += p[i];
  }
  s = inv(s);
  for (int i = 0; i < 4; i++) {
    p[i] = 1ll * s * p[i] % mod;
  }
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++)
      if (dis(i, j) <= R * R) getId(i, j);
  for (int i = -R; i <= R; i++) {
    for (int j = -R; j <= R; j++) {
      if (dis(i, j) <= R * R) {
        int l, r;
        l = r = getId(i, j);
        for (int k = 0, x, y; k < 4; k++) {
          x = i + nextx[k];
          y = j + nexty[k];
          if (dis(x, y) <= R * R) {
            mat[getId(i, j)][getId(x, y)] = (mod - p[k]);
          }
        }
        mat[getId(i, j)][getId(i, j)] = 1;
        mat[getId(i, j)][ncnt + 1] = 1;
      }
    }
  }
  int ans = Guass(ncnt);
  printf("%d\n", ans);
  return 0;
}
