#include <bits/stdc++.h>   using namespace std;   const int N = 201;   set<int> graph[N];   map<pair<int, int>, int> edges;   pair<int, int> bfs(int node) {     int dist[N] = {0};     int vis[N] = {0};     queue<pair<int, int> > q;     q.push({0, node});     while (!q.empty()) {       int top = q.front().second;       q.pop();       if (vis[top]) continue;       vis[top] = true;       for (set<int>::iterator it = graph[top].begin(); it != graph[top].end();            it++) {         int to = *it;         if (vis[to]) continue;         dist[to] = dist[top] + 1;         q.push({dist[to], to});       }     }     pair<int, int> temp = {node, 0};     for (int i = 1; i <= N; i++) {       if (dist[i] > temp.second) {         temp.second = dist[i];         temp.first = i;       }     }     return temp;   }   int find_dia(int node) {     pair<int, int> temp = bfs(node);     temp = bfs(temp.first);     return temp.second;   }   int main(void) {     int n;     cin >> n;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       graph[u].insert(v);       graph[v].insert(u);       edges[{u, v}] = 1;     }     int ans = 0;     for (map<pair<int, int>, int>::iterator it = edges.begin(); it != edges.end();          it++) {       int u = (*it).first.first;       int v = (*it).first.second;       graph[u].erase(v);       graph[v].erase(u);       ans = max(ans, find_dia(v) * find_dia(u));       graph[u].insert(v);       graph[v].insert(u);     }     cout << ans << endl;     return 0;   }   