macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashSet;

fn main() {
    input!{
        n: usize,
        m: usize,
        k: usize,
        es: [(usize1, usize1); m]
    }
    if k == 1 {
        println!("1");
        return;
    }
    let d = 1000000007;
    let mut stair = vec![1; k + m];
    for i in 1..k + m {
        stair[i] = stair[i - 1] * i % d;
    }
    let stair_i: Vec<usize> = stair.iter().map(|&x| inv_m(x, d)).collect();
    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    for &(u, v) in &es {
        g[u].push(v);
        g[v].push(u);
    }
    let bcs = biconnect(&g);
    let bcs_f: Vec<HashSet<(usize, usize)>> = bcs.iter().cloned().filter(|s| s.len() > 1).collect();
    let mut ans = pow_m(k, bcs.len() - bcs_f.len(), d);
    for bc in &bcs_f {
        let mut g2 = vec![vec![]; n];
        let mut vs = HashSet::new();
        for &(u, v) in bc.iter() {
            g2[u].push(v);
            g2[v].push(u);
            vs.insert(u);
            vs.insert(v);
        }
        let mut cycle = true;
        for &v in vs.iter() {
            if g2[v].len() != 2 {
                cycle = false;
                break;
            }
        }
        let l = bc.len();
        let mut t;
        if cycle {
            t = pow_m(k, l, d);
            for i in 1..l {
                t = (t + pow_m(k, gcd(i, l), d)) % d;
            }
            t = t * inv_m(l, d) % d;
        } else {
            t = stair[k + l - 1] * stair_i[l] % d * stair_i[k - 1] % d;
        }
        ans = ans * t % d;
    }
    println!("{}", ans);
}

fn biconnect(g: &Vec<Vec<usize>>) -> Vec<HashSet<(usize, usize)>> {
    let n = g.len();
    let mut pre = vec![n; n];
    let mut low = vec![n; n];
    let mut bcs = vec![];
    let mut tmp = vec![];
    for i in 0..n {
        if pre[i] != n {
            continue;
        }
        pre[i] = 0;
        low[i] = 0;
        biconnect_dfs(i, i, 0, g, &mut pre, &mut low, &mut bcs, &mut tmp);
    }
    bcs
}

fn biconnect_dfs(r: usize, p: usize, mut next: usize, g: &Vec<Vec<usize>>, pre: &mut Vec<usize>, low: &mut Vec<usize>, bcs: &mut Vec<HashSet<(usize, usize)>>, tmp: &mut Vec<(usize, usize)>) {
    if r != p && g[r].len() == 1 {
        return;
    }
    let n = g.len();
    for &c in &g[r] {
        if c == p || pre[c] < n && pre[c] > pre[r] {
            continue;
        }
        tmp.push((r, c));
        if pre[c] == n {
            next += 1;
            pre[c] = next;
            low[c] = pre[c];
            biconnect_dfs(c ,r, next, g, pre, low, bcs, tmp);
            low[r] = min(low[r], low[c]);
        } else {
            low[r] = min(low[r], pre[c]);
        }
        if low[c] >= pre[r] {
            let mut s = HashSet::new();
            while let Some(e) = tmp.pop() {
                s.insert(e);
                if e.0 == r {
                    break;
                }
            }
            bcs.push(s);
        }
    }
}

fn gcd(n: usize, m: usize) -> usize {
    let mut l = min(n, m);
    let mut r = max(n, m);
    while l > 0 {
        let t = l;
        l = r % l;
        r = t;
    }
    r
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


Measured memory_bytes: 4352