//12252024832524
#include <cstdio>
#include <cstring>
#include <algorithm>
#define TT template<typename T>
#define int LL
using namespace std;

typedef long long LL;
const int MAXN = 25;
const int MAXM = MAXN * MAXN;
int n,m,d[MAXN],cnt[MAXN][4];
bool vis[MAXN][MAXN];
LL bei = 1,ans = 0;

LL Read()
{
	LL x = 0,f = 1;char c = getchar();
	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
	return x * f;
}
TT void Put1(T x)
{
	if(x > 9) Put1(x/10);
	putchar(x%10^48);
}
TT void Put(T x,char c = -1)
{
	if(x < 0) putchar('-'),x = -x;
	Put1(x); if(c >= 0) putchar(c);
}
TT T Max(T x,T y){return x > y ? x : y;}
TT T Min(T x,T y){return x < y ? x : y;}
TT T Abs(T x){return x < 0 ? -x : x;}

int head[MAXN],tot;
struct edge
{
    int v,nxt;
}e[MAXM << 1];
void Add_Edge(int x,int y)
{
    e[++tot].v = y;
    e[tot].nxt = head[x];
    head[x] = tot;
}
void Add_Double_Edge(int x,int y)
{
    d[x]++;d[y]++;
    vis[x][y] = vis[y][x] = 1;
    Add_Edge(x,y);
    Add_Edge(y,x);
}
int c,q[MAXN],f[MAXN];
void dfs(int x)
{
    f[x] = 1;
    q[++c] = x;
    for(int i = head[x]; i ;i = e[i].nxt)
        if(!f[e[i].v])
            dfs(e[i].v);
}
int clr[MAXN];
void solve(int x)
{
    if(x == c+1)
    {
        ans++;
        return;
    }
    for(int j = 1;j <= 3;++ j)
    {
        if(cnt[q[x]][j]) continue;
        clr[q[x]] = j;
        bool suc = 1;
        for(int i = head[q[x]]; i ;i = e[i].nxt)
        {
            if(j == clr[e[i].v])
            {
                suc = 0;
                break;
            }
        }
        if(!suc) continue;
        for(int i = head[q[x]]; i ;i = e[i].nxt)
            cnt[e[i].v][j]++;
        solve(x+1);
        for(int i = head[q[x]]; i ;i = e[i].nxt)
            cnt[e[i].v][j]--;
        clr[q[x]] = 0;
    }
}

signed main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    n = Read(); m = Read();
    for(int i = 1;i <= m;++ i) Add_Double_Edge(Read(),Read());
    for(int i = 1;i <= n;++ i)
        if(!d[i]) bei *= 3;
    for(int i = 1;i <= n;++ i)
        for(int j = 1;j <= n;++ j)
            for(int k = 1;k <= n;++ k)
                for(int l = 1;l <= n;++ l)
                    if(i != j && j != k && k != l && i != k && i != l && j != l && vis[i][j] && vis[i][k] && vis[i][l] && vis[j][k] && vis[j][l] && vis[k][l])
                    {
                        Put(0);
                        return 0;
                    }
    for(int i = 1;i <= n;++ i)
    {
        if(!f[i] && d[i])
        {
            ans = c = 0;
            dfs(i);
            solve(1);
            bei *= ans;
        }
    }
    Put(bei);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

vector<ll> v[22],d(20),g;
ll u[22],n,cnt;

void dfs1(ll x,ll p) {
  if(u[x]) return;
  u[x]=1;
  g.pb(x);
  rep(i,v[x].size()) {
    ll y=v[x][i];
    if(y!=p) dfs1(y,x);
  }
}

void dfs(int k) {
  if(k>=g.size()) {
    cnt++;
    return;
  }
  ll x=g[k];
  rep(j,3) {
    d[x]=j;
    rep(i,v[x].size()) {
      ll y=v[x][i];
      if(d[y]==d[x]) goto next;
    }
    dfs(k+1);
  next:;
    d[x]=-1;
  }
}

void Main() {
  ll m;
  cin >> n >> m;
  rep(i,m) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  ll ans=1;
  rep(i,n) {
    if(!u[i]) {
      g.clear();
      dfs1(i,-1);
      rep(i,n) d[i]=-1;
      d[i]=0;
      cnt=0;
      dfs(1);
      ans*=cnt*3;
    }
  }
  pr(ans);
}

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