#include <cstdio>#include<iostream>#include<cstring>#include<vector>using namespacestd;Charmap[ the][ the];intn,m;#defineINF 100000structnode{intx, y;}; Vector<node>nn;intMain () { while(1) { inti,j,k; scanf ("%d%d",&n,&m); if(n==0) Break; GetChar (); for(i=1; i<=n;i++) { for(j=1; j<=m;j++) scanf ("%c",&Map[i][j]); GetChar (); } for(k=0;k< -; k++) {nn.clear (); intmaxx=0, maxy=0, minx=inf,miny=inf; Charx='A'+K; intflag=1; for(i=1; i<=n;i++) for(j=1; j<=m;j++) if(map[i][j]==x) {node tmp; Tmp.x=i; TMP.Y=J; Nn.push_back (TMP); } for(i=0; I<nn.size (); i++) { if(Nn[i].x>maxx) maxx=nn[i].x; if(Nn[i].x<minx) minx=nn[i].x; if(Nn[i].y>maxy) maxy=nn[i].y; if(Nn[i].y<miny) miny=nn[i].y; } if(maxx<minx+2)Continue;//printf ("AAA"); if(maxy<miny+2)Continue; if(Nn.size ()! = (maxx-minx+maxy-miny) *2) flag=0; for(i=minx+1; i<maxx;i++) for(j=miny+1; j<maxy;j++) if(Isupper (Map[i][j])) {flag=0; Break; } if(flag) printf ("%c", x); } printf ("\ n"); } return 0;}