#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200];
bool vis[200];
int dist, farthest;
void dfs(int root, int depth) {
  vis[root] = true;
  if (depth > dist) {
    dist = depth;
    farthest = root;
  }
  for (int i = 0; i < adj[root].size(); i++) {
    int child = adj[root][i];
    if (!vis[child]) {
      dfs(child, depth + 1);
    }
  }
  vis[root] = false;
}
void getlongestpath(int root) {
  dist = 0;
  farthest = root;
  dfs(root, 0);
  dist = 0;
  dfs(farthest, 0);
}
int main() {
  int n;
  cin >> n;
  pair<int, int> edges[n - 1];
  for (int i = 0; i < n; i++) {
    adj[i] = vector<int>();
  }
  for (int i = 0; i < n - 1; i++) {
    int src, dest;
    cin >> src >> dest;
    src--;
    dest--;
    adj[src].push_back(dest);
    adj[dest].push_back(src);
    edges[i] = make_pair(src, dest);
  }
  int max = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n; j++) {
      vis[j] = false;
    }
    vis[edges[i].second] = true;
    getlongestpath(edges[i].first);
    int path1len = dist;
    vis[edges[i].first] = true;
    getlongestpath(edges[i].second);
    int path2len = dist;
    if (path1len * path2len > max) {
      max = path1len * path2len;
    }
  }
  cout << max << endl;
  return 0;
}
