#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#define endl '\n'
#define int long long

using namespace std;

int cnt = 0;

void check(int v, vector<vector<int>> &g, vector<bool> &been) {
    been[v] = true;
    cnt++;
    for (auto u : g[v]) {
        if (!been[u]) {
            check(u, g, been);
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, zz;
    cin >> n >> m >> zz;
    vector<pair<int, int>> e;
    int u, v;
    for (int i = 0; i < m; ++i) {
        cin >> u >> v;
        u--;
        v--;
        e.push_back({u, v});
    }
    vector<bool> ban(m);
    for (int i = 0; i < m; ++i) {
        ban[i] = true;
        vector<vector<int>> g1(n), g2(n);
        for (int j = 0; j < m; ++j) {
            if (ban[j]) {
                g1[e[j].second].push_back(e[j].first);
                g2[e[j].first].push_back(e[j].second);
            } else {
                g1[e[j].first].push_back(e[j].second);
                g2[e[j].second].push_back(e[j].first);
            }
        }
        cnt = 0;
        vector<bool> been(n, false);
        check(0, g1, been);
        if (cnt != n) {
            ban[i] = false;
        } else {
            vector<bool> b1(n, false);
            cnt = 0;
            check(0, g2, b1);
            if (cnt != n) {
                ban[i] = false;
            }
        }
    }
    int calc = 0;
    for (int i = 0; i < m; ++i) {
        calc += ban[i];
    }
    int mod = 1e9 + 7;
    int cur = 1;
    for (int i = 0; i < calc; ++i) {
        cur = (cur * 2) % mod;
    }
    cout << cur << endl;
    return 0;
}
