/* ############################################################################
* START OF HEADER
* ############################################################################
*/
#include<cstdio>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<set>
#include<map>
using namespace std;
#define LL long long
#define LD long double
#define sc(x) scanf("%c",&x) //char
#define si(x) scanf("%d",&x) //int
#define sf(x) scanf("%f",&x) //float
#define sl(x) scanf("%I64d",&x) //int64_
#define sd(x) scanf("%lf",&x) //double
#define sld(x) scanf("%Lf",&x) //long double
#define slld(x) scanf("%lld",&x) //long long int
#define ss(x) scanf("%s",x) // string
#define pc(x) printf("%c",x)
#define pi(x) printf("%d ",x)
#define pf(x) printf("%f ",x)
#define pl(x) printf("%I64d ",x)
#define pd(x) printf("%lf ",x)
#define pld(x) printf("%Lf ",x)
#define plldn(x) printf("%lldn", x);
#define ps(x) printf("%s", x);
#define pin(x) printf("%d\n",x)
#define pln(x) printf("%I64d\n",x)
#define pfn(x) printf("%f\n",x)
#define pdn(x) printf("%lf\n",x)
#define pldn(x) printf("%Lf\n",x)
#define plld(x) printf("%lld\n", x);
#define psn(x) printf("%s\n",x)
#define pn() printf("\n")
#define _p() printf(" ")
#define MODVAL 1000000007
#define FORab(i,a,b) for(int i=a;i<=b;i++)
#define REVab(i,a,b) for(int i=a;i>=b;i--)
#define FORn(i,n) for(i=0;i<n;i++)
#define REVn(i,n) for(int i=n;i>=0;i--)
#define FORSTL(it, a) for(it=a.begin(); it!=a.end(); it++)
#define REVSTL(it, a) for(it=a.end(); it!=a.begin(); it--)
#define MEM(a,v) memset(a,v,sizeof(a))
#define MAX(x,y) (x)>(y)?(x):(y)
#define MIN(x,y) (x)<(y)?(x):(y)
#define pb push_back
#define pob pop_back
#define b() begin()
#define e() end()
#define s() size()
#define cl() clear()
#define fi first
#define se second
#define INF (1000000000)
#define SZ 100000
#define MOD (1<<30)
#define VS vector<string>
#define VI vector<int>
#define VF vector<float>
#define VD vector<double>
#define MII map<int,int>
#define MIS map<int, string>
#define MSI map<string, int>
#define MSS map<string, string>
#define VSI vector<string>::iterator
#define VII vector<int>:iterator
#define VFI vector<float>::iterator
#define VDI vector<double>::iterator
#define MIII map<int,int>::iterator
#define MISI map<int, string>::iterator
#define MSII map<string, int>::iterator
#define MSSI map<string, string>::iterator
#define print_array(x,n) { for(int i=0; i<n; i++) { cout << x[i] << " " ; } cout << endl; }
#define TEST int T;scanf("%d",&T);while(T--)
#define CASES int N;scanf("%d",&N);while(N--)
/* ############################################################################
* END OF HEADER
* ############################################################################
*/
#define MXN 3001
bool visit[MXN];
bool arr[MXN][MXN];
int depth[MXN];
int low_point[MXN];
int high_point[MXN];
int child_count[MXN];
int time_stamp=0;
class node {
public:
node(int id, int depth, int pid) : node_id_(id), node_depth_(depth), pid_(pid) { }
~node() {
for(int i=0; i<child_.size(); i++) {
delete child_[i];
}
}
int node_id_;
int node_depth_;
int pid_;
vector<node*> child_;
};
node *root_node=NULL;
int
calc_low_point(node *cur_node, int N) {
/* Leaf node */
if((cur_node->child_).size() == 0) {
int cur_id = cur_node->node_id_;
low_point[cur_id] = cur_node->node_depth_;
for(int i=0; i<cur_node->child_.size(); i++) {
arr[cur_id][cur_node->child_[i]->node_id_] = 0;
}
for(int i=0; i<N; i++) {
if(arr[cur_id][i] && (i != cur_node->pid_)) {
if(depth[i] < low_point[cur_id]) {
low_point[cur_id] = depth[i];
}
}
}
return low_point[cur_id];
}
int min_low_point = MXN+1000;
for(int i=0; i<cur_node->child_.size(); i++) {
/* Traverse all its childs */
int x = calc_low_point(cur_node->child_[i], N);
if(x < min_low_point) {
min_low_point = x;
}
}
/* Now traverse the cur_node */
int cur_id = cur_node->node_id_;
low_point[cur_id] = cur_node->node_depth_;
for(int i=0; i<cur_node->child_.size(); i++) {
arr[cur_id][cur_node->child_[i]->node_id_] = 0;
}
for(int i=0; i<N; i++) {
if(arr[cur_id][i] && (i != cur_node->pid_)) {
if(depth[i] < low_point[cur_id]) {
low_point[cur_id] = depth[i];
}
}
}
if(min_low_point < low_point[cur_id]) {
low_point[cur_id] = min_low_point;
}
return low_point[cur_id];
}
void
dfs_visit(int source, node *parent_node, int N) {
depth[source] = ++time_stamp;
visit[source] = true;
node* cur_node;
if(parent_node == NULL) {
/* why must this be 0 ?? */
root_node = new node(source, depth[source], 0);
cur_node = root_node;
} else {
cur_node = new node(source, depth[source], parent_node->node_id_);
parent_node->child_.pb(cur_node);
}
for(int i=0; i<N; i++) {
if(arr[source][i] && !visit[i]) {
dfs_visit(i, cur_node, N);
}
}
}
int
calc_high_point(node *r_node) {
if(r_node->child_.size() == 0) {
high_point[r_node->node_id_] = low_point[r_node->node_id_];
child_count[r_node->node_id_] = 0;
return high_point[r_node->node_id_];
}
int max = -1;
for(int i=0; i<r_node->child_.size(); i++) {
int x = calc_high_point(r_node->child_[i]);
if(x > max) {
max = x;
}
}
high_point[r_node->node_id_] = max;
child_count[r_node->node_id_] = r_node->child_.size();
if(max > low_point[r_node->node_id_]) {
return max;
} else {
return low_point[r_node->node_id_];
}
}
void
pre_order_traversal(node *r_node) {
cout << r_node->node_id_ << ":" << r_node->node_depth_ << endl;
for(int i=0; i<r_node->child_.size(); i++) {
pre_order_traversal(r_node->child_[i]);
}
}
void
post_order_traversal(node *r_node) {
for(int i=0; i<r_node->child_.size(); i++) {
post_order_traversal(r_node->child_[i]);
}
cout << r_node->node_id_ << ":" << r_node->node_depth_ << endl;
}
int find_articulation_points_low(node* root_node, int N) {
calc_high_point(root_node);
#if DEBUG
print_array(high_point, N);
//cout << "FInal nodes" << endl;
#endif
int ret=0;
if(root_node->child_.size() > 1) {
//cout << 0 << endl;
ret++;
}
for(int i=1; i<N; i++) {
if((high_point[i] >= depth[i]) && (child_count[i])) {
//cout << i << endl;
ret++;
}
}
return ret;
}
int
find_articulation_points(int N) {
int final = 0;
/* Reset */
memset(visit, 0, MXN*sizeof(bool));
memset(depth, 0, MXN*sizeof(int));
memset(low_point, 0, MXN*sizeof(int));
memset(high_point, 0, MXN*sizeof(int));
memset(child_count, 0, MXN*sizeof(int));
root_node = NULL;
/* Do a DFS and get the tree */
dfs_visit(0, root_node, N);
/* Do a post order and populate low_point[] */
calc_low_point(root_node, N);
#if DEBUG
pre_order_traversal(root_node);
print_array(depth, N);
print_array(low_point, N);
#endif
int ret = find_articulation_points_low(root_node, N);
/* Clean up */
delete root_node;
return ret;
}
int main() {
#if DEBUG
//freopen("in.txt", "r", stdin);
#endif
TEST {
int N, M;
unsigned long long K;
cin >> N >> M >> K;
memset(arr, 0, MXN*MXN*sizeof(bool));
while(M--) {
int i, j;
cin >> i >> j;
arr[i][j] = arr[j][i] = true;
}
unsigned long long num_of_pts = find_articulation_points(N);
K *= num_of_pts;
cout << K << endl;
}
}