#include <iostream>

using namespace std;
using LL = long long;

const int kMaxN = 21;

int n, m, p, q[kMaxN], k[kMaxN];
bool v[kMaxN], e[kMaxN][kMaxN];
LL c = 1, _c;

void F(int x) {
  if (!v[x]) {
    v[x] = 1, q[++p] = x;
    for (int i = 1; i <= n; ++i) {
      if (e[x][i]) {
        F(i);
      }
    }
  }
}

void D(int x) {
  if (x > p) {
    ++_c;
    return;
  }
  bool b[4] = {0, 0, 0, 0};
  for (int i = 1; i < x; ++i) {
    if (e[q[x]][q[i]]) {
      b[k[q[i]]] = 1;
    }
  }
  for (int i = 1; i <= 3; ++i) {
    if (!b[i]) {
      k[q[x]] = i;
      D(x + 1);
    }
  }
}

int main() {
  cin >> n >> m;
  for (int i = 1, x, y; i <= m; ++i) {
    cin >> x >> y;
    e[x][y] = e[y][x] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    if (!v[i]) {
      _c = p = 0, F(i), D(1), c *= _c;
    }
  }
  cout << c << endl;
  return 0;
}

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
//const int mod = 998244353;

vector<vector<int>> to;
vector<int> used, col, vs;
ll now;

void dfs(int v){
    used[v] = 1;
    vs.push_back(v);
    for(int u : to[v]){
        if(used[u]) continue;
        dfs(u);
    }
}

void dfs2(int i){
    if(i == vs.size()){
        now++;
        return;
    }
    int v = vs[i];
    rep(c, 0, 3){
        col[v] = c;
        bool flag = 0;
        for(int u : to[v]){
            if(col[u] == c){
                flag = 1;
            }
        }
        if(flag) continue;
        dfs2(i+1);
    }
    col[v] = -1;
}


int main()
{
    int n, m;
    cin >> n >> m;
    to = vector<vector<int>> (n);
    used = vector<int> (n);
    col = vector<int> (n, -1);
    rep(i, 0, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ll ans = 1;
    rep(v, 0, n){
        if(used[v]) continue;
        vs = vector<int> ();
        dfs(v);
        col[vs[0]] = 0;
        now = 0;
        dfs2(1);
        ans *= 3*now;
    }
    cout << ans << endl;
    return 0;
}
