#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int Num[110][110], c[8010];
set<int> s[7855];
int Pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (long long)ans * a % mod;
    a = (long long)a * a % mod;
    b >>= 1;
  }
  return ans;
}
int R, a[10], cnt = 0, p = 0;
int b[7855][7855];
int yh[10] = {-1, 0, 1, 0};
int yl[10] = {0, 1, 0, -1};
void solve() {
  int k = 1;
  for (int i = 1; i <= cnt; i++) {
    int Id = 0;
    for (int j = k; j <= cnt; j++)
      if (b[j][i]) {
        Id = j;
        break;
      }
    if (!Id) continue;
    for (int j = i; j <= cnt + 1; j++) swap(b[k][j], b[Id][j]);
    swap(c[k], c[Id]);
    for (int j = k + 1; j <= cnt; j++) {
      if (!b[j][i]) continue;
      int t = (long long)b[j][i] * Pow(b[k][i], mod - 2) % mod;
      set<int>::iterator it = s[c[k]].begin();
      for (; it != s[c[k]].end(); it++) {
        int y = *it, be = b[j][y];
        (b[j][y] -= (long long)b[k][y] * t % mod) %= mod;
        (b[j][y] += mod) %= mod;
        if (be == 0 && b[j][y] != 0) s[c[j]].insert(y);
        if (be != 0 && b[j][y] == 0) s[c[j]].erase(y);
      }
      int y = cnt + 1;
      (b[j][y] -= (long long)b[k][y] * t % mod) %= mod;
      (b[j][y] += mod) %= mod;
    }
    s[c[k]].clear();
    k++;
  }
  for (int i = cnt; i >= 1; i--) {
    for (int j = i + 1; j <= cnt; j++) {
      int y = b[j][cnt + 1];
      (b[i][cnt + 1] -= (long long)b[i][j] * y % mod) %= mod;
      (b[i][cnt + 1] += mod) %= mod;
    }
    b[i][cnt + 1] = ((long long)b[i][cnt + 1] * Pow(b[i][i], mod - 2)) % mod;
  }
}
int main() {
  scanf("%d", &R);
  for (int i = 0; i < 4; i++) scanf("%d", &a[i]), (p += a[i]) %= mod;
  p = Pow(p, mod - 2);
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++)
      if (i * i + j * j <= R * R) Num[i + 50][j + 50] = ++cnt;
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++) {
      if (Num[i + 50][j + 50] == 0) continue;
      int x = Num[i + 50][j + 50];
      b[x][x] = 1;
      b[x][cnt + 1] = 1;
      s[x].insert(x);
      c[x] = x;
      for (int k = 0; k < 4; k++) {
        int tx = i + yh[k], ty = j + yl[k], y = Num[tx + 50][ty + 50];
        if (!y) continue;
        b[x][y] = -(long long)a[k] * p % mod;
        (b[x][y] += mod) %= mod;
        s[x].insert(y);
      }
    }
  solve();
  printf("%d", b[Num[0 + 50][0 + 50]][cnt + 1]);
}
