import std; void main () { long N = readln.chomp.to!long; solve(N); } struct trio { int X; int Y; int Z; } void solve (long N) { trio[] ans; // assume x <= y <= z foreach (x; 0..int.max) { if (N < x*x) { break; } foreach (y; x..int.max) { if (x == 0 && y == 0) { continue; } if (N < y*y) { break; } // z = (N-xy) / (x+y) if ((N-x*y) % (x+y) == 0) { if (y <= (N-x*y)/(x+y)) { ans ~= trio(x, y, cast(int) (N-x*y)/(x+y)); } } } } // counting length int len = 0; foreach (ref x; ans) { if (x.X != x.Y && x.X != x.Z && x.Y != x.Z) { len += 6; } else if (x.X == x.Y && x.X != x.Z) { len += 3; } else if (x.X != x.Y && x.Y == x.Z) { len += 3; } else if (x.X == x.Y && x.X == x.Z && x.Y == x.Z) { len += 1; } else { assert(0, "you can't reach this statement."); } } // output writeln(len); foreach (ref x; ans) { if (x.X != x.Y && x.X != x.Z && x.Y != x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); writeln(x.X, " ", x.Z, " ", x.Y); writeln(x.Y, " ", x.X, " ", x.Z); writeln(x.Y, " ", x.Z, " ", x.X); writeln(x.Z, " ", x.X, " ", x.Y); writeln(x.Z, " ", x.Y, " ", x.X); } else if (x.X == x.Y && x.X != x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); writeln(x.X, " ", x.Z, " ", x.Y); writeln(x.Z, " ", x.X, " ", x.Y); } else if (x.X != x.Y && x.Y == x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); writeln(x.Y, " ", x.X, " ", x.Z); writeln(x.Y, " ", x.Z, " ", x.X); } else if (x.X == x.Y && x.X == x.Z && x.Y == x.Z) { writeln(x.X, " ", x.Y, " ", x.Z); } else { assert(0, "you can't reach this statement."); } } }