/*
找出当前界面的 x,y 的左右坐标 枚举边界,并且判断界面内是否全为‘.’
*/
#include<cstdio>
#include<cstring> #include<algorithm> #define INF 1<<30 using namespace std; char s[110][110]; int aph[30],n,m,ln; int judge(int x) { int lx,ly,rx,ry; lx = ly = INF; rx = ry = -1; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) { if(s[i][j]==x+'A') { lx = min(lx,i); ly = min(ly,j); rx = max(rx,i); ry = max(ry,j); } } if(lx==INF||ly==INF||rx==-1||ry==-1||rx-lx<2||ry-ly<2) { return 0; } for(int i = lx; i <= rx; i++) if(s[i][ly]!=x+'A'||s[i][ry]!=x+'A') return 0; for(int i = ly; i <= ry; i++) if(s[lx][i]!=x+'A'||s[rx][i]!=x+'A') return 0; for(int i = lx+1; i < rx; i++) for(int j = ly+1; j < ry; j++) if(s[i][j]!='.') return 0; return 1; } int solve() { memset(aph,0,sizeof(aph)); for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) if(s[i][j]!='.') aph[s[i][j]-'A']++; for(int i = 0; i < 26; i++) { if(!aph[i]) continue; if(judge(i)) printf("%c",i+'A'); } } int main() { while(scanf("%d%d",&n,&m)==2) { if(!n&&!m) break; for(int i = 0; i < n; i++) scanf("%s",&s[i]); solve(); printf("\n"); } return 0; }