#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

static const unsigned MODVAL = 1000000007;
struct mint
{
	unsigned val;
	mint():val(0){}
	mint(int      x):val(x%MODVAL) {}
	mint(unsigned x):val(x%MODVAL) {}
	mint(LL       x):val(x%MODVAL) {}
};
mint& operator+=(mint& x, mint y) { return x = x.val+y.val; }
mint& operator-=(mint& x, mint y) { return x = x.val-y.val+MODVAL; }
mint& operator*=(mint& x, mint y) { return x = LL(x.val)*y.val; }
mint operator+(mint x, mint y) { return x+=y; }
mint operator-(mint x, mint y) { return x-=y; }
mint operator*(mint x, mint y) { return x*=y; }

class BearCavalry { public:
	int countAssignments(vector <int> warriors, vector <int> horses)
	{
		mint total = 0;

		const int W = warriors[0];
		warriors.erase(warriors.begin());
		sort(warriors.begin(), warriors.end());
		sort(horses.begin(), horses.end());

		for(int x=0; x<horses.size(); ++x) {
			const int H = horses[x];
			vector<int> hs(horses.begin(), horses.begin()+x);
			hs.insert(hs.end(), horses.begin()+x+1, horses.end());
			total += cnt(W*H, warriors, hs);
		}
		return total.val;
	}

	mint cnt(int TOP, vector<int> w, vector<int> h)
	{
		mint total = 1;
		for(int i=0; i<w.size(); ++i) {
			int W = w[w.size()-1-i];

			int c=0;
			for(int hk: h)
				c += (hk*W < TOP);
			c -= i;
			if(c <= 0)
				return 0;
			total *= c;
		}
		return total;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, BearCavalry().countAssignments(warriors, horses));}
int main(){

CASE(0)
	int warriors_[] = {5,8,4,8};
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = {19,40,25,20};
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = 2; 
END
CASE(1)
	int warriors_[] = {1,1};
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = {1,1};
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = 0; 
END
CASE(2)
	int warriors_[] = {10,2,10};
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = {100,150,200};
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = 3; 
END
CASE(3)
	int warriors_[] = {10,20};
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = {1,3};
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = 1; 
END
CASE(4)
	int warriors_[] = {20,20,25,23,24,24,21};
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = {20,25,25,20,25,23,20};
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = 0; 
END
CASE(5)
	int warriors_[] = {970,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,
800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800,800};
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = {1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,
1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,
1000,1000,1000,1000,1000,1000,1000,1000,1000,1000};
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = 318608048; 
END
/*
CASE(6)
	int warriors_[] = ;
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = ;
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = ; 
END
CASE(7)
	int warriors_[] = ;
	  vector <int> warriors(warriors_, warriors_+sizeof(warriors_)/sizeof(*warriors_)); 
	int horses_[] = ;
	  vector <int> horses(horses_, horses_+sizeof(horses_)/sizeof(*horses_)); 
	int _ = ; 
END
*/
}
// END CUT HERE
