#include using namespace std; using ll=long long; const ll MOD=100000000000000007; int main(){ int n,m; cin>>n>>m; vector x(m); for(int i=0;i>x[i]; sort(x.begin(),x.end()); vector belong(m); for(int i=0;i> dp(m); for(int i=0;ito){ dp[belong[j]][to]+=step; if(dp[belong[j]][to]>=MOD){ dp[belong[j]][to]-=MOD; } } else dp[belong[j]].push_back(step); } } } else{ ll step=dp[0].front(); dp[0].pop_front(); for(int j=0;jto){ dp[belong[j]][to]+=step; if(dp[belong[j]][to]>=MOD){ dp[belong[j]][to]-=MOD; } } else dp[belong[j]].push_back(step); } } } } cout<