Under construction

Still being built. Things may change

Eggplant Summoning Magic

Time limit4sMemory limit1024 MB

Summary
Given N integer points in 3D, pick a structure-preserving map and M of the points that become a regular M-gon, maximizing N times M.
Level

Hard8 of 10

Topics
Geometry, Math, Brute force
Solved
No attempts yet

Problem

The Korean Eggplant Association is studying many ways to supply high-quality eggplants at low prices. Eggplant summoning magic is a recently developed method that sacrifices a small number of eggplants to summon a large number of them.

To use eggplant summoning magic, you must float NN eggplants in the air and chant a spell. Represent each eggplant's position as a point in three-dimensional coordinate space, and apply a suitable function f(P)f(P) to each point. The function f(P)f(P) must satisfy the following conditions.

  • The domain and codomain of f(P)f(P) are the set of all points (x,y,z)(x, y, z) whose coordinates are all rational numbers.
  • For any two distinct points AA, BB, f(A)f(A) and f(B)f(B) are different.
  • Three distinct points AA, BB, CC lie on one line if and only if f(A)f(A), f(B)f(B), f(C)f(C) lie on one line.
  • For two distinct points AA, BB and two distinct points CC, DD, line AB↔\overleftrightarrow{AB} is parallel to line CD↔\overleftrightarrow{CD} if and only if line f(A)f(B)↔\overleftrightarrow{f(A)f(B)} is parallel to line f(C)f(D)↔\overleftrightarrow{f(C)f(D)}. If AB↔=CD↔\overleftrightarrow{AB} = \overleftrightarrow{CD}, then lines AB↔\overleftrightarrow{AB} and CD↔\overleftrightarrow{CD} are parallel.

After applying f(P)f(P) to all NN points, choose MM of the NN points so that the polygon with those MM points as vertices is a regular MM-gon. Then you can summon N×MN \times M eggplants. (M≥3M \ge 3) If no suitable f(P)f(P) exists, or no suitable set of MM points can be chosen, the summoning fails. Given the positions of the NN eggplants, find the maximum number of eggplants you can summon by choosing one suitable function f(P)f(P) and one set of MM points, exactly once.

Input

The first line contains the number of eggplants NN. (3≤N≤5003 \le N \le 500)

Each of the next NN lines contains the position of one eggplant as a point. The ii-th line contains three integers xix_i, yiy_i, ziz_i separated by spaces. (0≤xi,yi,zi≤1080 \le x_i, y_i, z_i \le 10^8)

All eggplant positions are distinct.

Output

Print on the first line the maximum number of eggplants you can summon by choosing one suitable function f(P)f(P) and one set of MM points, exactly once.

Examples3

  1. Example 1

    Input
    4
    0 0 0
    1 0 0
    0 1 0
    0 0 1
    
    Expected output
    12
    
  2. Example 2

    Input
    4
    0 0 0
    1 0 0
    1 0 1
    2 0 1
    
    Expected output
    16
    
  3. Example 3

    Input
    3
    0 0 0
    1 1 1
    2 2 2
    
    Expected output
    0