#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <algorithm>
using namespace std;
int N, M;
vector<vector<int>> graph;
vector<bool> visited;
// Hàm DFS để đếm số đỉnh trong thành phần liên thông
int dfs(int u) {
visited[u] = true;
int size = 1; // Đếm đỉnh hiện tại
for (int v : graph[u]) {
if (!visited[v]) {
size += dfs(v);
}
}
return size;
}
int countDisconnectedPairs(int u, int v) {
// Tạm thời loại bỏ cạnh (u, v)
vector<int> temp_u = graph[u];
vector<int> temp_v = graph[v];
graph[u].erase(remove(graph[u].begin(), graph[u].end(), v), graph[u].end());
graph[v].erase(remove(graph[v].begin(), graph[v].end(), u), graph[v].end());
// Tìm các thành phần liên thông
visited.assign(N + 1, false);
vector<int> componentSizes;
for (int i = 1; i <= N; ++i) {
if (!visited[i]) {
componentSizes.push_back(dfs(i));
}
}
// Khôi phục cạnh (u, v)
graph[u] = temp_u;
graph[v] = temp_v;
// Tính số cặp không thể đi đến nhau
long long totalPairs = 0;
for (int size : componentSizes) {
totalPairs += 1LL * size * (N - size);
}
return totalPairs / 2; // Vì mỗi cặp được đếm 2 lần
}
int main() {
cin >> N >> M;
graph.assign(N + 1, vector<int>());
vector<pair<int, int>> edges;
for (int i = 0; i < M; ++i) {
int u, v;
cin >> u >> v;
graph[u].push_back(v);
graph[v].push_back(u);
edges.emplace_back(u, v);
}
for (auto [u, v] : edges) {
cout << countDisconnectedPairs(u, v) << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBOLCBNOwp2ZWN0b3I8dmVjdG9yPGludD4+IGdyYXBoOwp2ZWN0b3I8Ym9vbD4gdmlzaXRlZDsKCi8vIEjDoG0gREZTIMSR4buDIMSR4bq/bSBz4buRIMSR4buJbmggdHJvbmcgdGj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IHYpCiAgICBncmFwaFt1XSA9IHRlbXBfdTsKICAgIGdyYXBoW3ZdID0gdGVtcF92OwoKICAgIC8vIFTDrW5oIHPhu5EgY+G6t3Aga2jDtG5nIHRo4buDIMSRaSDEkeG6v24gbmhhdQogICAgbG9uZyBsb25nIHRvdGFsUGFpcnMgPSAwOwogICAgZm9yIChpbnQgc2l6ZSA6IGNvbXBvbmVudFNpemVzKSB7CiAgICAgICAgdG90YWxQYWlycyArPSAxTEwgKiBzaXplICogKE4gLSBzaXplKTsKICAgIH0KCiAgICByZXR1cm4gdG90YWxQYWlycyAvIDI7IC8vIFbDrCBt4buXaSBj4bq3cCDEkcaw4bujYyDEkeG6v20gMiBs4bqnbgp9CgppbnQgbWFpbigpIHsKICAgIGNpbiA+PiBOID4+IE07CgogICAgZ3JhcGguYXNzaWduKE4gKyAxLCB2ZWN0b3I8aW50PigpKTsKICAgIHZlY3RvcjxwYWlyPGludCwgaW50Pj4gZWRnZXM7CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBNOyArK2kpIHsKICAgICAgICBpbnQgdSwgdjsKICAgICAgICBjaW4gPj4gdSA+PiB2OwogICAgICAgIGdyYXBoW3VdLnB1c2hfYmFjayh2KTsKICAgICAgICBncmFwaFt2XS5wdXNoX2JhY2sodSk7CiAgICAgICAgZWRnZXMuZW1wbGFjZV9iYWNrKHUsIHYpOwogICAgfQoKICAgIGZvciAoYXV0byBbdSwgdl0gOiBlZGdlcykgewogICAgICAgIGNvdXQgPDwgY291bnREaXNjb25uZWN0ZWRQYWlycyh1LCB2KSA8PCBlbmRsOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==