#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  map<int,int>f;
  int cnt=0;
  for(int &i:a){
    cin>>i;
    f[i]++;
  }
  if(f[1]+f[2]<k){
    cout << 0 << endl;
    return 0;
  }
  if(f[1] > f[2]){
    cout << 1 << endl;
  } else {
    map<int,bool>v;
    int band = (1 << 30) - 1;
    int bor = 0;
    for(int i = 0; i < n; ++i){
      cout << band << " " << bor << " " << a[i] << " " << v[1] << " " << v[2] << endl;
      if(a[i]==1){
        bor|=1;
        cout << 1;
        if(v[2]){
          cout << ".1";
          band&=bor;
          bor=0;
          v.clear();
        } else {
          v[a[i]]=1;
        }
        cout << endl;
      } else if(a[i]==2){
        bor|=2;
        cout << 2;
        if (v[1]||v[2]){
          cout << ".1";
          band&=bor;
          bor=0;
          v.clear();
        } else {
          v[a[i]]=1;
        }
        cout << endl;
      }
      cout << band << " " << bor << " " << a[i] << " " << v[1] << " " << v[2] << endl;
    }
    if(bor!=0)band&=bor;
    cout << band << endl;
  }
}