#include <bits/stdc++.h>

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T>
auto make_vector(int n, int m, const T &value){
  return std::vector<std::vector<T>>(n, std::vector<T>(m, value));
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}

/**
 * @title Modint
 * @docs mint.md
 */
template <int32_t M> class ModInt{
public:
  constexpr static int32_t MOD = M;
  uint32_t val;
  
  constexpr ModInt(): val(0){}
  constexpr ModInt(int64_t n){
    if(n >= M) val = n % M;
    else if(n < 0) val = n % M + M;
    else val = n;
  }
  
  constexpr auto& operator=(const ModInt &a){val = a.val; return *this;}
  constexpr auto& operator+=(const ModInt &a){
    if(val + a.val >= M) val = (uint64_t)val + a.val - M;
    else val += a.val;
    return *this;
  }
  constexpr auto& operator-=(const ModInt &a){
    if(val < a.val) val += M;
    val -= a.val;
    return *this;
  }
  constexpr auto& operator*=(const ModInt &a){
    val = (uint64_t)val * a.val % M;
    return *this;
  }
  constexpr auto& operator/=(const ModInt &a){
    val = (uint64_t)val * a.inv().val % M;
    return *this;
  }

  constexpr auto operator+(const ModInt &a) const {return ModInt(*this) += a;}
  constexpr auto operator-(const ModInt &a) const {return ModInt(*this) -= a;}
  constexpr auto operator*(const ModInt &a) const {return ModInt(*this) *= a;}
  constexpr auto operator/(const ModInt &a) const {return ModInt(*this) /= a;}
  
  constexpr bool operator==(const ModInt &a) const {return val == a.val;}
  constexpr bool operator!=(const ModInt &a) const {return val != a.val;}
  
  constexpr auto& operator++(){*this += 1; return *this;}
  constexpr auto& operator--(){*this -= 1; return *this;}
  
  constexpr auto operator++(int){auto t = *this; *this += 1; return t;}
  constexpr auto operator--(int){auto t = *this; *this -= 1; return t;}
  
  constexpr static ModInt power(int64_t n, int64_t p){
    if(p < 0) return power(n, -p).inv();
    
    int64_t ret = 1, e = n % M;
    for(; p; (e *= e) %= M, p >>= 1) if(p & 1) (ret *= e) %= M;
    return ret;
  }
  
  constexpr static ModInt inv(int64_t a){
    int64_t b = M, u = 1, v = 0;
    
    while(b){
      int64_t t = a / b;
      a -= t * b; std::swap(a,b);
      u -= t * v; std::swap(u,v);
    }
    
    u %= M;
    if(u < 0) u += M;
    
    return u;
  }
  
  constexpr static auto frac(int64_t a, int64_t b){return ModInt(a) / ModInt(b);}
  
  constexpr auto power(int64_t p) const {return power(val, p);}
  constexpr auto inv() const {return inv(val);}
  
  friend constexpr auto operator-(const ModInt &a){return ModInt(M-a.val);}
  
  friend constexpr auto operator+(int64_t a, const ModInt &b){return ModInt(a) + b;}
  friend constexpr auto operator-(int64_t a, const ModInt &b){return ModInt(a) - b;}
  friend constexpr auto operator*(int64_t a, const ModInt &b){return ModInt(a) * b;}
  friend constexpr auto operator/(int64_t a, const ModInt &b){return ModInt(a) / b;}
  
  friend std::istream& operator>>(std::istream &s, ModInt<M> &a){s >> a.val; return s;}
  friend std::ostream& operator<<(std::ostream &s, const ModInt<M> &a){s << a.val; return s;}

  template <int N>
  static auto div(){
    static auto value = inv(N);
    return value;
  }

  explicit operator int32_t() const noexcept {return val;}
  explicit operator int64_t() const noexcept {return val;}
};

/**
 * @title Factorial table
 * @docs factorial_table.md
 */
template <typename T>
class FactorialTable{
public:
  using value_type = T;

private:
  std::vector<T> f_table;
  std::vector<T> if_table;

public:
  FactorialTable(int N){
    f_table.assign(N+1, 1);
    if_table.assign(N+1, 1);
    
    for(int i = 1; i <= N; ++i){
      f_table[i] = f_table[i-1] * i;
    }
    
    if_table[N] = f_table[N].inv();

    for(int i = N-1; i >= 0; --i){
      if_table[i] = if_table[i+1] * (i+1);
    }
  }
  
  T factorial(int64_t i) const {
    assert(i < (int)f_table.size());
    return f_table[i];
  }
  
  T inv_factorial(int64_t i) const {
    assert(i < (int)if_table.size());
    return if_table[i];
  }

  T P(int64_t n, int64_t k) const {
    if(n < k or n < 0 or k < 0) return 0;
    return factorial(n) * inv_factorial(n-k);
  }

  T C(int64_t n, int64_t k) const {
    if(n < k or n < 0 or k < 0) return 0;
    return P(n,k) * inv_factorial(k);
  }

  T H(int64_t n, int64_t k) const {
    if(n == 0 and k == 0) return 1;
    return C(n+k-1, k);
  }
};


/**
 * @title Basic graph
 * @docs graph.md
 */
template <typename T>
struct Edge{
  int from, to;
  T cost;
  Edge(){}
  Edge(int from, int to, T cost): from(from), to(to), cost(cost){}
};

template <typename T>
struct Graph{
  using weight_type = T;
  using edge_type = Edge<T>;
  
  std::vector<std::vector<Edge<T>>> data;

  auto& operator[](size_t i){return data[i];}
  const auto& operator[](size_t i) const {return data[i];}
  
  auto begin() const {return data.begin();}
  auto end() const {return data.end();}

  Graph(){}
  Graph(int N): data(N){}

  bool empty() const {return data.empty();}
  int size() const {return data.size();}

  void add_edge(int i, int j, T w){
    data[i].emplace_back(i, j, w);
  }
  
  void add_undirected(int i, int j, T w){
    add_edge(i, j, w);
    add_edge(j, i, w);
  }
};

template <typename T>
using Tree = Graph<T>;


template <typename T>
std::ostream& operator<<(std::ostream &s, const Edge<T> &a){
  s << "(" << a.from << " -> " << a.to << ", " << a.cost << ")";
  return s;
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const Graph<T> &a){
  for(int i = 0; i < (int)a.size(); ++i){
    s << i << " ->";
    for(auto &e : a[i]){
      s << " (" << e.to << ", " << e.cost << ")";
    }
    s << "\n";
  }

  return s;
}



/**
 * @title Articulation points
 * @docs articulation_points.md
 */
template <typename G>
std::vector<int> articulation_points(const G &graph){
  const int n = graph.size();
  std::vector<int> visit(n, -1), low(n, -1), ret;

  int v = 0;
  
  auto dfs =
    [&](auto &&dfs, int root, int cur){
      if(visit[cur] != -1) return visit[cur];
      visit[cur] = v;

      int temp = v;
      std::vector<int> children;
      ++v;

      for(auto &e : graph[cur]){
        if(visit[e.to] == -1) children.push_back(e.to);
        int t = dfs(dfs, e.to);
        temp = std::min(temp, t);
      }

      low[cur] = temp;

      if((cur != root or children.size() >= 2) and std::any_of(children.begin(), children.end(), [&](int x){return low[x] >= visit[cur];})){
        ret.push_back(cur);
      }

      return low[cur];
    };

  
  for(int i = 0; i < n; ++i){
    if(visit[i] == -1){
      dfs(dfs, i, i);
    }
  }

  return ret;
}




template <typename T>
auto biconnected_components(const Graph<T> &g){
  const int n = g.size();

  std::vector<std::vector<Edge<T>>> ret;
  std::stack<Edge<T>> st;

  std::vector<int> low(n, -1), ord(n, -1);
  int t = 0;

  std::vector<bool> check(n);
  
  auto dfs =
    [&](auto &dfs, int cur, int par) -> void {
      check[cur] = true;
      ord[cur] = t;
      low[cur] = t;
      ++t;

      for(auto &e : g[cur]){
        if(e.to == par) continue;
        
        if(ord[e.to] < ord[cur]){
          st.emplace(std::min(e.from, e.to), std::max(e.from, e.to), e.cost);
        }
        if(not check[e.to]){
          dfs(dfs, e.to, cur);
          low[cur] = std::min(low[cur], low[e.to]);
          if(low[e.to] >= ord[cur]){
            ret.emplace_back();
            while(true){
              auto f = st.top(); st.pop();
              ret.back().push_back(f);
              if(f.from == std::min(e.from, e.to) and f.to == std::max(e.from, e.to)) break;
            }
          }
        }else{
          low[cur] = std::min(low[cur], ord[e.to]);
        }
      }
    };

  for(int i = 0; i < n; ++i){
    if(not check[i]) dfs(dfs, i, -1);
  }

  return ret;
}







namespace solver{
  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  using mint = ModInt<1000000007>;
  
  void solve(){
    int N, M, K; std::cin >> N >> M >> K;
    Graph<int> g(N);
    for(int i = 0; i < M; ++i){
      int a, b; std::cin >> a >> b;
      --a, --b;
      g.add_undirected(a, b, 1);
    }
    
    auto bc = biconnected_components(g);

    auto ft = FactorialTable<mint>(10000);

    mint ans = 1;

    for(auto &a : bc){
      dump(a);
      std::set<int> s;
      for(auto &e : a){
        s.insert(e.from);
        s.insert(e.to);
      }

      const size_t n = s.size();
      
      if(a.size() == 1){
        ans *= K;
      }else if(a.size() == n){
        mint t = 0;
        for(size_t i = 0; i < n; ++i){
          t += mint::power(K, std::gcd(n, i));
        }

        t /= n;
        ans *= t;
      }else{
        ans *= ft.H(K, a.size());
      }
    }

    std::cout << ans << "\n";
  }
}

int main(){
  solver::init();
  int test_case = 1;
  while(true){
    try{
      solver::solve();
#ifdef DEBUG
      std::cerr << "[\e[1;34mTest case " << test_case << "\e[m]\n";
#endif
    }catch(const std::istream::failure &e){
      break;
    }
    ++test_case;
  }
  return 0;
}


Measured memory_bytes: 3984