Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
using namespace std;
const int N=1000;
const int mod=1e9+7;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int C[N][N],inv[N],qpow[N];
int head[N],next[N],to[N];
int ans=1,cnt,dfn[N],low[N],st[N],top,col,go[N],pre[N];
inline int gcd(int x,int y) { return y?gcd(y,x%y):x; }
inline int polya(int n) {
	int ans=0;
	for (int i=1;i<=n;i++) ans+=qpow[gcd(i,n)];
	return 1LL*ans*inv[n]%mod;
}
inline void dfs(int k,int fa) {
	dfn[k]=low[k]=++cnt;
	st[++top]=k;
	int s,i;bool flag;
	for (i=head[k];i;i=next[i]) if (to[i]!=fa) {
			if (!dfn[to[i]]) {
				dfs(to[i],k),low[k]=min(low[k],low[to[i]]);
				if (low[to[i]]>=dfn[k]) {
					s=0;flag=false;
					while (1) {
						s+=pre[st[top]]+1,flag|=go[st[top]]>1;
						if (st[top--]==to[i]) break;
					}
					ans=1LL*ans*(s==2?col:(flag?C[s+col-1][col-1]:polya(s)))%mod;
				}
			} else low[k]=min(low[k],dfn[to[i]]),pre[k]+=dfn[to[i]]<dfn[k];
			go[k]+=low[to[i]]<=low[fa];
		}
}
int main()
{
	int n=gi(),m=gi(),i,tot=0,a,b,j;col=gi();
	for (i=2,inv[1]=1;i<=m;i++) inv[i]=mod-1LL*inv[mod%i]*(mod/i)%mod;
	for (i=C[0][0]=1;i<=m+col;i++)
		for (j=C[i][0]=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	for (i=qpow[0]=1;i<=m;i++) qpow[i]=1LL*qpow[i-1]*col%mod;
	while (m--) {
		a=gi(),b=gi();
		to[++tot]=b,next[tot]=head[a],head[a]=tot;
		to[++tot]=a,next[tot]=head[b],head[b]=tot;
	}
	for (i=1;i<=n;i++) if (!dfn[i]) dfs(i,0);
	printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:34:28: error: reference to 'next' is ambiguous
   34 |         for (i=head[k];i;i=next[i]) if (to[i]!=fa) {
      |                            ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:22:13: note:                 'int next [1000]'
   22 | int head[N],next[N],to[N];
      |             ^~~~
a.cc: In function 'int main()':
a.cc:58:29: error: reference to 'next' is ambiguous
   58 |                 to[++tot]=b,next[tot]=head[a],head[a]=tot;
      |                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:22:13: note:                 'int next [1000]'
   22 | int head[N],next[N],to[N];
      |             ^~~~
a.cc:59:29: error: reference to 'next' is ambiguous
   59 |                 to[++tot]=a,next[tot]=head[b],head[b]=tot;
      |                             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:22:13: note:                 'int next [1000]'
   22 | int head[N],next[N],to[N];
      |             ^~~~