program DISCO2020yE
integer::N
character(4)::S
character,allocatable,dimension(:)::ans
integer Red,Blue,MD
read*,N
allocate(ans(2*N))
write(*,'(A)', advance='no')"?"
do i=1,N
  write(*,'(x,i0)', advance='no') i
end do
write(*,*)
read*,S
select case(S(1:1))
case("R")
    Red=1;Blue=N+1;MD=(Red+Blue)/2
    do while(Blue-Red>1)
        write(*,'(A)', advance='no')"?"
        do i=MD,MD+N-1
            write(*,'(x,i0)', advance='no') i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Red=MD
        case("B")
            Blue=MD
        end select
        MD=(Red+Blue)/2
    end do
    do j=1,Red
     write(*,'(A,i0)', advance='no')"? ",j
        do i=Red+1,Red+N-1
            write(*,'(x,i0)', advance='no') i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Ans(j)="R"
        case("B")
            Ans(j)="B"
        end select
    end do
    do j=Red+N,2*N
        write(*,'(A,i0)', advance='no')"? ",j
        do i=Red+1,Red+N-1
            write(*,'(x,i0)', advance='no') i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Ans(j)="R"
        case("B")
            Ans(j)="B"
        end select
    end do
    do j=Red+1,Red+N-1
        write(*,'(A)', advance='no')"?"
        do i=Red,j-1
            write(*,'(x,i0)', advance='no') i
        end do
        do i=j+1,Red+N
            write(*,'(x,i0)', advance='no') i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Ans(j)="B"
        case("B")
            Ans(j)="R"
        end select
    end do
case("B")
    Blue=1;Red=N+1;MD=(Red+Blue)/2
    do while(Red-Blue>1)
        write(*,'(A,i0)', advance='no')"?"
        do i=MD,MD+N-1
            write(*,'(A,i0)', advance='no') " ",i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Red=MD
        case("B")
            Blue=MD
        end select
        MD=(Red+Blue)/2
    end do
    do j=1,Blue
     write(*,'(A,i0)', advance='no')"? ",j
        do i=Blue+1,Blue+N-1
            write(*,'(A,i0)', advance='no') " ",i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Ans(j)="R"
        case("B")
            Ans(j)="B"
        end select
    end do
    do j=Blue+N,2*N
        write(*,'(A,i0)', advance='no')"? ",j
        do i=Blue+1,Blue+N-1
            write(*,'(x,i0)', advance='no') i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Ans(j)="R"
        case("B")
            Ans(j)="B"
        end select
    end do
    do j=Blue+1,Blue+N-1
        write(*,'(A)', advance='no')"?"
        do i=Blue,j-1
            write(*,'(x,i0)', advance='no') i
        end do
        do i=j+1,Blue+N
            write(*,'(x,i0)', advance='no') i
        end do
        write(*,*)
        read*,S
        select case(S(1:1))
        case("R")
            Ans(j)="B"
        case("B")
            Ans(j)="R"
        end select
    end do
end select
write(*,'(A)', advance='no')"! "
do i=1,2*N
  write(*,'(A)', advance='no') ans(i)
end do
write(*,*)
end program

Measured memory_bytes: 720