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
58
59
60
61
62
#include <bits/stdc++.h>
#pragma GCC target("popcnt")
using namespace std;
typedef long long LL;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, s;
	vector<bitset<50001>> b(150003);
	cin>>n>>s;
	for(int i=1; i<=n; i++){
		for(int j=i; j<=n; j+=i){
				b[i][j]=true;
		}
	}
	if(n==1){
		cout<<"0\n";
		return 0;
	}
	int i = 1;
	int m = 1;
	vector<tuple<int, int, int>> res;
	b[n+1] = b[1];
	res.push_back({1, 1, 2});
	while(s--){
		int x;
		cin>>x;
		for(; i<x; i++){
			if(b[n+m][i]==true){
				res.push_back({3, i, 0});
				b[n+m+1] = ~b[i];
				res.push_back({2, n+m, n+m+1});
				b[n+m+2] = b[n+m] & b[n+m+1];
				m+=2;
			}
		}
		if(b[n+m][x]==false){
			res.push_back({1, n+m, x});
			b[n+m+1] = b[n+m] | b[x];
			m++;
		}
		i++;
	}
	for(; i<=n; i++){
		if(b[n+m][i]==true){
			res.push_back({3, i, 0});
			b[n+m+1] = ~b[i];
			res.push_back({2, n+m, n+m+1});
			b[n+m+2] = b[n+m] & b[n+m+1];
			m+=2;
		}
	}
	cout<<m<<"\n";
	for(auto [a, b, c] : res){
		if(a!=3)cout<<a<<" "<<b<<" "<<c<<"\n";
		else cout<<a<<" "<<b<<"\n";
	}
	return 0;
}