Mixing proteins
Difficulty: Hard

Some scientists are working on protein recombination, and during their research, they have found a remarkable fact: there are 4 proteins in the protein ring that mutate after every second according to a fixed pattern. For simplicity, proteins are called $A, B, C, D$ (you know, protein names can be very complicated). A protein mutates into another one depending on itself and the protein right after it. Scientists determined that the mutation table goes like this:  

		A	B	C	D
    	_	_	_	_
	A|	A	B	C	D
	B|	B	A	D	C
	C|	C	D	A	B
	D|	D	C	B	A
    
Here rows denote the protein at current position, while columns denote the protein at the next position. And the corresponding value in the table denotes the new protein that will emerge. So for example, **if protein i is A, and protein i + 1 is B, protein i will change to B**. All mutations take place simultaneously. The protein ring is seen as a circular list, so last protein of the list mutates depending on the first protein. 

Using this data, they have written a small simulation software to get mutations second by second. The problem is that the protein rings can be very long (up to 1 million proteins in a single ring) and they want to know the state of the ring after upto $10^9$ seconds. Thus their software takes too long to report the  results. They ask you for your help.  

Input Format:
Input contains 2 lines.   
First line has 2 integers $N$ and $K$, $N$ being the length of the protein ring and $K$ the desired number of seconds.  
Second line contains a string of length $N$ containing uppercase letters $A$,$ B$, $C$ or $D$ only, describing the ring. 

Output Format:
Output a single line with a string of length $N$, describing the state of the ring after $K$ seconds.

Sample Input:

Sample Output:

Python 3 starter code:
#
# Complete the 'pmix' function below.
#
# The function is expected to return a STRING.
# The function accepts following parameters:
#  1. STRING s
#  2. INTEGER k
#

def pmix(s, k):
    # Write your code here




Reference solution (C++):
###C++  
```cpp  
//============================================================================
// Name        : PMIX.cpp
// Author      : Shaka
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cstdio>
#include <cassert>
using namespace std;
typedef unsigned char byte;
const int MAXN = 1e6;
byte S[2][MAXN];
int reverse_bits(int x) {
    x = ((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1);
    x = ((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2);
    x = ((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4);
    x = ((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8);
    x = ((x & 0xffff0000) >> 16) | ((x & 0x0000ffff) << 16);
    return x;
}
int main() {
    register int N, K, i, j, x, rev_x, rev_K;
    char c;
    for (scanf("%d%d\n", &N, &K), i = 0; i < N; ++i) {
        c = getchar();
        assert('A' <= c && c <= 'D');
        S[0][i] = c - 'A';
    }
    assert(1 <= i && i <= MAXN);
    for (rev_K = reverse_bits(K), j = 0; K; K -= x, rev_K -= rev_x, j ^= 1) {
        rev_x = rev_K & -rev_K;
        x = reverse_bits(rev_x);
        for (i = 0; i < N; ++i)
            S[j ^ 1][i] = S[j][i] ^ S[j][(i + x) % N];
    }
    for (i = 0; i < N; ++i) {
        printf("%c", S[j][i] + 'A');
    }
    printf("\n");
    return 0;
}
```