#pragma GCC target ("sse4") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using Int = long long; const char newl = '\n'; const int MOD = 1e9+7; // sum_{i=0}^{n-1} (ai + b) // m // 0 <= a, b template T sum_of_floor(T n,T m,T a,T b){ T res=0; while(1){ if(a>=m){ res+=(n-1)*n*(a/m)/2; res%=MOD; a%=m; } if(b>=m){ res+=n*(b/m); res%=MOD; b%=m; } T y=(a*n+b)/m; T x=y*m-b; if(y==0) return res; res+=(n-(x+a-1)/a)*y; res%=MOD; T nn=y; T nm=a; T na=m; T nb=(a-x%a)%a; n=nn; m=nm; a=na; b=nb; } return res; } //INSERT ABOVE HERE const int MAX = 2020; int as[MAX]; int bs[MAX]; signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n,m; cin>>n>>m; for(int i=0;i>as[i]; for(int j=0;j>bs[j]; vector ans(m); for(int i=0;i(bs[j]+1,bs[j],as[i],0); ans[j]%=MOD; } } long long res=0; for(int j=0;j