#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (ll i = (a); i <= (b); ++i)
#define per(i, a, b) for (ll i = (a); i >= (b); --i)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (register int i = head[x]; i; i = edge[i].nex)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, cnt) memset(a, cnt, sizeof(a))
#define cop(a, b) memcpy(a, b, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter putchar('\n')
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int maxn = 5e3 + 100 ;
const int inf = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const ll mod = 1e9 + 7 ;
const double eps = 1e-7 ;

ll power(ll a, ll b)
{
	ll ret = 1;
	for(; b; b >>= 1, (a *= a) %= mod) if(b & 1) (ret *= a) %= mod;
	return ret;
}

int n, m, k;

int a[maxn][maxn];

int dfn[maxn], low[maxn], cnt, tot;

stack <int> s;

vi edge[maxn], vcc[maxn];

ll ans = 1, c[maxn][maxn];

void init()
{
	ll n = 5e3;
	c[0][0] = 1;
	rep(i, 1, n)
	{
		c[i][0] = 1;
		rep(j, 1, i) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}
}

void tarjan(int now, int fa)
{
	dfn[now] = low[now] = ++ tot;
	s.push(now);
	for(int to : edge[now])
	{
		if(dfn[to])
		{
			low[now] = min(low[now], dfn[to]);
			continue;
		}
		tarjan(to, now);
		low[now] = min(low[now], low[to]);
		if(dfn[now] <= low[to])
		{
			vcc[++ cnt].pb(now);
			for(vcc[cnt].pb(s.top()); s.top() != to; s.pop(), vcc[cnt].pb(s.top()));
			s.pop();
		}
	}
}

ll gcd(ll a, ll b)
{
	return !b ? a : gcd(b, a % b);
}

void calc()
{
	rep(pos, 1, cnt)
	{
		if(siz(vcc[pos]) == 2)
		{
			(ans *= k) %= mod;
			continue;
		}
		int sum = 0;
		for(int i : vcc[pos]) for(int j : vcc[pos]) sum += a[i][j];
		sum >>= 1;
		if(sum != siz(vcc[pos])) (ans *= c[sum + k - 1][k - 1]) %= mod;
		else
		{
			ll ret = 0;
			rep(i, 1, sum) (ret += power(k, gcd(sum, i))) %= mod;
			(ret *= power(sum, mod - 2)) %= mod;
			(ans *= ret) %= mod;
		}
	}
}

signed main()
{
	scanf("%d %d %d", &n, &m, &k);
	init();
	rep(i, 1, m)
	{
		int u, v;
		scanf("%d %d", &u, &v);
		a[u][v] = a[v][u] = 1;
		edge[u].pb(v), edge[v].pb(u);
	}
	rep(i, 1, n) if(!dfn[i]) tarjan(i, i);
	calc();
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 201344