#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
long long int a1, a2, a3, a4, r, p1, p2, p3, p4, size, backX[10005],
    backY[10005];
int a[7900][7900];
int id[1000007];
inline long long int min(long long int x, long long int y) {
  return x < y ? x : y;
}
inline long long int max(long long int x, long long int y) {
  return x > y ? x : y;
}
template <class T>
inline void add(T& x, long long int y) {
  x = (x + y) % 1000000007;
}
inline long long int qpow(long long int x, long long int y) {
  long long int ans = 1, base = x;
  while (y) {
    if (y & 1) ans = ans * base % 1000000007;
    base = base * base % 1000000007;
    y >>= 1;
  }
  return ans;
}
inline long long int M(long long int x, long long int y) {
  return ((x + 13131) * 1313 + (y + 13131)) % 1000007;
}
inline void insert(int x, int y) {
  a[id[M(x, y)]][id[M(x, y)]] = 1;
  if (id[M(x - 1, y)]) a[id[M(x, y)]][id[M(x - 1, y)]] = 1000000007 - p1;
  if (id[M(x, y - 1)]) a[id[M(x, y)]][id[M(x, y - 1)]] = 1000000007 - p2;
  if (id[M(x + 1, y)]) a[id[M(x, y)]][id[M(x + 1, y)]] = 1000000007 - p3;
  if (id[M(x, y + 1)]) a[id[M(x, y)]][id[M(x, y + 1)]] = 1000000007 - p4;
}
inline void addTo(int x, int y, long long int c, int L, int R) {
  for (int i = L; i <= R; ++i)
    if (a[x][i]) add(a[y][i], a[x][i] * c % 1000000007);
  add(a[y][size + 1], a[x][size + 1] * c % 1000000007);
}
void solve() {
  for (int i = r; i >= -r; --i)
    for (int j = -r; j <= r; ++j)
      if (i * i + j * j <= r * r) {
        id[M(i, j)] = ++size;
        backX[size] = i;
        backY[size] = j;
      }
  for (int i = r; i >= -r; --i)
    for (int j = -r; j <= r; ++j)
      if (id[M(i, j)]) insert(i, j);
  for (int i = 1; i <= size; ++i) a[i][size + 1] = 1;
  for (int i = 1; i <= size; ++i) {
    for (int j = i; j <= min(size, i + r * 2); ++j) {
      if (i == j) continue;
      if (a[j][i])
        addTo(i, j,
              1000000007 - a[j][i] * qpow(a[i][i], 1000000007 - 2) % 1000000007,
              i, min(size, j + r * 2));
    }
  }
  for (int i = size; i >= 1; --i) {
    for (int j = i; j >= max(1, i - r * 2); --j) {
      if (i == j) continue;
      if (a[j][i])
        addTo(i, j,
              1000000007 - a[j][i] * qpow(a[i][i], 1000000007 - 2) % 1000000007,
              max(1, j - r * 2), i);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> r >> a1 >> a2 >> a3 >> a4;
  p1 = a1 * qpow(a1 + a2 + a3 + a4, 1000000007 - 2) % 1000000007;
  p2 = a2 * qpow(a1 + a2 + a3 + a4, 1000000007 - 2) % 1000000007;
  p3 = a3 * qpow(a1 + a2 + a3 + a4, 1000000007 - 2) % 1000000007;
  p4 = a4 * qpow(a1 + a2 + a3 + a4, 1000000007 - 2) % 1000000007;
  solve();
  cout << a[id[M(0, 0)]][size + 1] *
              qpow(a[id[M(0, 0)]][id[M(0, 0)]], 1000000007 - 2) % 1000000007
       << endl;
  return 0;
}
