output_description: Print the number of ways to divide the people into groups under the
  conditions, modulo 10^9+7.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N A B C D
attempt: N, A, B, C, D = map(int, input().split())
  
  memo = {}
  
  
  def factorial(x):
      if x in memo:
          return memo[x]
      if x <= 1:
          ret = 1
      else:
          ret = x * factorial(x - 1)
      memo[x] = ret
      return ret
  
  
  def process(N, groups, total, num, B, C, D):
      if num > B:
          if total != N:
              return 0
          print(groups)
          rest = N
          ret = 1
          for g, n in groups:
              for k in range(n):
                  ret *= factorial(rest) / factorial(g) / factorial(rest - g)
                  rest -= g
              ret //= factorial(n)
          return ret
      ret = 0
      for n in [0] + list(range(C, D + 1)):
          nextTotal = total + num * n
          if nextTotal <= N:
              ret += process(N, groups + [(num, n)], nextTotal, num + 1, B, C, D)
      return ret
  
  
  print(process(N, [], 0, A, B, C, D))
  
problem_description: Statement
  
  There are N people, conveniently numbered 1 through N. We want to divide them
  into some number of groups, under the following two conditions:
  
    * Every group contains between A and B people, inclusive.
  
    * Let F_i be the number of the groups containing exactly i people. Then, for all i, either F_i=0 or C≤F_i≤D holds.
  
  Find the number of these ways to divide the people into groups. Here, two ways
  to divide them into groups is considered different if and only if there exists
  two people such that they belong to the same group in exactly one of the two
  ways. Since the number of these ways can be extremely large, print the count
  modulo 10^9+7.
samples: [{"input": "3 1 3 1 2", "output": "4\n    \n\nThere are four ways to divide the people:\n\n  * (1,2),(3)\n  * (1,3),(2)\n  * (2,3),(1)\n  * (1,2,3)\n\nThe following way to divide the people does not count: (1),(2),(3). This is\nbecause it only satisfies the first condition and not the second.\n\n* * *"}, {"input": "7 2 3 1 3", "output": "105\n    \n\nThe only ways to divide the people under the conditions are the ones where\nthere are two groups of two people, and one group of three people. There are\n105 such ways.\n\n* * *"}, {"input": "1000 1 1000 1 1000", "output": "465231251\n    \n\n* * *"}, {"input": "10 3 4 2 5", "output": "0\n    \n\nThe answer can be 0."}]