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

#define ll              long long 
#define pb              push_back
#define all(v)          v.begin(),v.end()
#define sz(a)           (ll)a.size()
#define F               first
#define S               second
#define INF             2000000000000000000
#define popcount(x)     __builtin_popcountll(x)
#define pll             pair<ll,ll> 
#define pii             pair<int,int>
#define ld              long double

const int M = 1000000007;
const int MM = 998244353;
const long double PI = acos(-1);

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

const int N = 105;

vector<int> v[N];

set<pii> A;

bool vis[N];

int dep[N];
int a[N];

void dfs(int s,int p)
{
    vis[s] = true;
    for(auto j:v[s])
    {
        if(!vis[j])
        {
            dep[j] = dep[s] + 1;
            A.insert({s,j});
            dfs(j,s);
        }
        else if(j!=p && dep[j]<dep[s])
        {
            A.insert({s,j});
        }
    }
}

int _runtimeTerror_()
{
    int n,m;
    cin>>n>>m;
    vector<int> ans(m,-1);
    vector<pii> ed;
    for(int i=0;i<m;++i)
    {
        int x,y;
        cin>>x>>y;
        ed.pb({x,y});
    }
    for(int i=1;i<=n;++i)
        cin>>a[i];
    // 0 right,1 left;
    int cur = 0;
    for(auto &[j,k]:ed)
    {
        if(a[j] != a[k])
        {
            if(a[j]>a[k])
                ans[cur] = 0;
            else
                ans[cur] = 1;
        }
        else
        {   
            v[j].pb(k);
            v[k].pb(j);
        }
        ++cur;
    }
    for(int i=1;i<=n;++i)
    {
        if(!vis[i])
        {
            dfs(i,0);
        }
    }
    cur = 0;
    for(auto &[j,k]:ed)
    {
        if(a[j]==a[k])
        {
            if(A.count({j,k}))
                ans[cur] = 0;
            else
                ans[cur] = 1,assert(A.count({k,j}));
        }
        ++cur;
    }
    for(int i=0;i<m;++i)
    {
        cout<<(ans[i]?"<-":"->")<<"\n";
    }
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}
#include<bits/stdc++.h>
#define int long long
#define ld long double

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second


using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;


typedef pair<int, int> pii;

int power(int a, int b, int in_mod)
{
    int ans=1;
    int prod=a;
    while(b)
    {
        if(b%2)
            ans=(ans*prod)%in_mod;
        prod=(prod*prod)%in_mod;
        b/=2;
    }
    return ans;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int fact(int n,int in_mod){
    int f=1;
    for(int i=1;i<=n;i++) f=(f*i)%in_mod;
    return f;
}
int ncr(int n,int r,int in_mod){
    return (((fact(n,in_mod)*mod_inv(fact(r,in_mod),in_mod))%in_mod)*mod_inv(fact(n-r,in_mod),in_mod))%in_mod;
}
const int N = 25;
vector<int> adj[N];
int vis[N]={};
int edge[N][N]={};
int par[N]={};
void dfs(int s,int p,vector<int>& v){
    v.pb(s);
    par[s]=p;
    vis[s]=1;
    for(auto u:adj[s]){
        if(!vis[u]) dfs(u,s,v);
    }
}
void fun(vector<int>& v,int idx,vector<int>& col,int& cnt){
    if(idx==v.size()){
        int flag=0;
        for(int i=0;i<idx;i++){
            for(int j=i+1;j<idx;j++){
                if(edge[v[i]][v[j]] && col[v[i]]==col[v[j]]){
                    flag=1;
                }
            }
        }
        if(!flag) cnt++;
        return ;
    }

    set<int> st={1,2,3};
    st.erase(col[par[v[idx]]]);
    for(auto f:st){
        col[v[idx]]=f;
        fun(v,idx+1,col,cnt);
        col[v[idx]]=0;
    }

}
void solve()
{
    //write code here
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
        edge[u][v]=1;
        edge[v][u]=1;
    }
    int ans=1;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            vector<int> v;
            dfs(i,-1,v);
            int cnt=0;
            vector<int> col(N,0);
            col[i]=1;
            fun(v,1,col,cnt);
            col[i]=2;
            fun(v,1,col,cnt);
            col[i]=3;
            fun(v,1,col,cnt);

            ans*=cnt;
        }
    }
    cout<<ans<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    //cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((long double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}
/*
1.do not use bitshift (1<<int) because it gives value in int and not in long long 
2.check that for loops of i,j,k are properly declared
3.donot delete elements from map,set while looping in it
4.in a map's vector ,ie,map<int,vector<int>> mp,when you sort each vector in a loop it may not get sorted outside the scope of the loop so take care
*/