#include using namespace std; random_device rnd; mt19937 mt(rnd()); int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; { if(N == 2){ cout << 1 << endl; cout << "1 2 1" << endl; cout << "1 1" << endl; return 0; } if(N == 3){ cout << 3 << endl; cout << "1 2 1" << endl; cout << "1 3 4" << endl; cout << "2 3 9" << endl; cout << "1 1" << endl; cout << "1 2" << endl; cout << "1 3" << endl; return 0; } if(N == 4){ cout << 5 << endl; cout << "1 2 1" << endl; cout << "2 3 3" << endl; cout << "3 4 5" << endl; cout << "2 3 4" << endl; cout << "3 4 9" << endl; cout << "1 1" << endl; cout << "2 1 2" << endl; cout << "3 1 2 3" << endl; cout << "1 4" << endl; cout << "2 4 3" << endl; cout << "1 5" << endl; return 0; } if(N == 5){ cout << 7 << endl; cout << "1 2 1" << endl; cout << "2 3 3" << endl; cout << "3 4 5" << endl; cout << "4 5 7" << endl; cout << "2 3 4" << endl; cout << "3 4 9" << endl; cout << "4 5 16" << endl; cout << "1 1" << endl; cout << "2 1 2" << endl; cout << "3 1 2 3" << endl; cout << "4 1 2 3 4" << endl; cout << "1 5" << endl; cout << "2 5 3" << endl; cout << "3 5 3 4" << endl; cout << "1 6" << endl; cout << "2 6 4" << endl; cout << "3 7" << endl; return 0; } } vector Sq(40000); for(int i=1; i<200; i++) Sq.at(i*i) = true; if(N <= 100){ while(true){ vector W(N*3+9); iota(W.begin(),W.end(),1); vector A(N),B(N); shuffle(W.begin(),W.end(),mt); for(int i=0; i B.at(i)) swap(A.at(i),B.at(i)); bool ok = true; vector>> S(N,vector>(N)); for(int i=0; i Bs(1000,-1); Bs.at(0) = 0; int sum = 0; for(int p=i; p!=k; p++){ sum += A.at(p); if(A.at(p) == B.at(p)) continue; int d = B.at(p)-A.at(p); for(int v=999; v>=d; v--) if(Bs.at(v-d) != -1) Bs.at(v) = Bs.at(v-d)+(1<=d; v--) if(Bs.at(v-d) != -1) Bs.at(v) = Bs.at(v-d)+(1< P; if(inc){ for(int p=i; p!=k; p++){ if(s&(1<