#include using namespace std; typedef long long LL; const int nmax = 200010; const LL mod = 1000000007; int N,v[nmax],M; char ch[1000]; char x1,x2; int main(void){ LL i,j,urm,x,cnt,w; // freopen("txt.in","r",stdin); // freopen("txt.out","w",stdout); // ios::sync_with_stdio(false); cin >> N >> M; i = 1; while(cin >> ch){ int lg = strlen(ch); for(j = 1; j < lg-1; j+=2){ x1 = ch[j]; x2 = ch[j+1]; if(x1 == x2) continue; if(x1 < x2) ch[j+1] = x1; else ch[j] = x2; } for(j = 0; j < lg; j+=2) cout << ch[j]; if(i%M==0) cout << '\n'; else cout <<' '; ++i; } return 0; }