Language: C++

#include<bits/stdc++.h>
using namespace std;
#define nn 20
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair

int n,m;
pii link[nn*nn];

int cnt[1<<nn];int dep[nn];int topa[nn],pa[nn];
vector<int> v[nn],c[nn];
void dfs(int x,int p)
{
	dep[x]=dep[p]+1;pa[x]=p;
	for(int i=0;i<v[x].size();i++)
	{
		int y=v[x][i];
		if(y!=p)topa[y]=c[x][i],dfs(y,x);
	}
}


int solve(int x,int y)
{
	int mask=0;
	while(x!=y)
	{
		if(dep[x]<dep[y]) swap(x,y);
		mask|=1<<topa[x],x=pa[x];
	}
	return mask;
}


ll dp_tms[2][1<<nn],dp_val[2][1<<nn];
void add(ll &x,ll y) {x=(x+y)%mod;}
int main()
{
	
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int x,y;scanf("%d%d",&x,&y);x--,y--;
		link[i]=mp(x,y);
		if(i<n) v[x].push_back(y),v[y].push_back(x),c[x].push_back(i-1),c[y].push_back(i-1);
	} 
	
	dfs(0,-1);
	
	for(int i=n;i<=m;i++) cnt[solve(link[i].first,link[i].second)]++;
	
	for(int i=1;i<(1<<nn);i<<=1)
		for(int j=0;j<(1<<nn);j+=i+i)
			for(int k=j;k<j+i;k++)
				cnt[k+i]+=cnt[k];
	
	int now=1;
	dp_val[now][0]=0;dp_tms[now][0]=1;
	
	
	for(int i=1;i<=m;i++)
	{
		now^=1;
		memset(dp_val[now],0,sizeof dp_val[now]);
		memset(dp_tms[now],0,sizeof dp_tms[now]);
		
		for(int j=0;j<(1<<n-1);j++)
		if(dp_tms[now^1][j])
		{
			int can=cnt[j],alr=__builtin_popcount(j);
			can-=(i-alr-1);
			if(can<0) continue;
			
			if(can) add(dp_tms[now][j],dp_tms[now^1][j]*can),
					add(dp_val[now][j],dp_val[now^1][j]*can);
			
			int s=((1<<n-1)-1)^j;
			while(s)
			{
				int k=s&-s;s-=k;int e=j|k;
				dp_tms[now][e]+=dp_tms[now^1][j];
				if(dp_tms[now][e]>=mod) dp_tms[now][j][k]-=mod;
				dp_val[now][e]+=dp_val[now^1][j];
				add(dp_val[now][e],dp_tms[now^1][j]*i);
			}
		}
	}
		
	printf("%lld\n",dp_val[now][(1<<n-1)-1]);
	return 0;
}

Compiler output:
a.cc:10:15: error: 'std::pair<int, int> link [400]' redeclared as different kind of entity
   10 | pii link[nn*nn];
      |               ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
a.cc: In function 'int main()':
a.cc:47:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   47 |                 link[i]=mp(x,y);
      |                       ^
a.cc:47:24: error: assignment of read-only location '*(link + ((sizetype)i))'
   47 |                 link[i]=mp(x,y);
      |                 ~~~~~~~^~~~~~~~
a.cc:53:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   53 |         for(int i=n;i<=m;i++) cnt[solve(link[i].first,link[i].second)]++;
      |                                               ^
a.cc:53:49: error: request for member 'first' in '*(link + ((sizetype)i))', which is of non-class type 'int(const char*, const char*) noexcept'
   53 |         for(int i=n;i<=m;i++) cnt[solve(link[i].first,link[i].second)]++;
      |                                                 ^~~~~
a.cc:53:61: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   53 |         for(int i=n;i<=m;i++) cnt[solve(link[i].first,link[i].second)]++;
      |                                                             ^
a.cc:53:63: error: request for member 'second' in '*(link + ((sizetype)i))', which is of non-class type 'int(const char*, const char*) noexcept'
   53 |         for(int i=n;i<=m;i++) cnt[solve(link[i].first,link[i].second)]++;
      |                                                               ^~~~~~
a.cc:85:71: error: invalid types 'long long int[int]' for array subscript
   85 |                                 if(dp_tms[now][e]>=mod) dp_tms[now][j][k]-=mod;
      |                                                                       ^