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.util.*;
import java.math.*;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class Hello {
  static int []prev = new int[300005];
  static ArrayList<Integer> a[] = new ArrayList[300005];
  
  static int maxpos = 0;
  static int maxlen = 0;
  static void DEBUG(int n)
  {
    for (int i = 1;i <= n;++i) {
      System.out.print("node " + i + " nbs:");
      for (int j = 0;j < a[i].size();++j) {
	System.out.print(a[i].get(j) + " ");
      }
      System.out.println("===");
    }
  }
  
  static void dfs(int n, int pre, int depth)
  {
    prev[n] = pre;
    if (depth > maxlen) {
      maxlen = depth;
      maxpos = n;
    }
    for (int j = 0;j < a[n].size();++j) {
      if (a[n].get(j) != pre) {
	dfs(a[n].get(j), n, depth + 1);
      }
    }
  }
  static void dfs1(int n, int pre, int depth, int bad)
  {
    //prev[n] = pre;
    if (depth > maxlen) {
      maxlen = depth;
      maxpos = n;
    }
    for (int j = 0;j < a[n].size();++j) {
      if (a[n].get(j) != pre && a[n].get(j) != bad) {
	dfs1(a[n].get(j), n, depth + 1, bad);
      }
    }
  }
  public static void main(String[] args) {
    //Scanner in = new Scanner(System.in);
    FastReader in = new FastReader(System.in);
 
    int n = in.nextInt();
    for (int i = 0; i <= n; i++) a[i] = new ArrayList<>();
 
    int [][]e = new int[n - 1][2];
    for (int i = 0;i < n - 1;++i) {
      int i1 = in.nextInt();
      int i2 = in.nextInt();
      a[i1].add(i2);
      a[i2].add(i1);
      e[i][0] = i1;
      e[i][1] = i2;
    }
    
    int ans = 0;


    for (int j = 0;j < n - 1;++j) {
      int b1 = e[j][0];
      int b2 = e[j][1];
      int len1 = 0;
      int len2 = 0;


      maxlen = 0;
      maxpos = b1;
      dfs1(b1, 0, 0, b2);
      maxlen = 0;
      dfs1(maxpos, 0, 0, b2);
      len1 = maxlen;

      maxlen = 0;
      maxpos = b2;
      dfs1(b2, 0, 0, b1);
      maxlen = 0;
      dfs1(maxpos, 0, 0, b1);
      len2 = maxlen;
      if (len1 * len2 > ans) ans = len1 * len2;
    }
    System.out.println(ans);
  }
}
class FastReader {
  private boolean finished = false;

  private InputStream stream;
  private byte[] buf = new byte[1024];
  private int curChar;
  private int numChars;
  private SpaceCharFilter filter;

  public FastReader(InputStream stream) {
    this.stream = stream;
  }

  public int read() {
    if (numChars == -1) {
      throw new InputMismatchException();
    }
    if (curChar >= numChars) {
      curChar = 0;
      try {
	numChars = stream.read(buf);
      } catch (IOException e) {
	throw new InputMismatchException();
      }
      if (numChars <= 0) {
	return -1;
      }
    }

    return buf[curChar++];
  }

  public int peek() {
    if (numChars == -1) {
      return -1;
    }
    if (curChar >= numChars) {
      curChar = 0;
      try {
	numChars = stream.read(buf);
      } catch (IOException e) {
	return -1;
      }
      if (numChars <= 0) {
	return -1;
      }
    }
    return buf[curChar];
  }

  public int nextInt() {
    int c = read();
    while (isSpaceChar(c))
      c = read();
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    int res = 0;
    do {
      if (c == ',') {
	c = read();
      }
      if (c < '0' || c > '9') {
	throw new InputMismatchException();
      }
      res *= 10;
      res += c - '0';
      c = read();
    } while (!isSpaceChar(c));
    return res * sgn;
  }

  public long nextLong() {
    int c = read();
    while (isSpaceChar(c))
      c = read();
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    long res = 0;
    do {
      if (c < '0' || c > '9') {
	throw new InputMismatchException();
      }
      res *= 10;
      res += c - '0';
      c = read();
    } while (!isSpaceChar(c));
    return res * sgn;
  }

  public String nextString() {
    int c = read();
    while (isSpaceChar(c))
      c = read();
    StringBuilder res = new StringBuilder();
    do {
      res.appendCodePoint(c);
      c = read();
    } while (!isSpaceChar(c));
    return res.toString();
  }

  public boolean isSpaceChar(int c) {
    if (filter != null) {
      return filter.isSpaceChar(c);
    }
    return isWhitespace(c);
  }

  public static boolean isWhitespace(int c) {
    return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
  }

  private String readLine0() {
    StringBuilder buf = new StringBuilder();
    int c = read();
    while (c != '\n' && c != -1) {
      if (c != '\r') {
	buf.appendCodePoint(c);
      }
      c = read();
    }
    return buf.toString();
  }

  public String nextLine() {
    String s = readLine0();
    while (s.trim().length() == 0)
      s = readLine0();
    return s;
  }

  public String nextLine(boolean ignoreEmptyLines) {
    if (ignoreEmptyLines) {
      return nextLine();
    } else {
      return readLine0();
    }
  }

  public BigInteger nextBigInteger() {
    try {
      return new BigInteger(nextString());
    } catch (NumberFormatException e) {
      throw new InputMismatchException();
    }
  }

  public char nextCharacter() {
    int c = read();
    while (isSpaceChar(c))
      c = read();
    return (char) c;
  }

  public double nextDouble() {
    int c = read();
    while (isSpaceChar(c))
      c = read();
    int sgn = 1;
    if (c == '-') {
      sgn = -1;
      c = read();
    }
    double res = 0;
    while (!isSpaceChar(c) && c != '.') {
      if (c == 'e' || c == 'E') {
	return res * Math.pow(10, nextInt());
      }
      if (c < '0' || c > '9') {
	throw new InputMismatchException();
      }
      res *= 10;
      res += c - '0';
      c = read();
    }
    if (c == '.') {
      c = read();
      double m = 1;
      while (!isSpaceChar(c)) {
	if (c == 'e' || c == 'E') {
	  return res * Math.pow(10, nextInt());
	}
	if (c < '0' || c > '9') {
	  throw new InputMismatchException();
	}
	m /= 10;
	res += (c - '0') * m;
	c = read();
      }
    }
    return res * sgn;
  }

  public boolean isExhausted() {
    int value;
    while (isSpaceChar(value = peek()) && value != -1)
      read();
    return value == -1;
  }

  public String next() {
    return nextString();
  }

  public SpaceCharFilter getFilter() {
    return filter;
  }

  public void setFilter(SpaceCharFilter filter) {
    this.filter = filter;
  }

  public interface SpaceCharFilter {
    public boolean isSpaceChar(int ch);
  }
}
