#include <bits/stdc++.h>
#define pb emplace_back
#define SZ(x) ((int)x.size())
#define fi first
#define se second
#define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i)
#define FORLL(i, a, b) for (ll i = a, _b = b; i <= _b; ++i)
#define FORDLL(i, a, b) for (ll i = a, _b = b; i >= _b; --i)
#define all(x) x.begin(), x.end()
#define uni(x) sort(all(x)), x.erase(unique(all(x)), x.end())
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__)
template<typename T>
void __prine_one(const char *&s, const T &x)
{
while (*s == ' ') ++s;
const char *p = s;
int bal = 0;
while (*s)
{
if (*s == '(') ++bal;
else if (*s == ')') --bal;
else if (*s == ',' && bal == 0) break;
++s;
}
cerr.write(p, s - p) << " = " << x;
if (*s == ',')
{
cerr << " , ";
++s;
}
}
template<typename... Args>
void debug(const char *s, Args... args)
{
cerr << "[ ";
int dummy[] = {0, (__prine_one(s, args), 0)...};
(void)dummy;
cerr << " ]\n\n";
}
template<class X>
bool maximize(X &a, const X &b)
{
if (b > a)
{
a = b;
return true;
}
return false;
}
template<class X>
bool minimize(X &a, const X &b)
{
if (b < a)
{
a = b;
return true;
}
return false;
}
// --------------------------------------------------------------------------------------------
constexpr int maxn = 1e5 + 3;
int n, m, sz[maxn];
vector<int> g[maxn];
// --------------------------------------------------------------------------------------------
void readInput()
{
cin >> n >> m;
FOR(i, 1, m)
{
int u, v; cin >> u >> v;
if (u > v) swap(u, v);
g[u].push_back(v);
g[v].push_back(u);
}
}
namespace subTree
{
bool approve()
{
if (m != n - 1) return false;
FOR(i, 1, n)
if (SZ(g[i]) > 2) return false;
return true;
}
bool vis[maxn];
ll res = 0;
vector<int> vec;
void dfs_sz(int u, int p)
{
vis[u] = true;
sz[u] = 1;
vec.push_back(u);
for (int v : g[u])
{
if (vis[v]) continue;
dfs_sz(v, u);
res += 1ll * (sz[u] - 1) * sz[v];
sz[u] += sz[v];
}
}
void solve()
{
FOR(i, 1, n)
{
if (vis[i]) continue;
dfs_sz(i, -1);
for (int u : vec)
{
res += 1ll * (sz[u] - 1) * (SZ(vec) - sz[u]);
}
vec.clear();
}
res <<= 1;
cout << res;
}
}
namespace AC
{
int num[maxn], low[maxn], tdfs, in[maxn];
bool join[maxn];
stack<int> st;
int bcc;
vector<int> BCT[maxn << 1];
int root;
bool vis[maxn];
ll res;
vector<int> vec;
void tarjan(int u, int p)
{
num[u] = low[u] = ++tdfs;
st.push(u);
int children = 0;
for (int v : g[u])
{
if (!num[v])
{
tarjan(v, u);
low[u] = min(low[u], low[v]);
if (low[v] >= num[u])
{
join[u] = true;
++bcc;
while (st.size() && st.top() != u)
{
int v = st.top(); st.pop();
BCT[v].push_back(bcc);
BCT[bcc].push_back(v);
}
BCT[u].push_back(bcc);
BCT[bcc].push_back(u);
}
}
else low[u] = min(low[u], num[v]);
}
if (u == root && children <= 1)
join[u] = false;
}
ll sz_bct[maxn], sz[maxn];
int cnt_bcc = 0;
ll F(ll x) {return x * (x - 1) / 2;}
void dfs_sz(int u, int p)
{
vis[u] = true;
if (join[u] || u > n) vec.push_back(u);
if (u <= n) ++cnt_bcc;
sz[u] = sz_bct[u];
for (int v : BCT[u])
{
if (vis[v]) continue;
dfs_sz(v, u);
// 2 ngoai 1 trong voi nhung nhanh duoi
res += sz_bct[u] * (sz[u] - sz_bct[u]) * (sz[v]);
sz[u] += sz[v];
}
}
void solve()
{
bcc = n;
FOR(i, 1, n)
{
if (num[i]) continue;
root = i;
tarjan(i, -1);
}
FOR(u, 1, n)
{
if (join[u])
{
sz_bct[u] = 1;
}
}
FOR(u, n + 1, bcc)
{
for (int v : BCT[u])
{
sz_bct[u] += !join[v];
}
res += sz_bct[u] * (sz_bct[u] - 1) * (sz_bct[u] - 2) / 2;
// dbg(u, sz_bct[u]);
}
FORD(u, bcc, 1)
{
if (vis[u] == false)
{
dfs_sz(u, -1);
for (int x : vec)
{
// 2 trong 1 ngoai
res += F(sz_bct[x]) * 2 * (cnt_bcc - sz_bct[x]);
// 2 ngoai 1 trong chung bicon (chi cho khop)
if (join[x])
{
for (int xj : BCT[x])
res += F(sz_bct[xj]);
}
// 2 ngoai 1 trong 1 nhanh duoi 1 nhanh len
res += sz_bct[x] * (sz[x] - sz_bct[x]) * (cnt_bcc - sz[x]);
}
vec.clear();
cnt_bcc = 0;
}
}
cout << res * 2;
}
}
void solve()
{
AC :: solve();
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define TASK "TEST"
if (fopen(TASK".INP", "r"))
{
freopen(TASK".INP", "r", stdin);
freopen(TASK".OUT", "w", stdout);
}
readInput();
solve();
return 0;
}