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
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#ifdef LOCAL
auto operator<<(auto& o, auto x) -> decltype(x.first, o);
auto operator<<(auto& o, auto x) -> decltype(x.end(), o) {
  o << "{";
  for (int i = 0; auto y : x) o << ", " + !i++ * 2 << y;
  return o << "}"; }
auto operator<<(auto& o, auto x) -> decltype(x.first, o) {
  return o << "(" << x.first << ", " << x.second << ")"; }
void __print(auto... x) { ((cerr << x << " "), ...) << endl; }
#define debug(x...) __print("[" #x "]:", x)
#else
#define debug(...) 2137
#endif

const int N = 50050;
int n, s;
int a[N], b[N];
vector<array<int, 3>> odp;
int id;

int suma(int x, int y) {
  odp.push_back({1, x, y});
  return id++;
}
int prz(int x, int y) {
  odp.push_back({2, x, y});
  return id++;
}
int neg(int x) {
  odp.push_back({3, x, 0});
  return id++;
}

#ifdef LOCAL
using B = bitset<N>;
void spr() {
  vector<B> v;
  int m = sz(odp);
  v.resize(n + m);
  rep(i, 0, n) {
    for (int j = i + 1; j <= n; j += i + 1) v[i][j] = 1;
  }
  rep(i, 0, m) {
    auto [t, x, y] = odp[i];
    if (t == 1) {
      x--; y--;
      v[n + i] = v[x] | v[y];
    } else if (t == 2) {
      x--; y--;
      v[n + i] = v[x] & v[y];
    } else {
      x--;
      v[n + i] = ~v[x];
    }
  }
  rep(i, 1, n + 1) {
    assert(v[n + m - 1][i] == b[i]);
  }
}
#endif

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> s;
  int fi = n;
  rep(i, 0, s) {
    int x;
    cin >> x;
    b[x] = 1;
    fi = min(fi, x);
  }
  id = n + 1;
  int t = suma(fi, fi);
  for (int i = fi; i <= n; i += fi) a[i] = 1;
  rep(i, fi + 1, n + 1) {
    if (a[i] == 1 && b[i] == 0) {
      t = prz(t, neg(i));
      for (int j = i; j <= n; j += i) a[j] = 0;
    } else if (a[i] == 0 && b[i] == 1) {
      t = suma(t, i);
      for (int j = i; j <= n; j += i) a[j] = 1;
    }
  }
  assert(sz(odp) <= 100'000);
  cout << sz(odp) << '\n';
  for (auto [x, y, z] : odp) {
    cout << x << ' ' << y;
    if (x != 3) cout << ' ' << z;
    cout << '\n';
  }
#ifdef LOCAL
  spr();
#endif
}