1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;

bitset<50005> B, C;

struct Oper {
    int type, x, y;
};

int main() {
    ios_base::sync_with_stdio(0);
    int n, s;
    cin>>n>>s;
    for(int i=0;i<s;i++) {
        int a;
        cin>>a;
        B[a] = 1;
    }

    vector<Oper> ans;
    for(int i=1;i<=n;i++) {
        if(i == 1) {
            if(B[1]) {
                ans.push_back({1, 1, 1});
                for(int j=1;j<=n;j++) C[j] = 1;
            }
            else {
                ans.push_back({3, 1, 0});
            }
        }
        else {
            if(B[i] == C[i]) continue;
            if(B[i] && !C[i]) {
                bitset<50005> tmp;
                for(int j=i;j<=n;j+=i) tmp[j] = 1;
                C |= tmp;
                int sz = ans.size();
                ans.push_back({1, i, sz+n});
            }
            else {
                bitset<50005> tmp;
                for(int j=i;j<=n;j+=i) tmp[j] = 1;
                C &= (~tmp);
                int sz = ans.size();
                ans.push_back({3, i, 0});
                ans.push_back({2, sz+n+1, sz+n});
            }
        }
    }

    cout<<ans.size()<<endl;
    for(auto [t, x, y]: ans) {
        if(t == 3) cout<<t<<" "<<x<<"\n";
        else cout<<t<<" "<<x<<" "<<y<<"\n";
    }
}