#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool solve(int v, int c, vector<vector<int>>& G, vector<int>& color) {
    if (color[v] != -1) {
        if (color[v] != 2 && color[v] != c) {
            color[v] = -2;
            return false;
        } else {
            return true;
        }
    }

    bool res = true;
    int n = G.size();
    color[v] = c;

    rep(i, n) {
        if (G[v][i] == 0) continue;
        res &= solve(i, c ^ 1, G, color);
    }

    return res;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> G(n, vector<int>(n, false));
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        G[a[i]][b[i]] = 1;
        G[b[i]][a[i]] = 1;
    }

    ll ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        vector<vector<int>> G2 = G;
        vector<int> color(n, -1);
        rep(i, n) {
            if (bit >> i & 1) {
                color[i] = 2;
                rep(j, n) {
                    G2[i][j] = 0;
                    G2[j][i] = 0;
                }
            }
        }

        bool ok = true;
        rep(i, m) if (color[a[i]] == 2 && color[b[i]] == 2) ok = false;
        if (!ok) continue;

        ll tmp = 1;
        rep(i, n) {
            if (color[i] == -1 && solve(i, 0, G, color)) {
                tmp *= 2;
            }
        }

        rep(i, n) if (color[i] == -2) ok = false;
        if (ok) ans += tmp;
    }

    cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m; cin >> n >> m;
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v; --u, --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vector<bool> vis(n, 0);
    int sz;
    function<void(int)> dfs1 = [&](int u) {
        sz++;
        vis[u] = 1;
        for (int v : adj[u]) 
            if (!vis[v]) dfs1(v);
    };
    
    int offset, pos;
    vector<int> colour(n);
    function<bool(int)> dfs2 = [&](int u) {
        pos++;
        for (int v : adj[u]) {
            if (colour[v] == colour[u]) {
                return false;
            }
            if (colour[v] == -1) {
                colour[v] = (colour[u] + ((offset >> pos) & 1) + 1) % 3;
                if (!dfs2(v)) return false;
            }
        }
        return true;
    };

    long long ans = 1;
    for (int i = 0; i < n; ++i) {
        if (vis[i]) continue;
        sz = 0;
        dfs1(i);
        int cur = 0;
        for (offset = 0; offset < (1 << (sz - 1)); ++offset) {
            colour.assign(n, -1);
            colour[i] = 0;
            pos = -1;
            if (dfs2(i)) cur += 3;
        }
        ans *= cur;
    }
    cout << ans << '\n';

    return 0;
}