Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)
const INF = 0x7FFFFFFF

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		n, _ := strconv.Atoi(buf[0])
		m, _ := strconv.Atoi(buf[1])
		if n == 0 && m == 0 {
			break
		}
		chairs := make([]string, n)
		for i := range chairs {
			chairs[i] = "#"
		}
		sit := func(who string) {
			if who == "A" {
				chairs[getStringIndex(chairs, "#")] = "A" // A国の人は左から見て行って空いている席を見つけ次第座る
				// log.Println(chairs)
			} else if who == "B" {
				f := true
				for i := n-1; i > -1; i-- {
					// B国の人はA国人の隣以外で、右端から空いている椅子に座る
					if chairs[i] == "#" && (i == 0 || chairs[i-1] != "A") && (i == n-1 || chairs[i+1] != "A") {
								chairs[i] = "B"
								f = false
								break
					}
				}
				// A国人の隣しか空いていない場合、我慢して左端から空いている椅子に座る
				if f {
					chairs[getStringIndex(chairs, "#")] = "B"
				}
				// log.Println(chairs)
			} else if who == "C" { // C国人は人の隣に座りたい
				for i := 0; i < n; i++ {
					if chairs[i] != "#" {
						if i + 1 <= n-1 && chairs[i+1] == "#" {
							chairs[i+1] = "C"
							break
						} else if i - 1 >= 0 && chairs[i-1] == "#" {
							chairs[i-1] = "C"
							break
						}
					}
				}
				// log.Println(chairs)
			} else { // who == "D"
				// D国の人は人から離れて座りたい
				// どうしても誰かの隣に座らなければならない場合、その中で一番左側にある椅子に座る
				scores := make([]int, n)
				for i := range scores {
					scores[i] = INF
				}
				for i, v := range chairs {
					if v == "#" {
						scores[i]++
					}
				}
				for i := n-1; i > -1; i-- {
					tmp := 0
					if chairs[i] == "#" {
						tmp++
					} else {
						tmp = 0
					}
					scores[i] = min(scores[i], tmp)
				}
				chairs[getIntIndex(scores, getMax(scores))] = "D"
				// log.Println(chairs)
			}
		}
		scanner.Scan()
		if first := scanner.Text(); first == "A" || first == "D" {
			chairs[0] = first
		} else if first == "B" {
			chairs[len(chairs)-1] = "B"
		} else {
			chairs[n/2] = "C"
		}
		// log.Println(chairs)
		for i := 0; i < m-1; i++ {
			scanner.Scan()
			sit(scanner.Text())
		}
		fmt.Println(strings.Join(chairs, ""))
	}
}

func getStringIndex(chairs []string, who string) int {
	for i, v := range chairs {
		if v == who {
			return i
		}
	}
	return -1
}

func getIntIndex(scores []int, target int) int {
	for i, v := range scores {
		if v == target {
			return i
		}
	}
	return -1
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func getMax(scores []int) int {
	tmp := -1
	for _, v := range scores {
		if tmp < v {
			tmp = v
		}
	}
	return tmp
}

C++: #include <iostream>
#include <set>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef pair<int,int> P;
int chair[10002];
int n,m;
void A(){
	int ans=0;
	while(chair[ans]!=0)ans++;
	chair[ans]=1;
	return;
}
void B(){
	for(int i=n-1;i>=0;i--){
		if(chair[i]==0){
			if(i==0&&chair[1]!=1){chair[0]=2;return;}
			else if(i==n-1&&chair[n-2]!=1){chair[n-1]=2;return;}
			else if(0<i&&i<n-1&&chair[i-1]!=1&&chair[i+1]!=1){chair[i]=2;return;}
		}
	}
	int ans=0;
	while(chair[ans]!=0)ans++;
	chair[ans]=2;
	return;
}
void C(){
	int ans=0;
	if(chair[0]!=0){
		while(chair[ans]!=0)ans++;
		chair[ans]=3;
		return;
	}
	chair[n]=5;
	for(int i=0;i<n;i++){
		if(chair[i]!=0){
			if(chair[i+1]==0)chair[i+1]=3;
			else chair[i-1]=3;
			return;
		}
	}
	if(n%2)chair[(n+1)/2-1]=3;
	else chair[n/2]=3;
	return;
}
void D(){
	int a=0,f=0;
	P bl[5000];
	bool in=false;
	chair[n]=5;
	for(int i=0;i<=n;i++){
		if(in&&chair[i]!=0){
			in=false;bl[a++]=P(f,i);
		}else if(!in&&chair[i]==0){
			in=true;f=i;
		}
	}
	//for(int i=0;i<a;i++)printf("bl[%d]:[%d,%d)\n",i,bl[i].first,bl[i].second);
	if(bl[0].first==0&&bl[0].second==n){
		chair[0]=4;return;
	}else{
		int m,mlen=0;
		for(int i=0;i<a;i++){
			if(bl[i].second-bl[i].first>mlen){
				mlen=bl[i].second-bl[i].first;m=i;
			}
		}
		if(mlen%2){
			chair[bl[m].first+(mlen-1)/2]=4;return;
		}else{
			chair[bl[m].first+mlen/2-1]=4;return;
		}
	}
}
int main()
{
	while(cin>>n>>m&&(n||m)){
		fill(chair,chair+n,0);
		chair[n]=5;
		while(m--){
			char c;cin>>c;
			if(c=='A')A();
			if(c=='B')B();
			if(c=='C')C();
			if(c=='D')D();
		}
		for(int i=0;i<n;i++){
			if(chair[i]==0)cout<<'#';
			if(chair[i]==1)cout<<'A';
			if(chair[i]==2)cout<<'B';
			if(chair[i]==3)cout<<'C';
			if(chair[i]==4)cout<<'D';
		}
		cout<<endl;
	}
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int seki[111];

main(){
  int m,n;
  while(cin>>n>>m,n|m){
    string seat;
    rep(i,n)seat+='#';

    rep(i,m){
      cout<<seat<<" "<<m-i<<endl;
      char c;
      int pos=0;
      cin>>c;
      switch(c){
      case 'A':
	pos=0;
	while(seat[pos]!='#')++pos;
	seat[pos]='A';
	break;
      case 'B':
	pos=n-1;
	while(true){
	  if(pos<0)break;
	  if(seat[pos]!='#'){
	    --pos;
	    continue;
	  }
	  if(pos && seat[pos-1]=='A'){
	    --pos;
	    continue;
	  }
	  if(pos+1<n && seat[pos+1]=='A'){
	    --pos;
	    continue;
	  }
	  seat[pos]='B';
	  break;
	}
	if(pos==-1){
	  pos=0;
	  while(seat[pos]!='#')++pos;
	  seat[pos]='B';
	}
	break;
      case 'C':
	if(i==0){
	  if(n%2)seat[(n+1)/2-1]='C';
	  else seat[n/2]='C';
	}else{
	  pos=0;
	  while(seat[pos]!='#')++pos;
	  if(pos)seat[pos]='C';
	  else{
	    pos=0;
	    while(seat[pos]=='#')++pos;
	    seat[pos-1]='C';
	  }
	}
	break;
      case 'D':
	if(i==0){
	  seat[0]='D';
	  continue;
	}
	memset(seki,0,sizeof(0));
	int maxt=0,maxpos=0;

	if(seat[0]=='#'){
	  seki[0]=1;
	  maxt=1;
	  maxpos=1;
	}
	pos=1;
	while(pos<n){
	  if(seat[pos]=='#')seki[pos]=seki[pos-1]+1;
	  else seki[pos]=0;
	  if(seki[pos]>maxt){
	    maxt=seki[pos];
	    maxpos=pos;
	  }
	  ++pos;
	}
	//rep(j,n)cout<<seki[j]<<" ";
	//cout<<endl;
	//cout<<maxpos<<" "<<maxt<<endl;
	if(maxpos==n-1)seat[n-1]='D';
	else if(maxpos==maxt-1)seat[0]='D';
	else if(maxt%2)seat[maxpos-maxt/2]='D';
	else seat[maxpos-maxt/2]='D';
	break;
      }
    }
    cout<<seat<<endl;
  }
}