#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y))
#define chmax(x,y) x = max((x),(y))
#define popcount(x) __builtin_popcount(x)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

struct Unionfind{
    int n;
    vector<int> parents;
    Unionfind(int n):n(n),parents(n,-1){ }

    int find(int x){
        if(parents[x] < 0) return x;
        return parents[x] = find(parents[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);

        if(x==y) return;
        if(parents[x] > parents[y]) swap(x,y);
        parents[x] += parents[y];
        parents[y] = x;
    }  

    int size(int x){
        return -parents[find(x)];
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    vector<int> members(int x){
        int root = find(x);
        vector<int> member;
        for(int i=0;i<n;i++){
            if(find(i)==root ){
                member.push_back(i);
            }
        }
        return member;
    }

    int group_cnt(){
        int c = 0;
        for(int i=0;i<n;i++){
            if(parents[i] < 0) ++c;
        }
        return c;
    }
};


int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> G(n);
    Unionfind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
        uf.unite(a,b);
    }
    vector<int> seen(n,-1);
    auto dfs = [&](auto&& dfs,int i,vector<int>& v) -> void {
        v.push_back(i);
        seen[i] = 1;
        for(int j:G[i]){
            if(seen[j] >= 0) continue;
            dfs(dfs,j,v);
        }
        return;
    };
    auto dfs2 = [&](auto&& dfs2,vector<int>& v,vector<int>& color) -> ll {
        for(int j:v){
            if(color[j] == -1){
                ll res = 0;
                vector<int> use(3,0);
                for(int k:G[j]){
                    if(color[k] == -1) continue;
                    use[color[k]] ++;
                }
                rep(p,3){
                    if(use[p]==0){
                        color[j] = p;
                        res += dfs2(dfs2,v,color);
                    }
                }
                color[j] = -1;
                return res;
            }
        }
        return 1;
    };
    ll res = 1;
    rep(i,n){
        if(uf.find(i) == i){
            vector<int> v;
            dfs(dfs,i,v);
            vector<int> color(n,-1);
            color[v[0]] = 0;
            res *= 3*dfs2(dfs2,v,color);
        }
    }
    cout << res << endl;

    
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int n, m;
vector<vector<int>> adj;

long long ans=1;
long long comp_ans[25];

int color[100];

vector<vector<int>> component;
int visited[25] = {};

void discover(int vertex, int cid=-1) {
    if (cid==-1) {
        cid = component.size();
        component.push_back(vector<int>(0));
    }

    visited[vertex] = true;
    component[cid].push_back(vertex);
    for (int nxt : adj[vertex]) {
        if (not visited[nxt]) {
            discover(nxt, cid);
        }
    }
}

void tryColor(int vid, const int& cid) {
    if (vid >= component[cid].size()) {
        comp_ans[cid]++;
        // for (int i=0; i<n; i++) cout << color[i] << ' ';
        return;
    }

    int vertex = component[cid][vid];
    for (int cl=1; cl<4; cl++) {
        int flag = 1;

        for (int neighbor : adj[vertex]) {
            if (color[neighbor]==cl) flag = 0;
        }

        if (flag) {
            color[vertex] = cl;
            tryColor(vid+1, cid);
            color[vertex] = 0;
        }
    }
}



int main() {
    cin >> n >> m;
    adj.resize(n);
    for (int i=0; i<m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    for (int i=0; i<n; i++) {
        if (visited[i] == 0) discover(i);
    }

    
    for (int cid=0; cid<component.size(); cid++) {
        tryColor(0, cid);
        ans *= comp_ans[cid];
    }

    cout << ans << endl;
}

