#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int sqr(int x) { return x * x; }
vector<pair<int, int> > v;
map<pair<int, int>, int> id;
int m[8000][8000], X[8000];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int cnt;
long long qpow(long long a, long long b) {
  long long ret = 1LL;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
long long inv(long long x) { return qpow(x, mod - 2); }
void CAL() {
  for (int i = 0; i < cnt; ++i) {
    long long x = inv(m[i][i]);
    for (int j = i; j < min(cnt, i + 111); ++j) m[i][j] = m[i][j] * x % mod;
    X[i] = X[i] * x % mod;
    vector<int> O;
    vector<long long> T;
    for (int j = i + 1; j < min(i + 111, cnt); ++j) {
      if (j == i) continue;
      if (!m[j][i]) continue;
      O.push_back(j), T.push_back(m[j][i]);
      X[j] = (X[j] - (long long)X[i] * m[j][i] % mod + mod) % mod;
    }
    for (int j = i; j < min(cnt, i + 111); ++j) {
      if (!m[i][j]) continue;
      for (int k = 0; k < O.size(); ++k)
        m[O[k]][j] = (m[O[k]][j] - T[k] * m[i][j] % mod + mod) % mod;
    }
  }
  for (int i = cnt - 1; i >= 0; --i) {
    for (int j = i - 1; j >= max(0, i - 111); --j) {
      if (m[j][i] == 0) continue;
      X[j] = (X[j] - (long long)X[i] * m[j][i] % mod + mod) % mod;
    }
  }
}
int main() {
  int R, a[4];
  scanf("%d", &R);
  for (int i = 0; i < 4; ++i) scanf("%d", a + i);
  for (int i = 0; i <= 200; ++i) {
    for (int j = 0; j <= 200; ++j) {
      if (sqr(100 - i) + sqr(100 - j) <= sqr(R))
        v.push_back(pair<int, int>(i, j)), id[pair<int, int>(i, j)] = cnt++;
    }
  }
  for (int i = 0; i < cnt; ++i) {
    m[i][i] = 1;
    for (int k = 0; k < 4; ++k) {
      int xx = v[i].first + dx[k];
      int yy = v[i].second + dy[k];
      if (id.find(pair<int, int>(xx, yy)) == id.end()) continue;
      m[i][id[pair<int, int>(xx, yy)]] =
          (mod - a[k] * inv(a[0] + a[1] + a[2] + a[3]) % mod + mod) % mod;
    }
  }
  X[id[pair<int, int>(100, 100)]] = 1;
  CAL();
  long long ans = 0;
  for (int i = 0; i < cnt; ++i) ans = (ans + X[i]) % mod;
  cout << ans << endl;
  return 0;
}
