#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline int pow(int x, int k) {
  int sum = 1;
  for (; k; k >>= 1, x = 1LL * x * x % 1000000007)
    if (k & 1) sum = 1LL * sum * x % 1000000007;
  return sum;
}
int a[7900 + 5][7900 + 5], res[7900 + 5];
int R, a1, a2, a3, a4, cnt, id[105][105], ans;
inline int& ID(int x, int y) { return id[x + R + 1][y + R + 1]; }
void Gauss() {
  for (int i = 1; i <= cnt; ++i) {
    for (int j = i; j <= cnt && j <= i + 100; ++j)
      if (a[j][i]) {
        if (j != i) {
          for (int k = i; k <= cnt && k <= i + 100; ++k) swap(a[i][k], a[j][k]);
          swap(a[i][cnt + 1], a[j][cnt + 1]);
        }
        break;
      }
    if (!a[i][i]) continue;
    int Inv = pow(a[i][i], 1000000007 - 2);
    for (int j = i + 1; j <= cnt && j <= i + 100; ++j)
      if (a[j][i]) {
        int t = 1LL * Inv * a[j][i] % 1000000007;
        for (int k = i; k <= cnt && k <= i + 100; ++k)
          a[j][k] = (a[j][k] - 1LL * a[i][k] * t % 1000000007 + 1000000007) %
                    1000000007;
        a[j][cnt + 1] = (a[j][cnt + 1] - 1LL * a[i][cnt + 1] * t % 1000000007 +
                         1000000007) %
                        1000000007;
      }
  }
  for (int i = cnt; i; --i) {
    int t = a[i][cnt + 1];
    for (int j = i + 1; j <= cnt && j <= i + 100; ++j)
      t = (t - 1LL * a[i][j] * res[j] % 1000000007 + 1000000007) % 1000000007;
    res[i] = 1LL * t * pow(a[i][i], 1000000007 - 2) % 1000000007;
  }
  ans = res[ID(0, 0)];
}
int main() {
  R = read();
  a1 = read();
  a2 = read();
  a3 = read();
  a4 = read();
  int inv = pow(a1 + a2 + a3 + a4, 1000000007 - 2);
  for (int i = -R; i <= R; ++i)
    for (int j = -R; j <= R; ++j)
      if (i * i + j * j <= R * R) ID(i, j) = ++cnt, a[cnt][cnt] = 1;
  a[ID(0, 0)][cnt + 1] = 1;
  for (int i = -R; i <= R; ++i)
    for (int j = -R; j <= R; ++j)
      if (i * i + j * j <= R * R) {
        if (ID(i - 1, j))
          a[ID(i - 1, j)][ID(i, j)] = 1000000007 - 1LL * a1 * inv % 1000000007;
        if (ID(i, j - 1))
          a[ID(i, j - 1)][ID(i, j)] = 1000000007 - 1LL * a2 * inv % 1000000007;
        if (ID(i + 1, j))
          a[ID(i + 1, j)][ID(i, j)] = 1000000007 - 1LL * a3 * inv % 1000000007;
        if (ID(i, j + 1))
          a[ID(i, j + 1)][ID(i, j)] = 1000000007 - 1LL * a4 * inv % 1000000007;
        a[ID(i, j)][cnt + 1] = 1;
      }
  Gauss();
  cout << ans;
  return 0;
}
