#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N, M;
bool checked[25];
ll ans = 1;
ll color[25];
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

vector<int> edges[25];
ll way = 0;
vector<int> v;

void dfs(int idx) {
    if(idx == v.size()) {
        way++;
        return;
    }
    set<int> st;
    st.insert(1);
    st.insert(2);
    st.insert(3);
    for(auto to : edges[v[idx]]) {
        st.erase(color[to]);
    }
    for(auto c : st) {
        color[v[idx]] = c;
        dfs(idx + 1);
        color[v[idx]] = 0;
    }
}

void dfs2(int now) {
    v.push_back(now);
    checked[now] = true;
    for(auto to : edges[now]) {
        if(checked[to]) continue;
        dfs2(to);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    UnionFind uni(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uni.merge(a, b);
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    for(int i = 0; i < N; i++) {
        if(uni.root(i) != i) continue;
        v.clear();
        dfs2(i);
        way = 0;
        dfs(0);
        ans *= way;
    }
    cout << ans << endl;
    return 0;
}
    #include <bits/stdc++.h>
    #define HAR BAR LAGTA HAI APUN HI J BHAGWAAN HAI!!
    #define UTSAV  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define ll long long int
    #define loop(i,m,n) for(ll i=m;i<n;i++)
    #define sq(a) (a)*(a)
    #define MAX 1e9
    #define MIN -1e9
    #define mod 1000000007
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    #define debug(x) cerr<<#x<<'='<<(x)<<endl;
    #define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
    #define mxn 100005
    using namespace std;
    ll n;
    vector<int> arr[100001];
    int vis[100001];
    vector<int> res;
    int c = 0;
    ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b); 
     
}
    void dfs1(int node){
        res.push_back(node);
        vis[node]=1;
        for(int i : arr[node]) dfs1(i);
    }
    bool dfs(int node){
        if(vis[node]==1) return false;
        vis[node]=1;
        for(int i : arr[node]) dfs(i);
        return true;
    }

    bool isPrime(ll n){
        for(ll i=2;i*i<=n;i++){
            if(n%i==0) return false;
        }
        return true;
    }
    ll fact(ll n){
        if(n==1) return 1;
        else return n*fact(n-1);
    }
    ll comb(ll n,ll r){
        return fact(n)/(fact(n-r)*fact(r)) ;
    }
    bool invalid(ll n){
        ll n1 = n;
        while(n1>0){
            if(n1%10!=0&&n%(n1%10)!=0) return true;
            n1/=10;
        }
        return false;
    }
    ll cal(ll n){
        return (n*(n-1)*(n-2)/6);
    }
 ll findMin(ll a[],ll i,ll sum,ll sumTotal){
        if(i==0) return abs((sumTotal-sum)-sum);
        return std::min(findMin(a,i-1,sum+a[i-1],sumTotal),findMin(a,i-1,sum,sumTotal));
    }
    ll max_value(ll n,ll k){
        ll i=0;
        while((ll)std::pow(k,i)<=n) i++;
        return i-1;
    }
    int main()
    {
        UTSAV
        int t=1;
    // cin>>t;
        while(t-->0){
           ll n;
           cin>>n;
           ll a,b;
           ll ans1 = 1e9;
           ll ans2 = 1e9;
           ll ans = 1e9;
           vector<ll> a1,b1;
           for(int i=0;i<n;i++){
               cin>>a>>b;
               ans = std::min(ans,a+b);
               a1.pb(a);
               b1.pb(b);
           }
           for(int i=0;i<n;i++){
               for(int j=0;j<n;j++){
                   if(i==j) continue;
                   ans = std::min(ans,std::max(a1[i],b1[j]));
               }
           }
           cout<<ans<<endl;
        }   
        return 0;
    }