#include <bits/stdc++.h>
using namespace std;
int mat[7905][7905], vecr[7905];
long long R, n, p[4];
long long modpow(long long x, long long n) {
  x = (x % 1000000007 + 1000000007) % 1000000007;
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
    n >>= 1;
  }
  return res;
}
vector<long long> gauss_band(int B) {
  for (int j = 0; j < n; j++) {
    int pivot = -1;
    for (int i = j; i < min((int)n, j + B + 3); i++) {
      if (mat[i][j]) {
        pivot = i;
        break;
      }
    }
    if (pivot == -1) continue;
    for (int g = j; g < min((int)n, j + 2 * B + 3); g++)
      swap(mat[j][g], mat[pivot][g]);
    long long rev = modpow(1LL * mat[j][j], 1000000007 - 2);
    int en = -1;
    for (int i = min((int)n, j + 2 * B + 3) - 1; i >= j; i--)
      if (mat[j][i]) {
        en = i;
        break;
      }
    assert(en >= j);
    for (int i = j + 1; i < min((int)n, j + B + 3); i++) {
      if (mat[i][j]) {
        long long gg = 1LL * mat[i][j] * rev % 1000000007;
        vecr[i] -= 1LL * vecr[j] * gg % 1000000007;
        if (vecr[i] < 0) vecr[i] += 1000000007;
        for (int g = j; g <= en; g++) {
          mat[i][g] -= 1LL * mat[j][g] * gg % 1000000007;
          if (mat[i][g] < 0) mat[i][g] += 1000000007;
        }
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (mat[i][i] == 0) continue;
    long long rev = modpow(1LL * mat[i][i], 1000000007 - 2);
    for (int j = i - 1; j >= max(0, i - 2 * B - 3); j--) {
      if (mat[j][i]) {
        vecr[j] -= 1LL * vecr[i] * rev % 1000000007 * mat[j][i] % 1000000007;
        if (vecr[j] < 0) vecr[j] += 1000000007;
        mat[j][i] = 0;
      }
    }
  }
  vector<long long> ans;
  for (int i = 0; i < n; i++)
    ans.push_back((1LL * vecr[i] % 1000000007 + 1000000007) % 1000000007 *
                  modpow(1LL * mat[i][i], 1000000007 - 2) % 1000000007);
  return ans;
}
int target, nxt;
map<pair<int, int>, int> M;
vector<pair<int, int> > vec;
int main() {
  cin >> R >> p[0] >> p[1] >> p[2] >> p[3];
  long long rev = modpow(p[0] + p[1] + p[2] + p[3], 1000000007 - 2);
  for (int h = 0; h < 4; h++) p[h] = p[h] * rev % 1000000007;
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++) {
      if (i * i + j * j <= R * R) {
        vec.push_back(make_pair(i, j));
        M[make_pair(i, j)] = vec.size() - 1;
        if (i == 0 && j == 0) target = vec.size() - 1;
      }
    }
  n = vec.size();
  int dx[4] = {-1, 0, 1, 0};
  int dy[4] = {0, -1, 0, 1};
  for (int i = -R; i <= R; i++)
    for (int j = -R; j <= R; j++) {
      if (i * i + j * j <= R * R) {
        for (int k = 0; k < 4; k++) {
          int nx = i + dx[k], ny = j + dy[k];
          if (nx * nx + ny * ny <= R * R) {
            mat[M[make_pair(i, j)]][M[make_pair(nx, ny)]] = 1000000007 - p[k];
          }
        }
        mat[M[make_pair(i, j)]][M[make_pair(i, j)]] = 1;
        vecr[M[make_pair(i, j)]] = 1;
      }
    }
  vector<long long> ret = gauss_band(105);
  cout << ret[target] << endl;
}
