void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int h, w; rd(h, w);
  int[char] cnt;
  for(char c='a'; c<='z'; c++) cnt[c]=0;
  foreach(_; 0..h){
    auto s=readln.chomp;
    foreach(char c; s) cnt[c]++;
  }

  auto a=new int[](0);
  foreach(v; cnt.values){
    if(v) a~=v;
  }
  sort(a);
  writeln(a);

  auto b=new int[](0);
  auto y=(h+1)/2, x=(w+1)/2;
  foreach(i; 0..y)foreach(j; 0..x){
    if(i+1!=y && j+1!=x) b~=4;
    else if(i+1==y && j+1==x){
      if(h%2==0 && w%2==0) b~=4;
      else if(h%2 && w%2) b~=1;
      else b~=2;
    }else if(i+1==y) b~=(h%2==0 ? 4 : 2);
    else b~=(w%2==0 ? 4 : 2);
  }
  sort!("a>b")(b);
  writeln(b);

  const inf=to!int(1e8);
  foreach(ref e; a){
    foreach(ref e2; b){
      if(e2<=e) e-=e2, e2=inf;
    }
  }

  writeln(a);
  writeln(b);

  int sm=reduce!("a+b")(a);
  if(sm==0){
    foreach(e; b) assert(e==inf);
    writeln("Yes");
  }else{
    writeln("No");
  }

  
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}