#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int flag[1010], sg[1010], ff[1010];
int N, p, f, s, i, j, x, ss, y, z, t, l, S, T, u, use[1010], pre[1010], ans, m,
    n, tot, xx, a[1010];
int v[10010], ne[10010], head[1010], cost[10010], flo[10010], ffl[10010],
    fro[10010], dis[1010];
queue<int> q;
void add(int x, int y, int c, int f) {
  v[++l] = y;
  ne[l] = head[x];
  head[x] = l;
  cost[l] = c;
  flo[l] = f;
  fro[l] = x;
  v[++l] = x;
  ne[l] = head[y];
  head[y] = l;
  cost[l] = -c;
  flo[l] = 0;
  fro[l] = y;
}
bool spfa() {
  q.push(S);
  memset(dis, 63, sizeof(dis));
  ffl[S] = 1e9;
  dis[S] = 0;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    use[u] = 0;
    for (int i = head[u]; i; i = ne[i])
      if (flo[i] && dis[u] + cost[i] < dis[v[i]]) {
        ffl[v[i]] = min(ffl[u], flo[i]);
        dis[v[i]] = dis[u] + cost[i];
        pre[v[i]] = i;
        if (!use[v[i]]) q.push(v[i]), use[v[i]] = 1;
      }
  }
  return dis[T] < 1e9;
}
void flowback(int x) {
  int t = T;
  while (t != S) {
    flo[pre[t]] -= x;
    flo[pre[t] ^ 1] += x;
    t = fro[pre[t]];
  }
}
void min_cost_flow() {
  while (spfa()) {
    flowback(ffl[T]);
    ans += ffl[T] * dis[T];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  ss = 1000;
  l = 1;
  S = n * 2 + 1;
  T = n * 2 + 2;
  add(S, 1, 0, m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    for (t = 0, xx = x; xx; xx >>= 1) t += xx & 1;
    a[i] = x;
    if (mp[x]) add(mp[x] + n, i, (i - mp[x] - 1) * ss, 1);
    mp[x] = i;
    if (i < n)
      add(i + n, i + 1, t, 1), add(i, i + 1, ss, 1e9);
    else
      add(i + n, T, t, 1), add(i, T, ss, 1e9);
    add(i, i + n, 0, 1);
  }
  min_cost_flow();
  ans -= ss * (m - 1) * n;
  for (i = 1; i <= n; i++) {
    for (j = head[i + n]; j; j = ne[j])
      if ((!flo[j]) && (cost[j] == (v[j] - i - 1) * ss))
        flag[i] = 1, sg[v[j]] = i;
    if (!sg[i]) tot++;
    tot++;
  }
  printf("%d %d\n", tot, ans);
  for (i = 1; i <= n; i++) {
    if (!sg[i]) {
      for (j = 0; j < m && use[j]; j++)
        ;
      ff[i] = j;
      use[j] = 1;
      printf("%c=%d\n", j + 'a', a[i]);
    } else
      ff[i] = ff[sg[i]];
    printf("print(%c)\n", ff[i] + 'a');
    if (!flag[i]) use[ff[i]] = 0;
  }
  fclose(stdout);
}
