#include <bits/stdc++.h>
using namespace std;

int64_t gcd(int64_t a, int64_t b){
    return b==0 ? a : gcd(b, a%b);
}

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=num; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    seq_inv[0] = 1;
    seq_inv[1] = 1;
    for(int i=2; i<=num; i++){
        seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for(int i=2; i<=num; i++){
        fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
    }
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

typedef pair<int, int> P;

struct LowLink{
    vector<bool> visited;
    vector<int> ord, low;
    vector<int> articulations;
    vector<int> bridges;
    vector<vector<int>> bc;
    vector<int> tmp;
    vector<int> cmp;

    void dfs(int i, int p, int& k, vector<P> edges[]){
        visited[i] = true;
        ord[i] = k++;
        low[i] = ord[i];
        bool art = false;
        int ct = 0;
        for(auto& pr : edges[i]) if(pr.first != p){
            int j = pr.first, e = pr.second;
            if(ord[j] < ord[i]) tmp.push_back(e);
            if(!visited[j]){
                ct++;
                dfs(j, i, k, edges);
                low[i] = min(low[i], low[j]);
                if(p != -1 && ord[i] <= low[j]) art = true;
                if(ord[i] < low[j]) bridges.push_back(e);
                if(ord[i] <= low[j]){
                    bc.push_back({});
                    while(true){
                        int e2 = tmp.back();
                        bc.back().push_back(e2);
                        tmp.pop_back();
                        if(e == e2) break;
                    }
                }
            }else{
                low[i] = min(low[i], ord[j]);
            }
        }

        if(p == -1 && ct > 1) art = true;
        if(art) articulations.push_back(i);
    }

    void calculate(int N, int M, vector<P> edges[]){
        visited.resize(N);
        ord.resize(N, -1);
        low.resize(N, -1);
        cmp.resize(M);
        int k = 0;
        for(int i=0; i<N; i++) if(!visited[i]) dfs(i, -1, k, edges);
        for(int i=0; i<bc.size(); i++) for(int e : bc[i]) cmp[e] = i;
    }
};

int main(){
    int N, M, K, A[100], B[100];
    cin >> N >> M >> K;
    vector<P> edges[50];
    for(int i=0; i<M; i++){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        edges[A[i]].push_back({B[i], i});
        edges[B[i]].push_back({A[i], i});
    }

    LowLink link;
    link.calculate(N, M, edges);
    
    int64_t ans = 1;
    create_mod_tables(200);

    bitset<100> used;
    for(int i=0; i<M; i++){
        if(used[i]) continue;
        set<int> vs;
        int e = 0;
        for(int j=0; j<M; j++) if(link.cmp[i] == link.cmp[j]){
            used[j] = true;
            e++;
            vs.insert(A[j]);
            vs.insert(B[j]);
        }
        int v = vs.size();

        int64_t res = 0;
        if(v == e){
            for(int d=0; d<e; d++) add(res, power_mod(K, gcd(d, e)));
            mul(res, inv_mod(e));
        }else{
            res = comb_mod(e+K-1, e);
        }
        mul(ans, res);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256