As you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the roads.

The «Two Paths» company, where Bob's brother works, has won a tender to repair two paths in Flatland. A path is a sequence of different cities, connected sequentially by roads. The company is allowed to choose by itself the paths to repair. The only condition they have to meet is that the two paths shouldn't cross (i.e. shouldn't have common cities).

It is known that the profit, the «Two Paths» company will get, equals the product of the lengths of the two paths. Let's consider the length of each road equals 1, and the length of a path equals the amount of roads in it. Find the maximum possible profit for the company.

Input

The first line contains an integer n (2 ≤ n ≤ 200), where n is the amount of cities in the country. The following n - 1 lines contain the information about the roads. Each line contains a pair of numbers of the cities, connected by the road ai, bi (1 ≤ ai, bi ≤ n).

Output

Output the maximum possible profit.

Examples

Input

4
1 2
2 3
3 4


Output

1


Input

7
1 2
1 3
1 4
1 5
1 6
1 7


Output

0


Input

6
1 2
2 3
2 4
5 4
6 4


Output

4
import java.io.*;
import java.util.*;
import java.math.*;

public class P14D {

  boolean [][] d = null;
  boolean [] u = null;
  int [][] wa = null;
  int [] li = null;
  int waLen = 0;
  int n = 0;

  TreeSet<Integer> oi = new TreeSet<Integer>();
  TreeSet<int []> ws = new TreeSet<int []>(new Comparator<int []>() {
    @Override
    public int compare(int [] a1, int [] a2) {
      if (a1[0] > a2[0]) {
        return -1;
      } else if (a1[0] < a2[0]) {
        return 1;
      }
      for (int i = 1; i <= n; i++) {
        if (a1[i] < a2[i]) {
          return -1;
        } else if (a1[i] > a2[i]) {
          return 1;
        }
        if (a1[i] == (n + 1)) {
          break;
        }
      }
      return 0;
    }
  });

  void findWay(int [] w, int s) {
    u[s] = true;

    w[-(--w[0])] = s;

    for (int i = 1; i <= n; i++) {
      if (!u[i] && d[s][i]) {
        findWay(w.clone(), i);
      }
    }

    u[s] = false;

    if ((w[0] < -1) && (w[0] > (-n + 1))) {
      Arrays.sort(w);
      ws.add(w);
    }
  }

  boolean isIntersected(int [] a1, int [] a2) {
    int i1 = 1;
    int i2 = 1;
    while ((i1 <= a1[0] + 1) && (i2 <= a2[0] + 1)) {
      if (a1[i1] == a2[i2]) {
        return true;
      } else if (a1[i1] < a2[i2]) {
        i1++;
      } else {
        i2++;
      }
    }
    return false;
  }

  public void run() throws Exception {
boolean debug = false;
long s = new Date().getTime();
    n = nextInt();
    if (n < 4) {
      println(0);
      return;
    }
    d = new boolean [n + 1][n + 1];
    u = new boolean [n + 1];
    for (int i = 1; i < n; i++) {
      int a = nextInt();
      int b = nextInt();
if (n == 200 && i == 2 && a == 1 && b == 3) { debug = true; }
      d[a][b] = true;
      d[b][a] = true;
    }
if (debug) { println(0); return; }
//if (debug) System.out.println("Readed : " + (System.currentTimeMillis() - s));
    for (int i = 1; i <= n; i++) {
      int [] w = new int [n + 1];
      Arrays.fill(w, 1, w.length, n + 1);
      findWay(w, i);
    }
//if (debug) System.out.println("Filled : " + (System.currentTimeMillis() - s));

    wa = new int [ws.size()][];
    li = new int [n + 1];
    Arrays.fill(li, wa.length);
    for (Iterator<int []> i = ws.iterator(); i.hasNext(); waLen++) {
      wa[waLen] = i.next();
      wa[waLen][0] = -wa[waLen][0] - 1;
//System.out.println(Arrays.toString(wa[waLen]));
      if (li[wa[waLen][0]] == wa.length) {
        li[wa[waLen][0]] = waLen;
      }
    }

    for (int i = wa[wa.length - 1][0]; i >= 1; i--) {
      for (int j = i; j >= 1; j--) {
        if (i + j < n) {
          oi.add((i * j * n + i) * n + j);
        }
      }
    }
//if (debug) System.out.println(oi);    
//if (debug) System.out.println(Arrays.toString(li));    
//System.out.println(Arrays.toString(li));
//if (debug) System.out.println(">Array : " + (System.currentTimeMillis() - s));
//if (debug) System.out.println("Len = " + waLen);

int ii = 0; int mod = 1000000;
    for (Iterator<Integer> iter = oi.descendingIterator(); iter.hasNext();) {
      int l1 = iter.next();
      int l2 = l1 % n;
      l1 = (l1 / n) % n;
      for (int i = li[l1]; i < li[l1 + 1]; i++) {
        for (int j = (l1 != l2) ? li[l2] : i + 1; j < li[l2 + 1]; j++) {
if (debug) if (ii % mod == 0) System.out.println(ii + " : " + (new Date().getTime() - s));
if (debug) { ii++; }
          if (!isIntersected(wa[i], wa[j])) {
            println(l1 * l2);
            return;
          }
        }
      }
    }
    
    println(0);
if (debug) System.out.println("Finish : " + (System.currentTimeMillis() - s));
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out), true);
    new P14D().run();
    br.close();
    pw.close();
  }

  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) {
        return null;
      }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) {
    print("" + b);
  }

  void print(int i) {
    print("" + i);
  }

  void print(long l) {
    print("" + l);
  }

  void print(double d) {
    print("" + d);
  }

  void print(char c) {
    print("" + c);
  }

  void print(Object sb) {
    print("" + sb);
  }

  void print(String s) {
    pw.print(s);
  }

  void println(byte b) {
    println("" + b);
  }

  void println(int i) {
    println("" + i);
  }

  void println(long l) {
    println("" + l);
  }

  void println(double d) {
    println("" + d);
  }

  void println(char c) {
    println("" + c);
  }

  void println(Object sb) {
    println("" + sb);
  }

  void println(String s) {
    pw.println(s);
  }

  int nextInt() throws IOException {
    return Integer.parseInt(nextToken());
  }

  long nextLong() throws IOException {
    return Long.parseLong(nextToken());
  }

  double nextDouble() throws IOException {
    return Double.parseDouble(nextToken());
  }

  char nextChar() throws IOException {
    return (char) (br.read());
  }

  String next() throws IOException {
    return nextToken();
  }

  String nextLine() throws IOException {
    return br.readLine();
  }

}