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
63
64
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (int a = 0; a < (b); a++)
#define rep1(a, b) for (int a = 1; a <= (b); a++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;

#define LOCAL false

const int MAXN = 5e4 + 7;
int n, s;

bool have[MAXN];
bool present[MAXN];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (LOCAL) {
        ignore=freopen("io/in", "r", stdin);
        ignore=freopen("io/out", "w", stdout);
    }

    cin >> n >> s;
    int x;
    rep(i, s) {
        cin >> x;
        present[x] = true;
    }

    vector<tuple<int, int, int>> oper;
    int idx = n+1;
    bool first = true;
    rep1(x, n) if (have[x]^present[x]) {
        if (first) {
            oper.push_back({2, 1, x});
            for (int y = x; y <= n; y += x) have[y] = true;
            idx++;
            first = false;
            continue;
        }
        if (!have[x]) {
            oper.push_back({1, x, idx-1});
            for (int y = x; y <= n; y += x) have[y] = true;
            idx++;
        } else {
            oper.push_back({3, x, 0});
            idx++;
            oper.push_back({2, idx-2, idx-1});
            idx++;
            for (int y = x; y <= n; y += x) have[y] = false;
        }
    }

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

    return 0;
}