#P1375I. Cubic Lattice

    ID: 3117 Type: RemoteJudge 4000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 10 Uploaded By: Tags>geometrymathmatricesnumber theory*3500

Cubic Lattice

Description

A cubic lattice LL in 33-dimensional euclidean space is a set of points defined in the following way: L={ur1+vr2+wr3}u,v,wZL=\{u \cdot \vec r_1 + v \cdot \vec r_2 + w \cdot \vec r_3\}_{u, v, w \in \mathbb Z} Where r1,r2,r3Z3\vec r_1, \vec r_2, \vec r_3 \in \mathbb{Z}^3 are some integer vectors such that:

  • r1\vec r_1, r2\vec r_2 and r3\vec r_3 are pairwise orthogonal: r1r2=r1r3=r2r3=0\vec r_1 \cdot \vec r_2 = \vec r_1 \cdot \vec r_3 = \vec r_2 \cdot \vec r_3 = 0 Where ab\vec a \cdot \vec b is a dot product of vectors a\vec a and b\vec b.
  • r1\vec r_1, r2\vec r_2 and r3\vec r_3 all have the same length: r1=r2=r3=r|\vec r_1| = |\vec r_2| = |\vec r_3| = r
You're given a set A={a1,a2,,an}A=\{\vec a_1, \vec a_2, \dots, \vec a_n\} of integer points, ii-th point has coordinates ai=(xi;yi;zi)a_i=(x_i;y_i;z_i). Let gi=gcd(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i). It is guaranteed that gcd(g1,g2,,gn)=1\gcd(g_1,g_2,\dots,g_n)=1.

You have to find a cubic lattice LL such that ALA \subset L and rr is the maximum possible.

First line contains single integer nn (1n1041 \leq n \leq 10^4) — the number of points in AA.

The ii-th of the following nn lines contains integers xix_i, yiy_i, ziz_i (0<xi2+yi2+zi210160 < x_i^2 + y_i^2 + z_i^2 \leq 10^{16}) — coordinates of the ii-th point.

It is guaranteed that gcd(g1,g2,,gn)=1\gcd(g_1,g_2,\dots,g_n)=1 where gi=gcd(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i).

In first line output a single integer r2r^2, the square of maximum possible rr.

In following 33 lines output coordinates of vectors r1\vec r_1, r2\vec r_2 and r3\vec r_3 respectively.

If there are multiple possible answers, output any.

Input

First line contains single integer nn (1n1041 \leq n \leq 10^4) — the number of points in AA.

The ii-th of the following nn lines contains integers xix_i, yiy_i, ziz_i (0<xi2+yi2+zi210160 < x_i^2 + y_i^2 + z_i^2 \leq 10^{16}) — coordinates of the ii-th point.

It is guaranteed that gcd(g1,g2,,gn)=1\gcd(g_1,g_2,\dots,g_n)=1 where gi=gcd(xi,yi,zi)g_i=\gcd(x_i,y_i,z_i).

Output

In first line output a single integer r2r^2, the square of maximum possible rr.

In following 33 lines output coordinates of vectors r1\vec r_1, r2\vec r_2 and r3\vec r_3 respectively.

If there are multiple possible answers, output any.

Sample Input 1

2
1 2 3
1 2 1

Sample Output 1

1
1 0 0
0 1 0
0 0 1

Sample Input 2

1
1 2 2

Sample Output 2

9
2 -2 1
1 2 2
-2 -1 2

Sample Input 3

1
2 5 5

Sample Output 3

9
-1 2 2
2 -1 2
2 2 -1