#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
    registerGen(argc, argv, 1);
    
    int st = opt<int>(1);
    vector<vector<int>> tests;
    for (int t1 = 6 * (st - 1) + 1; t1 < 6 * st; t1++) {
        for (int t2 = 6 * (st - 1) + 1; t2 < 6 * st; t2++) {
            for (int t3 = 6 * (st - 1) + 1; t3 < 6 * st; t3++) {
                for (int t4 = 6 * (st - 1) + 1; t4 < 6 * st; t4++) {
                    for (int T = max(1, min({t1, t2, t3, t4}) / 2); T < t1 + t2 + t3 + t4; T++) {
                        if (tests.size() == int(1e3)) {
                            println(tests.size());
                            for (vector<int> v : tests)
                                println(v);
                        
                            return 0;
                        }
                        tests.push_back({t1, t2, t3, t4, T});
                    }
                }
            }
        }
    }
    
    println(tests.size());
    for (vector<int> v : tests)
        println(v);

    return 0;
}
