#define LOCAL

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define ECH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)
#pragma comment(linker, "/STACK:36777216")
//#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Pascal system("fpc main.pas")

typedef long long LL;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

inline int RD(){ int x; RD(x); return x;}
template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline void RC(char &c){scanf(" %c", &c);}
inline void RS(char *s){scanf("%s", s);}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}

template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const LL INF_64 = 0x3f3f3f3f3f3f3f3fLL;
const DB EPS = 1e-11;
const DB OO = 1e15;
const DB PI = 3.14159265358979323846264; //M_PI;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(min(a, b), max(c, d));}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,
inline bool _1(int x, int i){return x & 1<<i;}
inline bool _1(LL x, int i){return x & 1LL<<i;}
inline LL _1(int i){return 1LL<<i;}
//inline int _1(int i){return 1<<i;}
inline LL _U(int i){return _1(i) - 1;};
//inline int _U(int i){return _1(i) - 1;};

template<class T> inline T low_bit(T x) {
    return x & -x;
}

template<class T> inline T high_bit(T x) {
    T p = low_bit(x);
    while (p != x) x -= p, p = low_bit(x);
    return p;
}

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

inline int count_bits(LL x){
    x = (x & 0x5555555555555555LL) + ((x & 0xaaaaaaaaaaaaaaaaLL) >> 1);
    x = (x & 0x3333333333333333LL) + ((x & 0xccccccccccccccccLL) >> 2);
    x = (x & 0x0f0f0f0f0f0f0f0fLL) + ((x & 0xf0f0f0f0f0f0f0f0LL) >> 4);
    x = (x & 0x00ff00ff00ff00ffLL) + ((x & 0xff00ff00ff00ff00LL) >> 8);
    x = (x & 0x0000ffff0000ffffLL) + ((x & 0xffff0000ffff0000LL) >> 16);
    x = (x & 0x00000000ffffffffLL) + ((x & 0xffffffff00000000LL) >> 32);
    return x;
}

int reverse_bits(int x){
    x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);
    x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
    x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);
    x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
    x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);
    return x;
}

LL reverse_bits(LL x){
    x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);
    x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);
    x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);
    x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);
    x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);
    x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);
    return x;
}

// <<= ` 2. Modular Arithmetic Basic .,

inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}
inline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}
inline int sqr_M(int a){return pdt(a, a);}

inline int pow(int a, int b){
    int c = 1;
    while (b) {
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

template<class T>
inline int pow(T a, int b){
    T c(1);
    while (b) {
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

inline int _I(int b){
    int a = MOD, x1 = 0, x2 = 1, q;
    while (true){
        q = a / b, a %= b;
        if (!a) return (x2 + MOD) % MOD;
        DEC(x1, pdt(q, x2));

        q = b / a, b %= a;
        if (!b) return (x1 + MOD) % MOD;
        DEC(x2, pdt(q, x1));
    }
}

inline void DIV(int &a, int b){MUL(a, _I(b));}
inline int qtt(int a, int b){return pdt(a, _I(b));}

inline int sum(int a, int b, int MOD){
    a += b; if (a >= MOD) a -= MOD;
    return a;
}

inline int phi(int n){
    int res = n;
    for (int i=2;sqr(i)<=n;++i) if (!(n%i)){
        DEC(res, qtt(res, i));
        do{n /= i;} while(!(n%i));
    }
    if (n != 1)
        DEC(res, qtt(res, n));
    return res;
}

// <<= '9. Comutational Geometry .,

struct Po; struct Line; struct Seg;

inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);}
inline bool equ(DB x, DB y){return !sgn(x, y);}

struct Po{
    DB x, y;
    Po(DB _x = 0, DB _y = 0):x(_x), y(_y){}

    friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}
    friend ostream& operator <<(ostream& out, Po p){return out << "(" << p.x << ", " << p.y << ")";}

    friend bool operator ==(Po, Po);
    friend bool operator !=(Po, Po);
    friend Po operator +(Po, Po);
    friend Po operator -(Po, Po);
    friend Po operator *(Po, DB);
    friend Po operator /(Po, DB);

    bool operator < (const Po &rhs) const{return sgn(x, rhs.x) < 0 || sgn(x, rhs.x) == 0 && sgn(y, rhs.y) < 0;}
    Po operator-() const{return Po(-x, -y);}
    Po& operator +=(Po rhs){x += rhs.x, y += rhs.y; return *this;}
    Po& operator -=(Po rhs){x -= rhs.x, y -= rhs.y; return *this;}
    Po& operator *=(DB k){x *= k, y *= k; return *this;}
    Po& operator /=(DB k){x /= k, y /= k; return *this;}

    DB length_sqr(){return sqr(x) + sqr(y);}
    DB length(){return sqrt(length_sqr());}

    DB atan(){
        return atan2(y, x);
    }

    void input(){
        scanf("%lf %lf", &x, &y);
    }
};

bool operator ==(Po a, Po b){return sgn(a.x - b.x) == 0 && sgn(a.y - b.y) == 0;}
bool operator !=(Po a, Po b){return sgn(a.x - b.x) != 0 || sgn(a.y - b.y) != 0;}
Po operator +(Po a, Po b){return Po(a.x + b.x, a.y + b.y);}
Po operator -(Po a, Po b){return Po(a.x - b.x, a.y - b.y);}
Po operator *(Po a, DB k){return Po(a.x * k, a.y * k);}
Po operator *(DB k, Po a){return a * k;}
Po operator /(Po a, DB k){return Po(a.x / k, a.y / k);}

struct Line{
    Po a, b;
    Line(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}
    Line(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}
    Line(Seg);

    friend ostream& operator <<(ostream& out, Line p){return out << p.a << "-" << p.b;}
};

struct Seg{
    Po a, b;
    Seg(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}
    Seg(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}
    Seg(Line l);

    friend ostream& operator <<(ostream& out, Seg p){return out << p.a << "-" << p.b;}
    DB length(){return (b - a).length();}
};

Line::Line(Seg l):a(l.a), b(l.b){}
Seg::Seg(Line l):a(l.a), b(l.b){}

#define innerProduct dot
#define scalarProduct dot
#define dotProduct dot
#define outerProduct det
#define crossProduct det

inline DB dot(DB x1, DB y1, DB x2, DB y2){return x1 * x2 + y1 * y2;}
inline DB dot(Po a, Po b){return dot(a.x, a.y, b.x, b.y);}
inline DB dot(Po p0, Po p1, Po p2){return dot(p1 - p0, p2 - p0);}
inline DB dot(Line l1, Line l2){return dot(l1.b - l1.a, l2.b - l2.a);}
inline DB det(DB x1, DB y1, DB x2, DB y2){return x1 * y2 - x2 * y1;}
inline DB det(Po a, Po b){return det(a.x, a.y, b.x, b.y);}
inline DB det(Po p0, Po p1, Po p2){return det(p1 - p0, p2 - p0);}
inline DB det(Line l1, Line l2){return det(l1.b - l1.a, l2.b - l2.a);}

template<class T1, class T2> inline DB dist(T1 x, T2 y){return sqrt(dist_sqr(x, y));}

inline DB dist_sqr(Po a, Po b){return sqr(a.x - b.x) + sqr(a.y - b.y);}
inline DB dist_sqr(Po p, Line l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}
inline DB dist_sqr(Po p, Seg l){
    Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;
    if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));
    else return min(v1.length_sqr(), v2.length_sqr());
}

inline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}
inline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}

inline DB dist_sqr(Line l1, Line l2){
    if (sgn(det(l1, l2)) != 0) return 0;
    return dist_sqr(l1.a, l2);
}
inline DB dist_sqr(Line l1, Seg l2){
    Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);
    return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();
}

bool isIntersect(Seg l1, Seg l2){

    //if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;

    return
        min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&
        min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&
        min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&
        min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&
    sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&
    sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;

}

inline DB dist_sqr(Seg l1, Seg l2){
    if (isIntersect(l1, l2)) return 0;
    else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));
}

inline bool isOnExtremePoint(const Po &p, const Seg &l){
    return p == l.a || p == l.b;
}

inline bool isOnseg(const Po &p, const Seg &l){

    //if (p == l.a || p == l.b) return false;

    return sgn(det(p, l.a, l.b)) == 0 &&
        sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;
}

inline Po intersect(const Line &l1, const Line &l2){
    return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));
}

// perpendicular foot
inline Po intersect(const Po & p, const Line &l){
    return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);
}

inline Po rotate(Po p, DB alpha, Po o = Po()){
    p.x -= o.x, p.y -= o .y;
    return Po(p.x * cos(alpha) - p.y * sin(alpha), p.y * cos(alpha) + p.x * sin(alpha)) + o;
}

// <<= ' A. Random Event ..

inline int rand32(){return (bool(rand() & 1) << 30) | (rand() << 15) + rand();}
inline int random32(int l, int r){return rand32() % (r - l + 1) + l;}
inline int random(int l, int r){return rand() % (r - l + 1) + l;}
int dice(){return rand() % 6;}
bool coin(){return rand() % 2;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    scanf("%d", &x);
    //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

template<class T> inline void OT(const T &x){
    printf("%d\n", x);
}

/* .................................................................................................................................. */

const int N = 1000009;

int F0[N], F1[N], G0[N], G1[N]; char s[N];
int L[N], R[N], n, k, k_, l, r;

int main(){

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

    RD(n, k); RS(s+1); k_ = k + 1;

	REP_1(i, n) L[i] = L[i-1] + (s[i]=='X');
	DWN_1(i, n, 1) R[i] = R[i+1] + (s[i]=='X');

    l = 0, r = 0; REP_1(i, n){
        if (s[i] == 'X' || s[i] == 'B') ++r; else l = r = i;
        F1[i] = sum(pdt(s[i] == 'X' ? 2 : 1, F1[i-1]), F0[i] = r-l>=k && s[i-k] != 'B' ? dff(pow(2, L[i-k_]), F1[i-k_]) : 0);
        cout << F0[i] << " " << F1[i] << endl;
    }

    l = n+1, r = n+1; DWN_1(i, n, 1){
        if (s[i] == 'X' || s[i] == 'W') --l; else r = l = i;
        G1[i] = sum(pdt(s[i] == 'X' ? 2 : 1, G1[i+1]), G0[i] = r-l>=k && s[i+k] != 'W' ? dff(pow(2, R[i+k_]), G1[i+k_]) : 0);
    }

    int res = 0; FOR(i, 1, n) INC(res, pdt(F0[i], G1[i+1]));
    OT(res);
}


#define LOCAL

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define ECH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

// <<= ' A. Random Event ..

inline int rand32(){return (bool(rand() & 1) << 30) | (rand() << 15) + rand();}
inline int random32(int l, int r){return rand32() % (r - l + 1) + l;}
inline int random(int l, int r){return rand() % (r - l + 1) + l;}
int dice(){return rand() % 6;}
bool coin(){return rand() % 2;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    cin >> x;
    //scanf("%d", &x);
    //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

template<class T> inline void OT(const T &x){
    //printf("%d\n", x);

}

/* .................................................................................................................................. */

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string.h>

const int N=2000010;
const int inf=0x3f3f3f3f;
const long long mod=1000000007ll;

using namespace std;

int n,k;
char s[N];
long long p[N],suml[N],sumr[N],b[N],w[N],sb[N],sw[N];

int main(){

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

	p[0]=1;
	for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
	scanf("%d%d%s",&n,&k,&s[1]);
	for(int i=1;i<=n;i++)
		suml[i]=suml[i-1]+(s[i]=='X');
	for(int i=n;i>=1;i--)
		sumr[i]=sumr[i+1]+(s[i]=='X');
	for(int i=1,l=0,r=0;i<=n;i++)
	{
		if(s[i]=='X' || s[i]=='B') r++;
		else l=r=i;
		if(r-l>=k && s[i-k]!='B') b[i]=p[suml[i-k-1]]-sb[i-k-1];
		else b[i]=0;b[i]%=mod;
		if(s[i]=='X') sb[i]=(2*sb[i-1]+b[i])%mod;
		else sb[i]=(sb[i-1]+b[i])%mod;
	}
	for(int i=n,l=n+1,r=n+1;i>=1;i--)
	{
		if(s[i]=='X' || s[i]=='W') l--;
		else r=l=i;
		if(r-l>=k && s[i+k]!='W') w[i]=p[sumr[i+k+1]]-sw[i+k+1];
		else w[i]=0;w[i]%=mod;
		if(s[i]=='X') sw[i]=(2*sw[i+1]+w[i])%mod;
		else sw[i]=(sw[i+1]+w[i])%mod;
	}
	long long ret=0;
	for(int i=1;i<n;i++){
		ret+=b[i]*sw[i+1],ret%=mod;
	}
	cout<<(ret+mod)%mod<<endl;
	return 0;
}


#define LOCAL

/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)
#define REP_C(i, n) for (int n____=int(n),i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=int(b),i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=int(a),i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<int(n);++i)
#define FOR_N(i, a, b) for (i=int(a);i<int(b);++i)
#define DWN_N(i, b, a) for (i=int(b-1);i>=int(a);--i)
#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=int(n);++i)
#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)
#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)
#define REP_C_N(i, n) for (n____=int(n),i=0;i<n____;++i)
#define FOR_C_N(i, a, b) for (b____=int(b),i=a;i<b____;++i)
#define DWN_C_N(i, b, a) for (a____=int(a),i=b-1;i>=a____;--i)
#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)

#define ECH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define DO(n) while(n--)
#define DO_C(n) int n____ = n; while(n____--)
#define TO(i, a, b) int s_=a<b?1:-1,b_=b+s_;for(int i=a;i!=b_;i+=s_)
#define TO_1(i, a, b) int s_=a<b?1:-1,b_=b;for(int i=a;i!=b_;i+=s_)
#define SQZ(i, j, a, b) for (int i=int(a),j=int(b)-1;i<j;++i,--j)
#define SQZ_1(i, j, a, b) for (int i=int(a),j=int(b);i<=j;++i,--j)
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)

#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define BSC(A, X) find(ALL(A), X) // != A.end()
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int(A.size())
#define PB push_back
#define MP(A, B) make_pair(A, B)

#define Rush int T____; RD(T____); DO(T____)
#pragma comment(linker, "/STACK:36777216")
//#pragma GCC optimize ("O2")
#define Ruby system("ruby main.rb")
#define Haskell system("runghc main.hs")
#define Pascal system("fpc main.pas")

typedef long long LL;
typedef double DB;
typedef unsigned UINT;
typedef unsigned long long ULL;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VD;
typedef set<int> SI;
typedef set<string> SS;
typedef set<LL> SL;
typedef set<DB> SD;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef map<LL, int> MLI;
typedef map<DB, int> MDI;
typedef map<int, bool> MIB;
typedef map<string, bool> MSB;
typedef map<LL, bool> MLB;
typedef map<DB, bool> MDB;
typedef pair<int, int> PII;
typedef pair<int, bool> PIB;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
typedef set<PII> SII;
typedef map<PII, int> MPIII;
typedef map<PII, bool> MPIIB;

/** I/O Accelerator **/

/* ... :" We are I/O Accelerator ... Use us at your own risk ;) ... " .. */

template<class T> inline void RD(T &);
template<class T> inline void OT(const T &);

inline int RD(){ int x; RD(x); return x;}
template<class T> inline T& _RD(T &x){ RD(x); return x;}
inline void RC(char &c){scanf(" %c", &c);}
inline void RS(char *s){scanf("%s", s);}

template<class T0, class T1> inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}
template<class T0, class T1, class T2> inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}
template<class T0, class T1, class T2, class T3> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}
template<class T0, class T1> inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}
template<class T0, class T1, class T2> inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}
template<class T0, class T1, class T2, class T3> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}
template<class T0, class T1, class T2, class T3, class T4> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}

template<class T> inline void RST(T &A){memset(A, 0, sizeof(A));}
template<class T0, class T1> inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}
template<class T0, class T1, class T2> inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}
template<class T0, class T1, class T2, class T3> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}

template<class T> inline void CLR(priority_queue<T, vector<T>, less<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(priority_queue<T, vector<T>, greater<T> > &Q){
    while (!Q.empty()) Q.pop();
}

template<class T> inline void CLR(T &A){A.clear();}
template<class T0, class T1> inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}
template<class T0, class T1, class T2> inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}
template<class T0, class T1, class T2, class T3> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}
template<class T> inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}
template<class T> inline void FLC(T &A, int x){memset(A, x, sizeof(A));}
template<class T0, class T1> inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}
template<class T0, class T1, class T2> inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}
template<class T0, class T1, class T2, class T3> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}
template<class T0, class T1, class T2, class T3, class T4> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}
template<class T0, class T1, class T2, class T3, class T4, class T5> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6> inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}

template<class T> inline void SRT(T &A){sort(ALL(A));}
template<class T, class C> inline void SRT(T &A, C B){sort(ALL(A), B);}

/** Add - On **/

int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const LL INF_64 = 0x3f3f3f3f3f3f3f3fLL;
const DB EPS = 1e-11;
const DB OO = 1e15;
const DB PI = 3.14159265358979323846264; //M_PI;

// <<= ` 0. Daily Use .,

template<class T> inline void checkMin(T &a,const T b){if (b<a) a=b;}
template<class T> inline void checkMax(T &a,const T b){if (b>a) a=b;}
template <class T, class C> inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}
template <class T, class C> inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}
template<class T> inline T min(T a, T b, T c){return min(min(a, b), c);}
template<class T> inline T max(T a, T b, T c){return max(max(a, b), c);}
template<class T> inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}
template<class T> inline T max(T a, T b, T c, T d){return max(min(a, b), max(c, d));}
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T cub(T a){return a*a*a;}
int Ceil(int x, int y){return (x - 1) / y + 1;}

// <<= ` 1. Bitwise Operation .,
inline bool _1(int x, int i){return x & 1<<i;}
inline bool _1(LL x, int i){return x & 1LL<<i;}
inline LL _1(int i){return 1LL<<i;}
//inline int _1(int i){return 1<<i;}
inline LL _U(int i){return _1(i) - 1;};
//inline int _U(int i){return _1(i) - 1;};

template<class T> inline T low_bit(T x) {
    return x & -x;
}

template<class T> inline T high_bit(T x) {
    T p = low_bit(x);
    while (p != x) x -= p, p = low_bit(x);
    return p;
}

inline int count_bits(int x){
    x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);
    x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);
    x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);
    x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);
    x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);
    return x;
}

inline int count_bits(LL x){
    x = (x & 0x5555555555555555LL) + ((x & 0xaaaaaaaaaaaaaaaaLL) >> 1);
    x = (x & 0x3333333333333333LL) + ((x & 0xccccccccccccccccLL) >> 2);
    x = (x & 0x0f0f0f0f0f0f0f0fLL) + ((x & 0xf0f0f0f0f0f0f0f0LL) >> 4);
    x = (x & 0x00ff00ff00ff00ffLL) + ((x & 0xff00ff00ff00ff00LL) >> 8);
    x = (x & 0x0000ffff0000ffffLL) + ((x & 0xffff0000ffff0000LL) >> 16);
    x = (x & 0x00000000ffffffffLL) + ((x & 0xffffffff00000000LL) >> 32);
    return x;
}

int reverse_bits(int x){
    x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);
    x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);
    x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);
    x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);
    x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);
    return x;
}

LL reverse_bits(LL x){
    x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);
    x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);
    x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);
    x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);
    x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);
    x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);
    return x;
}

// <<= ` 2. Modular Arithmetic Basic .,

inline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}
inline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}
inline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}
inline int dff(int a, int b){a -= b; if (a < 0) a  += MOD; return a;}
inline void MUL(int &a, int b){a = (LL)a * b % MOD;}
inline int pdt(int a, int b){return (LL)a * b % MOD;}
inline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}
inline int sqr_M(int a){return pdt(a, a);}

inline int pow(int a, int b){
    int c = 1;
    while (b) {
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

template<class T>
inline int pow(T a, int b){
    T c(1);
    while (b) {
        if (b&1) MUL(c, a);
        MUL(a, a), b >>= 1;
    }
    return c;
}

inline int _I(int b){
    int a = MOD, x1 = 0, x2 = 1, q;
    while (true){
        q = a / b, a %= b;
        if (!a) return (x2 + MOD) % MOD;
        DEC(x1, pdt(q, x2));

        q = b / a, b %= a;
        if (!b) return (x1 + MOD) % MOD;
        DEC(x2, pdt(q, x1));
    }
}

inline void DIV(int &a, int b){MUL(a, _I(b));}
inline int qtt(int a, int b){return pdt(a, _I(b));}

inline int sum(int a, int b, int MOD){
    a += b; if (a >= MOD) a -= MOD;
    return a;
}

inline int phi(int n){
    int res = n;
    for (int i=2;sqr(i)<=n;++i) if (!(n%i)){
        DEC(res, qtt(res, i));
        do{n /= i;} while(!(n%i));
    }
    if (n != 1)
        DEC(res, qtt(res, n));
    return res;
}

// <<= '9. Comutational Geometry .,

struct Po; struct Line; struct Seg;

inline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}
inline int sgn(DB x, DB y){return sgn(x - y);}
inline bool equ(DB x, DB y){return !sgn(x, y);}

struct Po{
    DB x, y;
    Po(DB _x = 0, DB _y = 0):x(_x), y(_y){}

    friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}
    friend ostream& operator <<(ostream& out, Po p){return out << "(" << p.x << ", " << p.y << ")";}

    friend bool operator ==(Po, Po);
    friend bool operator !=(Po, Po);
    friend Po operator +(Po, Po);
    friend Po operator -(Po, Po);
    friend Po operator *(Po, DB);
    friend Po operator /(Po, DB);

    bool operator < (const Po &rhs) const{return sgn(x, rhs.x) < 0 || sgn(x, rhs.x) == 0 && sgn(y, rhs.y) < 0;}
    Po operator-() const{return Po(-x, -y);}
    Po& operator +=(Po rhs){x += rhs.x, y += rhs.y; return *this;}
    Po& operator -=(Po rhs){x -= rhs.x, y -= rhs.y; return *this;}
    Po& operator *=(DB k){x *= k, y *= k; return *this;}
    Po& operator /=(DB k){x /= k, y /= k; return *this;}

    DB length_sqr(){return sqr(x) + sqr(y);}
    DB length(){return sqrt(length_sqr());}

    DB atan(){
        return atan2(y, x);
    }

    void input(){
        scanf("%lf %lf", &x, &y);
    }
};

bool operator ==(Po a, Po b){return sgn(a.x - b.x) == 0 && sgn(a.y - b.y) == 0;}
bool operator !=(Po a, Po b){return sgn(a.x - b.x) != 0 || sgn(a.y - b.y) != 0;}
Po operator +(Po a, Po b){return Po(a.x + b.x, a.y + b.y);}
Po operator -(Po a, Po b){return Po(a.x - b.x, a.y - b.y);}
Po operator *(Po a, DB k){return Po(a.x * k, a.y * k);}
Po operator *(DB k, Po a){return a * k;}
Po operator /(Po a, DB k){return Po(a.x / k, a.y / k);}

struct Line{
    Po a, b;
    Line(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}
    Line(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}
    Line(Seg);

    friend ostream& operator <<(ostream& out, Line p){return out << p.a << "-" << p.b;}
};

struct Seg{
    Po a, b;
    Seg(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}
    Seg(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}
    Seg(Line l);

    friend ostream& operator <<(ostream& out, Seg p){return out << p.a << "-" << p.b;}
    DB length(){return (b - a).length();}
};

Line::Line(Seg l):a(l.a), b(l.b){}
Seg::Seg(Line l):a(l.a), b(l.b){}

#define innerProduct dot
#define scalarProduct dot
#define dotProduct dot
#define outerProduct det
#define crossProduct det

inline DB dot(DB x1, DB y1, DB x2, DB y2){return x1 * x2 + y1 * y2;}
inline DB dot(Po a, Po b){return dot(a.x, a.y, b.x, b.y);}
inline DB dot(Po p0, Po p1, Po p2){return dot(p1 - p0, p2 - p0);}
inline DB dot(Line l1, Line l2){return dot(l1.b - l1.a, l2.b - l2.a);}
inline DB det(DB x1, DB y1, DB x2, DB y2){return x1 * y2 - x2 * y1;}
inline DB det(Po a, Po b){return det(a.x, a.y, b.x, b.y);}
inline DB det(Po p0, Po p1, Po p2){return det(p1 - p0, p2 - p0);}
inline DB det(Line l1, Line l2){return det(l1.b - l1.a, l2.b - l2.a);}

template<class T1, class T2> inline DB dist(T1 x, T2 y){return sqrt(dist_sqr(x, y));}

inline DB dist_sqr(Po a, Po b){return sqr(a.x - b.x) + sqr(a.y - b.y);}
inline DB dist_sqr(Po p, Line l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}
inline DB dist_sqr(Po p, Seg l){
    Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;
    if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));
    else return min(v1.length_sqr(), v2.length_sqr());
}

inline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}
inline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}

inline DB dist_sqr(Line l1, Line l2){
    if (sgn(det(l1, l2)) != 0) return 0;
    return dist_sqr(l1.a, l2);
}
inline DB dist_sqr(Line l1, Seg l2){
    Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);
    return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();
}

bool isIntersect(Seg l1, Seg l2){

    //if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;

    return
        min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&
        min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&
        min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&
        min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&
    sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&
    sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;

}

inline DB dist_sqr(Seg l1, Seg l2){
    if (isIntersect(l1, l2)) return 0;
    else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));
}

inline bool isOnExtremePoint(const Po &p, const Seg &l){
    return p == l.a || p == l.b;
}

inline bool isOnseg(const Po &p, const Seg &l){

    //if (p == l.a || p == l.b) return false;

    return sgn(det(p, l.a, l.b)) == 0 &&
        sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;
}

inline Po intersect(const Line &l1, const Line &l2){
    return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));
}

// perpendicular foot
inline Po intersect(const Po & p, const Line &l){
    return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);
}

inline Po rotate(Po p, DB alpha, Po o = Po()){
    p.x -= o.x, p.y -= o .y;
    return Po(p.x * cos(alpha) - p.y * sin(alpha), p.y * cos(alpha) + p.x * sin(alpha)) + o;
}

// <<= ' A. Random Event ..

inline int rand32(){return (bool(rand() & 1) << 30) | (rand() << 15) + rand();}
inline int random32(int l, int r){return rand32() % (r - l + 1) + l;}
inline int random(int l, int r){return rand() % (r - l + 1) + l;}
int dice(){return rand() % 6;}
bool coin(){return rand() % 2;}

// <<= ' 0. I/O Accelerator interface .,

template<class T> inline void RD(T &x){
    //cin >> x;
    scanf("%d", &x);
    //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
    //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}

template<class T> inline void OT(const T &x){
    printf("%d\n", x);
}

/* .................................................................................................................................. */

const int N = 1000009;

int F0[N], F1[N], G0[N], G1[N]; char s[N];
int L[N], R[N], n, k, k_, l, r;

int main(){

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

    RD(n, k); RS(s+1); k_ = k + 1;

	REP_1(i, n) L[i] = L[i-1] + (s[i]=='X');
	DWN_1(i, n, 1) R[i] = R[i+1] + (s[i]=='X');

    l = 0, r = 0; REP_1(i, n){
        if (s[i] == 'X' || s[i] == 'B') ++r; else l = r = i;
        F1[i] = sum(pdt(s[i] == 'X' ? 2 : 1, F1[i-1]), F0[i] = r-l>=k && s[i-k] != 'B' ? dff(pow(2, L[i-k_]), F1[i-k_]) : 0);
    }

    l = n+1, r = n+1; DWN_1(i, n, 1){
        if (s[i] == 'X' || s[i] == 'W') --l; else r = l = i;
        G1[i] = sum(pdt(s[i] == 'X' ? 2 : 1, G1[i+1]), G0[i] = r-l>=k && s[i+k] != 'W' ? dff(pow(2, R[i+k_]), G1[i+k_]) : 0);
    }

    int res = 0; FOR(i, 1, n) INC(res, pdt(F0[i], G1[i+1]));
    OT(res);
}


#include<bits/stdc++.h>
#define pb push_back
#define sz(x) (int)x.size()
#define scf scanf
#define ptf printf
#define fst first
#define scd second
#define forp(i,j,k) for(int i=j;i<k;i++)
#define form(i,j,k) for(int i=j;i>k;i--)
using namespace std;
typedef long long LL;

const int N=1e6+10;
const LL mo=1e9+10;

LL f[N],g[N],a[N][2],b[N],gg[N];
char s[N];
int n,k;

void cc(LL*f,char*s,char ch)
{
    int st=ch=='W'?1:0,t0=0;
    char hh=ch=='W'?'B':'W';
    memset(a,0,sizeof(a));
    memset(f,0,sizeof(f));
    forp(i,0,n)if(s[i]!=hh)b[i]=++t0;else b[i]=t0=0;
    LL cnt=1;
    forp(i,0,n)
    {
        if(i<=k-1)
        {
            if(s[i]!=ch)a[i][1-st]=cnt;
            if(s[i]!=hh)a[i][st]=cnt;
            if(b[i]==k)a[i][st]=(a[i][st]+mo-1)%mo;
            if(s[i]=='X')cnt=cnt*2%mo;
            if(b[i]==k)f[i]=1;
            continue;
        }
        if(s[i]=='X')cnt=cnt*2%mo;
        if(i>k-1)
        {
            if(s[i]!=hh)
            {
                a[i][st]=(a[i-1][0]+a[i-1][1])%mo;
                if(b[i]>=k)a[i][st]=(a[i][st]+mo-a[i-k][1-st])%mo;
            }
            if(s[i]!=ch)
                a[i][1-st]=(a[i-1][0]+a[i-1][1])%mo;
        }
        if(b[i]>=k)f[i]=a[i-k][1-st];
    }
}

int main()
{
    scf("%d%d%s",&n,&k,s);
    cc(f,s,'B');
    reverse(s,s+n);
    cc(gg,s,'W');
    g[k-1]=gg[k-1];
    forp(i,k,n){g[i]=g[i-1]*(s[i]=='X'?2:1)+gg[i];g[i]%=mo;}
    reverse(g,g+n);
    LL ans=0;
    forp(i,0,n)ans=(ans+f[i]*g[i+1])%mo;
    ptf("%I64d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
#define pb push_back
#define sz(x) (int)x.size()
#define scf scanf
#define ptf printf
#define fst first
#define scd second
#define forp(i,j,k) for(int i=j;i<k;i++)
#define form(i,j,k) for(int i=j;i>k;i--)
using namespace std;
typedef long long LL;

const int N=1e6+10;
const LL mo=1e9+7;

LL f[N],g[N],a[N][2],b[N],gg[N];
char s[N];
int n,k;

void cc(LL*f,char*s,char ch)
{
    int st=ch=='W'?1:0,t0=0;
    char hh=ch=='W'?'B':'W';
    memset(a,0,sizeof(a));
    memset(f,0,sizeof(f));
    forp(i,0,n)if(s[i]!=hh)b[i]=++t0;else b[i]=t0=0;
    LL cnt=1;
    forp(i,0,n)
    {
        if(i<=k-1)
        {
            if(s[i]!=ch)a[i][1-st]=cnt;
            if(s[i]!=hh)a[i][st]=cnt;
            if(b[i]==k)a[i][st]=(a[i][st]+mo-1)%mo;
            if(s[i]=='X')cnt=cnt*2%mo;
            if(b[i]==k)f[i]=1;
            continue;
        }
        if(s[i]=='X')cnt=cnt*2%mo;
        if(i>k-1)
        {
            if(s[i]!=hh)
            {
                a[i][st]=(a[i-1][0]+a[i-1][1])%mo;
                if(b[i]>=k)a[i][st]=(a[i][st]+mo-a[i-k][1-st])%mo;
            }
            if(s[i]!=ch)
                a[i][1-st]=(a[i-1][0]+a[i-1][1])%mo;
        }
        if(b[i]>=k)f[i]=a[i-k][1-st];
    }
}

int main()
{
	scf("%d%d%s",&n,&k,s);
	cc(f,s,'B');
	reverse(s,s+n);
	cc(gg,s,'W');
	memset(g,0,sizeof(g));
	g[k-1]=gg[k-1];
	forp(i,k,n){g[i]=g[i-1]*(s[i]=='X'?2:1)+gg[i];g[i]%=mo;}
	reverse(g,g+n);
	LL ans=0;
    forp(i,0,n)ans=(ans+f[i]*g[i+1])%mo;
	ptf("%I64d\n",ans);
    return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <map>
#include <utility>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <sstream>
#include <set>
#include <complex>
#include <iomanip>
#include <queue>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define SZ(x) ((int)x.size())
#define PB push_back
#define show(x) cerr << "#" << #x << ": " << x << endl
#define F first
#define S second
#define X real()
#define Y imag()

using namespace std;
typedef pair<int, int> pii;
typedef complex<double> point;

const int MAX_N = 1000 * 1000 + 10;
const long long MOD = 1000000007;

int n, k;
char str[MAX_N];
long long mod2[MAX_N];
long long cntW[MAX_N];
long long cntB[MAX_N];
long long dpW[2][MAX_N];
long long dpB[2][MAX_N];

bool allb(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntW[e] - cntW[s] == 0);
}

bool allw(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntB[e] - cntB[s] == 0);
}

void calc(char* str, long long dp[][MAX_N], char c, bool (*check) (int, int)){ //dp[0][i]  ---> have a block of c, dp[1][i] ---> no block of c
	long long* dph = dp[0];
	long long* dpn = dp[1];
	dph[0] = 0;
	dpn[0] = 1;
	for(int i = 1; i <= n; i++){
		dph[i] = dph[i - 1];
		if((*check)(i - k, i))
			dph[i] += dpn[i - k];
		int countx = i - (cntB[i] + cntW[i]);
		dpn[i] = mod2[countx] - dph[i];
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k >> str;
	cntW[0] = 0;
	cntB[0] = 0;
	mod2[0] = 1;
	FOR(i, n){
		mod2[i + 1] = (mod2[i] * 2) % MOD;
		cntW[i + 1] = cntW[i];
		cntB[i + 1] = cntB[i];
		if(str[i] == 'W')
			cntW[i+1]++;
		if(str[i] == 'B')
			cntB[i+1]++;
	}

	long long* dph = dpB[0];
	long long* dpn = dpB[1];
	dph[0] = 0;
	dpn[0] = 1;
	for(int i = 1; i <= n; i++){
		dpn[i] = dpn[i - 1];
		if(str[i - 1] == 'X')
			dpn[i] += dpn[i - 1];
		if(str[i - 1] != 'W' && i >= k && allb(i - k, i)){
			if(i == k)
				dpn[i] -= 1;
			else{
				if(str[i - k - 1] != 'B')
					dpn[i] -= dpn[i - k - 1];
			}
		}
		int countx = i - (cntB[i] + cntW[i]);
		dph[i] = mod2[countx] - dpn[i];
	}

	dph = dpW[0];
	dpn = dpW[1];
	dph[n] = 0;
	dpn[n] = 1;
	for(int i = n - 1; i >= 0; i--){
		dpn[i] = dpn[i + 1];
		if(str[i] == 'X')
			dpn[i] += dpn[i + 1];
		if(str[i] != 'B' && i + k <= n && allw(i, i + k)){
			if(i + k == n)
				dpn[i] -= 1;
			else{
				if(str[i + k] != 'W')
					dpn[i] -= dpn[i + k + 1];
			}
		}
		int countx = (n - i) - (cntW[n] - cntW[i]) - (cntB[n] - cntB[i]);
		dph[i] = mod2[countx] - dpn[i];
// 		show(i);
// 		show(dpn[i]);
	}

	long long ans = 0;
	for(int i = k; i <= n - k; i++)
		if(allb(i - k, i)){
			long long cur = 1;
			if(i > k && str[i - k - 1] == 'B')
				continue;
			if(i > k)
				cur = dpB[1][i - k - 1];
			cur *= dpW[0][i];
			ans += (cur % MOD);
			ans %= MOD;
		}
	ans %= MOD;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <map>
#include <utility>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <sstream>
#include <set>
#include <complex>
#include <iomanip>
#include <queue>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define SZ(x) ((int)x.size())
#define PB push_back
#define show(x) cerr << "#" << #x << ": " << x << endl
#define F first
#define S second
#define X real()
#define Y imag()

using namespace std;
typedef pair<int, int> pii;
typedef complex<double> point;

const int MAX_N = 1000 * 1000 + 10;
const long long MOD = 1000000007;

int n, k;
char str[MAX_N];
long long mod2[MAX_N];
long long cntW[MAX_N];
long long cntB[MAX_N];
long long dpW[2][MAX_N];
long long dpB[2][MAX_N];

bool allb(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntW[e] - cntW[s] == 0);
}

bool allw(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntB[e] - cntB[s] == 0);
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k >> str;
	cntW[0] = 0;
	cntB[0] = 0;
	mod2[0] = 1;
	FOR(i, n){
		mod2[i + 1] = (mod2[i] * 2) % MOD;
		cntW[i + 1] = cntW[i];
		cntB[i + 1] = cntB[i];
		if(str[i] == 'W')
			cntW[i+1]++;
		if(str[i] == 'B')
			cntB[i+1]++;
	}

	long long* dph = dpB[0];
	long long* dpn = dpB[1];
	dph[0] = 0;
	dpn[0] = 1;
	for(int i = 1; i <= n; i++){
		dpn[i] = dpn[i - 1];
		if(str[i - 1] == 'X')
			dpn[i] += dpn[i - 1];
		if(str[i - 1] != 'W' && i >= k && allb(i - k, i)){
			if(i == k)
				dpn[i] -= 1;
			else{
				if(str[i - k - 1] != 'B')
					dpn[i] -= dpn[i - k - 1];
			}
		}
		int countx = i - (cntB[i] + cntW[i]);
		dph[i] = mod2[countx] - dpn[i];
	}

	dph = dpW[0];
	dpn = dpW[1];
	dph[n] = 0;
	dpn[n] = 1;
	for(int i = n - 1; i >= 0; i--){
		dpn[i] = dpn[i + 1];
		if(str[i] == 'X')
			dpn[i] += dpn[i + 1];
		if(str[i] != 'B' && i + k <= n && allw(i, i + k)){
			if(i + k == n)
				dpn[i] -= 1;
			else{
				if(str[i + k] != 'W')
					dpn[i] -= dpn[i + k + 1];
			}
		}
		int countx = (n - i) - (cntW[n] - cntW[i]) - (cntB[n] - cntB[i]);
		dph[i] = mod2[countx] - dpn[i];
	}

	long long ans = 0;
	for(int i = k; i <= n - k; i++)
		if(allb(i - k, i)){
			long long cur = 1;
			if(i > k && str[i - k - 1] == 'B')
				continue;
			if(i > k)
				cur = dpB[1][i - k - 1];
			cur *= dpW[0][i];
			ans += (cur % MOD);
			ans %= MOD;
		}
	ans %= MOD;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <map>
#include <utility>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <sstream>
#include <set>
#include <complex>
#include <iomanip>
#include <queue>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define SZ(x) ((int)x.size())
#define PB push_back
#define show(x) cerr << "#" << #x << ": " << x << endl
#define F first
#define S second
#define X real()
#define Y imag()

using namespace std;
typedef pair<int, int> pii;
typedef complex<double> point;

const int MAX_N = 1000 * 1000 + 10;
const long long MOD = 1000000007;

int n, k;
char str[MAX_N];
long long mod2[MAX_N];
long long cntW[MAX_N];
long long cntB[MAX_N];
long long dpW[2][MAX_N];
long long dpB[2][MAX_N];

bool allb(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntW[e] - cntW[s] == 0);
}

bool allw(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntB[e] - cntB[s] == 0);
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k >> str;
	cntW[0] = 0;
	cntB[0] = 0;
	mod2[0] = 1;
	FOR(i, n){
		mod2[i + 1] = (mod2[i] * 2) % MOD;
		cntW[i + 1] = cntW[i];
		cntB[i + 1] = cntB[i];
		if(str[i] == 'W')
			cntW[i+1]++;
		if(str[i] == 'B')
			cntB[i+1]++;
	}

	long long* dph = dpB[0];
	long long* dpn = dpB[1];
	dph[0] = 0;
	dpn[0] = 1;
	for(int i = 1; i <= n; i++){
		dpn[i] = dpn[i - 1];
		if(str[i - 1] == 'X')
			dpn[i] += dpn[i - 1];
		if(str[i - 1] != 'W' && i >= k && allb(i - k, i)){
			if(i == k)
				dpn[i] -= 1;
			else{
				if(str[i - k - 1] != 'B')
					dpn[i] -= dpn[i - k - 1];
			}
		}
		int countx = i - (cntB[i] + cntW[i]);
		dph[i] = mod2[countx] - dpn[i];
		dph[i] %= MOD;
		dpn[i] %= MOD;
	}

	dph = dpW[0];
	dpn = dpW[1];
	dph[n] = 0;
	dpn[n] = 1;
	for(int i = n - 1; i >= 0; i--){
		dpn[i] = dpn[i + 1];
		if(str[i] == 'X')
			dpn[i] += dpn[i + 1];
		if(str[i] != 'B' && i + k <= n && allw(i, i + k)){
			if(i + k == n)
				dpn[i] -= 1;
			else{
				if(str[i + k] != 'W')
					dpn[i] -= dpn[i + k + 1];
			}
		}
		int countx = (n - i) - (cntW[n] - cntW[i]) - (cntB[n] - cntB[i]);
		dph[i] = mod2[countx] - dpn[i];
		dph[i] %= MOD;
		dpn[i] %= MOD;
	}

	long long ans = 0;
	for(int i = k; i <= n - k; i++)
		if(allb(i - k, i)){
			long long cur = 1;
			if(i > k && str[i - k - 1] == 'B')
				continue;
			if(i > k)
				cur = dpB[1][i - k - 1];
			cur *= dpW[0][i];
			ans += (cur % MOD);
			ans %= MOD;
		}
	ans %= MOD;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;
	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <map>
#include <utility>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <sstream>
#include <set>
#include <complex>
#include <iomanip>
#include <queue>

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define SZ(x) ((int)x.size())
#define PB push_back
#define show(x) cerr << "#" << #x << ": " << x << endl
#define F first
#define S second
#define X real()
#define Y imag()

using namespace std;
typedef pair<int, int> pii;
typedef complex<double> point;

const int MAX_N = 1000 * 1000 + 10;
const long long MOD = 1000000007;

int n, k;
char str[MAX_N];
long long mod2[MAX_N];
long long cntW[MAX_N];
long long cntB[MAX_N];
long long dpW[2][MAX_N];
long long dpB[2][MAX_N];

bool allb(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntW[e] - cntW[s] == 0);
}

bool allw(int s, int e){		// [closed, open)  interval
	if(s < 0 || e > n)
		return false;
	return (cntB[e] - cntB[s] == 0);
}

void calc(char* str, long long dp[][MAX_N], char c, bool (*check) (int, int)){ //dp[0][i]  ---> have a block of c, dp[1][i] ---> no block of c
	long long* dph = dp[0];
	long long* dpn = dp[1];
	dph[0] = 0;
	dpn[0] = 1;
	for(int i = 1; i <= n; i++){
		dph[i] = dph[i - 1];
		if((*check)(i - k, i))
			dph[i] += dpn[i - k];
		int countx = i - (cntB[i] + cntW[i]);
		dpn[i] = mod2[countx] - dph[i];
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k >> str;
	cntW[0] = 0;
	cntB[0] = 0;
	mod2[0] = 1;
	FOR(i, n){
		mod2[i + 1] = (mod2[i] * 2) % MOD;
		cntW[i + 1] = cntW[i];
		cntB[i + 1] = cntB[i];
		if(str[i] == 'W')
			cntW[i+1]++;
		if(str[i] == 'B')
			cntB[i+1]++;
	}

	long long* dph = dpB[0];
	long long* dpn = dpB[1];
	dph[0] = 0;
	dpn[0] = 1;
	for(int i = 1; i <= n; i++){
		dpn[i] = dpn[i - 1];
		if(str[i - 1] == 'X')
			dpn[i] += dpn[i - 1];
		if(str[i - 1] != 'W' && i >= k && allb(i - k, i)){
			if(i == k)
				dpn[i] -= 1;
			else{
				if(str[i - k - 1] != 'B')
					dpn[i] -= dpn[i - k - 1];
			}
		}
		int countx = i - (cntB[i] + cntW[i]);
		dph[i] = mod2[countx] - dpn[i];
	}

	dph = dpW[0];
	dpn = dpW[1];
	dph[n] = 0;
	dpn[n] = 1;
	for(int i = n - 1; i >= 0; i--){
		dpn[i] = dpn[i + 1];
		if(str[i] == 'X')
			dpn[i] += dpn[i + 1];
		if(str[i] != 'B' && i + k <= n && allw(i, i + k)){
			if(i + k == n)
				dpn[i] -= 1;
			else{
				if(str[i + k] != 'W')
					dpn[i] -= dpn[i + k + 1];
			}
		}
		int countx = (n - i) - (cntW[n] - cntW[i]) - (cntB[n] - cntB[i]);
		dph[i] = mod2[countx] - dpn[i];
// 		show(i);
// 		show(dpn[i]);
	}

	long long ans = 0;
	for(int i = k; i <= n - k; i++)
		if(allb(i - k, i)){
			long long cur = 1;
			if(i > k && str[i - k - 1] == 'B')
				continue;
			if(i > k)
				cur = dpB[1][i - k - 1];
			cur *= dpW[0][i];
			ans += (cur % MOD);
			ans %= MOD;
		}
	cout << ans << endl;
	return 0;
}


#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
long long i,j,k,l,n,m,s,an,sum,K,C,tt,tot;
const long long N=2100000;
const long long pp=1000000007;
long long f[N],g[N],anl[N],anr[N],S[N],er[N],chu[N];
char a[N];
long long quick(long long x,long long y)
{
    long long xx=1;
    while (y)
    {
        if (y&1) xx=xx*x%pp;
        x=x*x%pp;
        y/=2;
    }
    return xx;
}
int main()
{
    scanf("%I64d%I64d",&n,&K);
    scanf("%s",a+1);
    er[0]=1;
    for (long long i=1;i<=n;i++) er[i]=er[i-1]*2%pp;
    chu[n]=quick(er[n],pp-2);
    for (long long i=n-1;i>=0;i--) chu[i]=chu[i+1]*2%pp;
    for (long long i=1;i<=n;i++) S[i]=S[i-1]+(a[i]=='X');
    long long l=n;
    f[l]=1;sum=1;
    for (long long i=1;i<=n;i++)
    {
        if (a[i]=='W')
        {
            for (long long j=l;j<=n;j++) f[j]=0;
            l=n;
            f[l]=sum;
        }
        else
        {
            l--;
            if (a[i]=='X')
            f[l]=sum,sum+=f[l],sum%=pp;
        }
        anl[i]=f[l+K];anl[i]%=pp;
        sum-=f[l+K];sum=(sum%pp+pp)%pp;
    }
    memset(f,0,sizeof(f));
    l=n;
    f[l]=1;sum=1;
    for (long long i=n;i>=1;i--)
    {
        if (a[i]=='B')
        {
            for (long long j=l;j<=n;j++) f[j]=0;
            l=n;
            f[l]=sum;
        }
        else
        {
            l--;
            if (a[i]=='X')
            f[l]=sum,sum+=f[l],sum%=pp;
        }
        anr[i]=f[l+K];anr[i]%=pp;
        sum-=f[l+K];sum=(sum%pp+pp)%pp;
    }
    long long s2=0;
    for (long long i=1;i<=n;i++) s2+=anr[i]*er[S[i-1]],s2%=pp;
    for (long long i=1;i<=n;i++)
    {
         s2-=anr[i]*er[S[i-1]],s2=(s2%pp+pp)%pp;
         an+=anl[i]*s2*chu[S[i]]%pp,an%=pp;
        //for (long long j=i+1;j<=n;j++)
        //an+=anl[i]*anr[j]*er[S[j-1]-S[i]];
    }
    printf("%I64d\n",an);
    //for(;;);
    //system("pause");
    return 0;
}


#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
long long i,j,k,l,n,m,s,an,sum,K,C,tt,tot;
const long long N=2100000;
const long long pp=1000000007;
long long f[N],g[N],anl[N],anr[N],S[N],er[N],chu[N];
char a[N];
long long quick(long long x,long long y)
{
    long long xx=1;
    while (y)
    {
        if (y&1) xx=xx*x%pp;
        x=x*x%pp;
        y/=2;
    }
    return xx;
}
int main()
{
    scanf("%I64d%I64d",&n,&K);
    scanf("%s",a+1);
    er[0]=1;
    for (long long i=1;i<=n;i++) er[i]=er[i-1]*2%pp;
    chu[n]=quick(er[n],pp-2);
    for (long long i=n-1;i>=0;i--) chu[i]=chu[i+1]*2%pp;
    for (long long i=1;i<=n;i++) S[i]=S[i-1]+(a[i]=='X');
    long long l=n;
    f[l]=1;sum=1;
    for (long long i=1;i<=n;i++)
    {
        if (a[i]=='W')
        {
            for (long long j=l;j<=n;j++) f[j]=0;
            l=n;
            f[l]=sum;
        }
        else
        {
            l--;
            if (a[i]=='X')
            f[l]=sum,sum+=f[l],sum%=pp;
        }
        anl[i]=f[l+K];anl[i]%=pp;
        sum-=f[l+K];sum=(sum%pp+pp)%pp;
    }
    memset(f,0,sizeof(f));
    l=n;
    f[l]=1;sum=1;
    for (long long i=n;i>=1;i--)
    {
        if (a[i]=='B')
        {
            for (long long j=l;j<=n;j++) f[j]=0;
            l=n;
            f[l]=sum;
        }
        else
        {
            l--;
            if (a[i]=='X')
            f[l]=sum,sum+=f[l],sum%=pp;
        }
        anr[i]=f[l+K];anr[i]%=pp;
        sum-=f[l+K];sum=(sum%pp+pp)%pp;
    }
    long long s2=0;
    for (long long i=1;i<=n;i++) s2+=anr[i]*er[S[i-1]]%pp,s2%=pp;
    for (long long i=1;i<=n;i++)
    {
         s2-=anr[i]*er[S[i-1]]%pp,s2=(s2%pp+pp)%pp;
         an+=anl[i]*s2%pp*chu[S[i]]%pp,an%=pp;
        //for (long long j=i+1;j<=n;j++)
        //an+=anl[i]*anr[j]*er[S[j-1]-S[i]];
    }
    printf("%I64d\n",(an+pp)%pp);
    //for(;;);
    //system("pause");
    return 0;
}


//#pragma warning (disable: 4786)
//#pragma comment (linker, "/STACK:16777216")

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
#define maxim 100
#define LLD long long int
#define LLU long long unsigned
#define HD short int
#define HU short unsigned
#define pi acos(-1.0)
#define inf (1<<29)
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define pb push_back
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define eps 1e-9
#define rep(i,init,n) for(i=init;i<n;i++)
#define rem(i,init,n) for(i=init;i>n;i--)
#define foreach(i, c) for( __typeof( (c).begin() ) i = (c).begin(); i != (c).end(); ++i )
#define _abs(a) ((a)<0?(-(a)):(a))
#define area(x1,y1,x2,y2,x3,y3) ( x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2) )
#define sqr(x) ((x)*(x))
#define distSqr(x1,y1,x2,y2) ( sqr(x1-x2) + sqr(y1-y2) )
#define spDist(lat1,long1,lat2,long2,r) ( r * acos( sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(long1-long2) ) )
#define isEq(a,b) (fabs(a-b)<eps)
#define STR string
#define LF double
#define IT iterator
#define VI vector<int>
#define VLLD vector<LLD>
#define VS vector<STR>
#define VLF vector<LF>
#define MII map<int,int>
#define MIB map<int,bool>
#define MSI map<STR,int>
#define MSB map<STR,bool>
#define MSS map<STR,STR>
#define M2dII map<int,map<int,int> >
#define QI queue<int>
#define SI stack<int>
#define PII pair< int, int >
#define PPI pair< PII, int >
#define ff first
#define ss second
#define VPII vector<PII>
#define MP make_pair

#define chk(a,k) ((bool)(a&(1<<(k))))
#define set0(a,k) (a&(~(1<<(k))))
#define set1(a,k) (a|(1<<(k)))

#define chkA(a,k) (bool)(a[(k)>>5] & (1<<((k)&31)))
#define setA0(a,k) (a[(k)>>5] &= ~(1<<((k)&31)))
#define setA1(a,k) (a[(k)>>5] |= (1<<((k)&31)))

#define SD(a) scanf("%d",&a)
#define SU(a) scanf("%u",&a)
#define SHD(a) scanf("%hd",&a)
#define SHU(a) scanf("%hu",&a)
#define SF(a) scanf("%f",&a)
#define SLF(a) scanf("%lf",&a)
#define SC(a) scanf("%c",&a)
#define SS(a) scanf("%s",a)

int diru[] = {-1,-1,-1,0,0,1,1,1};
int dirv[] = {-1,0,1,-1,1,-1,0,1};

using namespace std;

#define DEB(args...) {dbg,args; cerr<<endl;}
struct debugger { template<typename T> debugger& operator,(const T& v) { cerr<<v<<" "; return *this; } } dbg ;

template< class T > T sq(T n) { return n*n; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > void setmax(T &a, T b) { if(a < b) a = b; }
template< class T > void setmin(T &a, T b) { if(b < a) a = b; }
template< class T > T power(T N,T P){  return (P==0)?  1: N*power(N,P-1); }

#define MAX 1000002

char in[MAX] ;
int pre[2][MAX] ;
int dp[2][2][MAX] ;
int DP[MAX][7] ;
PII rng[MAX][7] ;
//int tree[2][2][4*MAX] ;
int x,y,F,Clr,ans ;
int M = 1000000007 ;
/*
void update(int b, int e, int node)
{
          if(b>x || e<x)                return ;

          if(b==e)
          {
                    tree[F][Clr][node] = dp[F][Clr][b] ;

                    return ;
          }

          int m = (b+e)>>1, u = node<<1 ;
          int v = u+1 ;

          update(b,m,u) ;
          update(m+1,e,v) ;

          tree[F][Clr][node] = tree[F][Clr][u] + tree[F][Clr][v] ;

          if(tree[F][Clr][node] >= M)           tree[F][Clr][node] -= M ;
}

void query(int b, int e, int node)
{
          if(b>y || e<x)                return ;

          if(x<=b && e<=y)
          {
                    ans += tree[F][Clr][node] ;

                    if(ans>=M)          ans -= M ;

                    return ;
          }

          int m = (b+e)>>1, u = node<<1 ;
          int v = u+1 ;

          query(b,m,u) ;
          query(m+1,e,v) ;
}
*/
int pos,I,n ;

int query()
{
          if(x>y)
          {
                    ans = 0 ;
                    return DP[I][pos] = 0 ;
          }

          int p = rng[I+1][pos].ff ;
          int q = rng[I+1][pos].ss ;

          int ret = 0,i ;

          if(I==n-1 || p>q)
          {
                    rep(i,x,y+1)
                    {
                              ret += dp[F][Clr][i] ;
                              if(ret>=M)           ret -= M ;
                    }

                    ans = ret ;

                    return DP[I][pos] = ret ;
          }

          /*LLD val =  0;

          rep(i,x,y+1)
          {
                    val += dp[F][Clr][i] ;
                    if(val>=M)           val -= M ;
          }*/

          ret += DP[I+1][pos] ;

          while(q>y)
          {
                    ret -= dp[F][Clr][q--] ;
                    if(ret<0)           ret += M ;
          }

          while(q<y)
          {
                    ret += dp[F][Clr][++q] ;
                    if(ret>=M)           ret -= M ;
          }

          while(p<x)
          {
                    ret -= dp[F][Clr][p++] ;
                    if(ret<0)           ret += M ;
          }

          while(p>x)
          {
                    //if(pos==0)                    DEB(ret,dp[F][Clr][p-1]) ;

                    ret += dp[F][Clr][--p] ;
                    if(ret>=M)           ret -= M ;

                    //if(pos==0)
                              //DEB(I,pos,x,y,ret,val,F,Clr,dp[1][F][Clr],DP[I+1][pos]) ;
                              //DEB(I,pos,ret,F,Clr,dp[F][Clr][p]) ;
          }

          ans = ret ;

          //if(pos==0)      DEB(I,pos,x,y,ret,val,F,Clr,dp[1][F][Clr],DP[I+1][pos]) ;

          return DP[I][pos] = ret ;
}

int main()
{
         int T,t=1,m,i,j,k,clr,f,val;
         //freopen("in.txt","r",stdin);
         //freopen("out.txt","w",stdout);
         //scanf("%d",&T);
         //for(t=1;t<=T;t++)
         //while(scanf("%d",&n)==1)
         scanf("%d",&n) ;
         scanf("%d",&k) ;

         SS(in) ;

         i = n ;

         rep(clr,0,2)
                    pre[clr][i] = i-1 ;

         rem(i,n-1,-1)
         {
                   rep(clr,0,2)
                   {
                             if(in[i]=='X' || clr == (in[i]=='B'))        pre[clr][i] = pre[clr][i+1] ;
                             else pre[clr][i] = i-1 ;

                             //DEB(clr,i,pre[clr][i]) ;
                   }
         }

         i = n ;

         rep(F,0,2)
                    rep(Clr,0,2)
                    {
                              dp[F][Clr][i] = 1 ;
                              //x = i ;
                              //update(0,n,1) ;
                    }

         rem(i,n-1,-1)
         {
                   I = i ;

                   clr = 0 ;  f = 0 ;

                   pos = 0 ;

                   x = i ;
                   y = min(n-1,pre[clr][i]) ;

                   x ++; y++ ;

                   ans = 0 ;
                   F = 0 ;    Clr = 1 ;
                   query() ;

                   //DEB(f,clr,i,ans,DP) ;

                   rng[i][pos] = PII(x,y) ;
                    DP[i][pos] = ans ;

                   //DEB(f,clr,i,x,y,ans) ;

                   dp[f][clr][i] = ans ;

                    ///////////////////////////////////////

                   clr = 0 ;  f = 1 ;

                   pos ++ ;

                   x = i ;
                   y = min(i+k-2,pre[clr][i]) ;

                   x ++; y++ ;

                    ans = 0 ;
                    F = 1 ;    Clr = 1 ;
                    query() ;

                    rng[i][pos] = PII(x,y) ;
                    DP[i][pos] = ans ;

                   dp[f][clr][i] = ans ;

                   ///////////////////////////////////////
                   ///////////////////////////////////////
                   ///////////////////////////////////////

                   clr = 1 ;
                   val = 0 ;

                   pos ++ ;

                   rng[i][pos] = PII(i,i-1) ;
                   DP[i][pos] = 0 ;

                   if(pre[clr][i]>=i+k-1)
                   {
                             x = i+k-1 ;
                             y = min(n-1,pre[clr][i]) ;

                             x ++; y++ ;

                              ans = 0 ;
                              F = 1 ;    Clr = 0 ;
                              query() ;

                              rng[i][pos] = PII(x,y) ;
                              DP[i][pos] = ans ;

                              val = ans ;
                   }

                   ///////////////////////////////////////
                   ///////////////////////////////////////
                   ///////////////////////////////////////

                   clr = 1 ;  f = 0 ;

                   pos ++ ;

                   x = i ;
                   y = min(i+k-2,pre[clr][i]) ;

                   x ++; y++ ;

                    ans = 0 ;
                    F = f ;    Clr = 0 ;
                    query() ;

                    rng[i][pos] = PII(x,y) ;
                   DP[i][pos] = ans ;

                   dp[f][clr][i] = ans+val ;      if(dp[f][clr][i]>=M)          dp[f][clr][i] -= M ;

                   ///////////////////////////////////////

                   clr = 1 ;  f = 1 ;

                   pos ++ ;

                   x = i ;
                   y = min(i+k-2,pre[clr][i]) ;

                   x ++; y++ ;

                    ans = 0 ;
                    F = f ;    Clr = 0 ;
                    query() ;

                    rng[i][pos] = PII(x,y) ;
                   DP[i][pos] = ans ;

                   dp[f][clr][i] = ans+val ;      if(dp[f][clr][i]>=M)          dp[f][clr][i] -= M ;

                   /*rep(F,0,2)
                              rep(Clr,0,2)
                              {
                                        x = i ;
                                        //update(0,n,1) ;

                                        //DEB(dp[F][Clr][i]) ;
                              }*/
         }

          ans = dp[0][0][0] + dp[0][1][0] ;

          int tot = 1 ;

          rep(i,0,n)
          {
                    if(in[i]=='X')
                    {
                              tot <<= 1 ;
                              if(tot>=M)          tot -= M ;
                    }
          }

          ans = tot-ans ;

          ans %= M ;
          ans += M ;
          ans %= M ;

         //rep(i,0,n)
                  //scanf("%d",&m);

         printf("%d\n",ans) ;

	return 0;
}


//#pragma warning (disable: 4786)
//#pragma comment (linker, "/STACK:16777216")

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
#define maxim 100
#define LLD long long int
#define LLU long long unsigned
#define HD short int
#define HU short unsigned
#define pi acos(-1.0)
#define inf (1<<29)
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define pb push_back
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define eps 1e-9
#define rep(i,init,n) for(i=init;i<n;i++)
#define rem(i,init,n) for(i=init;i>n;i--)
#define foreach(i, c) for( __typeof( (c).begin() ) i = (c).begin(); i != (c).end(); ++i )
#define _abs(a) ((a)<0?(-(a)):(a))
#define area(x1,y1,x2,y2,x3,y3) ( x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2) )
#define sqr(x) ((x)*(x))
#define distSqr(x1,y1,x2,y2) ( sqr(x1-x2) + sqr(y1-y2) )
#define spDist(lat1,long1,lat2,long2,r) ( r * acos( sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(long1-long2) ) )
#define isEq(a,b) (fabs(a-b)<eps)
#define STR string
#define LF double
#define IT iterator
#define VI vector<int>
#define VLLD vector<LLD>
#define VS vector<STR>
#define VLF vector<LF>
#define MII map<int,int>
#define MIB map<int,bool>
#define MSI map<STR,int>
#define MSB map<STR,bool>
#define MSS map<STR,STR>
#define M2dII map<int,map<int,int> >
#define QI queue<int>
#define SI stack<int>
#define PII pair< int, int >
#define PPI pair< PII, int >
#define ff first
#define ss second
#define VPII vector<PII>
#define MP make_pair

#define chk(a,k) ((bool)(a&(1<<(k))))
#define set0(a,k) (a&(~(1<<(k))))
#define set1(a,k) (a|(1<<(k)))

#define chkA(a,k) (bool)(a[(k)>>5] & (1<<((k)&31)))
#define setA0(a,k) (a[(k)>>5] &= ~(1<<((k)&31)))
#define setA1(a,k) (a[(k)>>5] |= (1<<((k)&31)))

#define SD(a) scanf("%d",&a)
#define SU(a) scanf("%u",&a)
#define SHD(a) scanf("%hd",&a)
#define SHU(a) scanf("%hu",&a)
#define SF(a) scanf("%f",&a)
#define SLF(a) scanf("%lf",&a)
#define SC(a) scanf("%c",&a)
#define SS(a) scanf("%s",a)

int diru[] = {-1,-1,-1,0,0,1,1,1};
int dirv[] = {-1,0,1,-1,1,-1,0,1};

using namespace std;

#define DEB(args...) {dbg,args; cerr<<endl;}
struct debugger { template<typename T> debugger& operator,(const T& v) { cerr<<v<<" "; return *this; } } dbg ;

template< class T > T sq(T n) { return n*n; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > void setmax(T &a, T b) { if(a < b) a = b; }
template< class T > void setmin(T &a, T b) { if(b < a) a = b; }
template< class T > T power(T N,T P){  return (P==0)?  1: N*power(N,P-1); }

#define MAX 1000002

char in[MAX] ;
int pre[2][MAX] ;
int dp[2][2][MAX] ;
int tree[2][2][4*MAX] ;
int x,y,F,Clr,ans ;
int M = 1000000007 ;

void update(int b, int e, int node)
{
          if(b>x || e<x)                return ;

          if(b==e)
          {
                    tree[F][Clr][node] = dp[F][Clr][b] ;

                    return ;
          }

          int m = (b+e)>>1, u = node<<1 ;
          int v = u+1 ;

          update(b,m,u) ;
          update(m+1,e,v) ;

          tree[F][Clr][node] = tree[F][Clr][u] + tree[F][Clr][v] ;

          if(tree[F][Clr][node] >= M)           tree[F][Clr][node] -= M ;
}

void query(int b, int e, int node)
{
          if(b>y || e<x)                return ;

          if(x<=b && e<=y)
          {
                    ans += tree[F][Clr][node] ;

                    if(ans>=M)          ans -= M ;

                    return ;
          }

          int m = (b+e)>>1, u = node<<1 ;
          int v = u+1 ;

          query(b,m,u) ;
          query(m+1,e,v) ;
}

int main()
{
         int n,T,t=1,m,i,j,k,clr,f,val;
         //freopen("in.txt","r",stdin);
         //freopen("out.txt","w",stdout);
         //scanf("%d",&T);
         //for(t=1;t<=T;t++)
         //while(scanf("%d",&n)==1)
         scanf("%d",&n) ;
         scanf("%d",&k) ;

         SS(in) ;

         i = n ;

         rep(clr,0,2)
                    pre[clr][i] = i-1 ;

         rem(i,n-1,-1)
         {
                   rep(clr,0,2)
                   {
                             if(in[i]=='X' || clr == (in[i]=='B'))        pre[clr][i] = pre[clr][i+1] ;
                             else pre[clr][i] = i-1 ;

                             //DEB(clr,i,pre[clr][i]) ;
                   }
         }

         i = n ;

         rep(F,0,2)
                    rep(Clr,0,2)
                    {
                              dp[F][Clr][i] = 1 ;
                              x = i ;
                              update(0,n,1) ;
                    }

         rem(i,n-1,-1)
         {
                   clr = 0 ;  f = 0 ;

                   x = i ;
                   y = min(n-1,pre[clr][i]) ;

                   x ++; y++ ;

                   ans = 0 ;
                   F = 0 ;    Clr = 1 ;
                   query(0,n,1) ;

                   //DEB(f,clr,i,x,y,ans) ;

                   dp[f][clr][i] = ans ;

                    ///////////////////////////////////////

                   clr = 0 ;  f = 1 ;

                   x = i ;
                   y = min(i+k-2,pre[clr][i]) ;

                   x ++; y++ ;

                    ans = 0 ;
                    F = 1 ;    Clr = 1 ;
                    query(0,n,1) ;

                   dp[f][clr][i] = ans ;

                   ///////////////////////////////////////
                   ///////////////////////////////////////
                   ///////////////////////////////////////

                   clr = 1 ;
                   val = 0 ;

                   if(pre[clr][i]>=i+k-1)
                   {
                             x = i+k-1 ;
                             y = min(n-1,pre[clr][i]) ;

                             x ++; y++ ;

                              ans = 0 ;
                              F = 1 ;    Clr = 0 ;
                              query(0,n,1) ;

                              val = ans ;
                   }

                   ///////////////////////////////////////
                   ///////////////////////////////////////
                   ///////////////////////////////////////

                   clr = 1 ;  f = 0 ;

                   x = i ;
                   y = min(i+k-2,pre[clr][i]) ;

                   x ++; y++ ;

                    ans = 0 ;
                    F = f ;    Clr = 0 ;
                    query(0,n,1) ;

                   dp[f][clr][i] = ans+val ;      if(dp[f][clr][i]>=M)          dp[f][clr][i] -= M ;

                   ///////////////////////////////////////

                   clr = 1 ;  f = 1 ;

                   x = i ;
                   y = min(i+k-2,pre[clr][i]) ;

                   x ++; y++ ;

                    ans = 0 ;
                    F = f ;    Clr = 0 ;
                    query(0,n,1) ;

                   dp[f][clr][i] = ans+val ;      if(dp[f][clr][i]>=M)          dp[f][clr][i] -= M ;

                   rep(F,0,2)
                              rep(Clr,0,2)
                              {
                                        x = i ;
                                        update(0,n,1) ;

                                        //DEB(dp[F][Clr][i]) ;
                              }
         }

          ans = dp[0][0][0] + dp[0][1][0] ;

          int tot = 1 ;

          rep(i,0,n)
          {
                    if(in[i]=='X')
                    {
                              tot <<= 1 ;
                              if(tot>=M)          tot -= M ;
                    }
          }

          ans = tot-ans ;

          ans %= M ;
          ans += M ;
          ans %= M ;

         //rep(i,0,n)
                  //scanf("%d",&m);

         printf("%d\n",ans) ;

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string.h>

const int N=100010;
const int inf=0x3f3f3f3f;
const long long mod=1000000007ll;

using namespace std;

int n,k;
char s[N];
long long p[N],suml[N],sumr[N],b[N],w[N],sb[N],sw[N];

int main()
{
	p[0]=1;
	for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
	scanf("%d%d%s",&n,&k,&s[1]);
	for(int i=1;i<=n;i++)
		suml[i]=suml[i-1]+(s[i]=='X');
	for(int i=n;i>=1;i--)
		sumr[i]=sumr[i+1]+(s[i]=='X');
	for(int i=1,l=0,r=0;i<=n;i++)
	{
		if(s[i]=='X' || s[i]=='B') r++;
		else l=r=i;
		if(r-l>=k) b[i]=p[(i<=k?0:suml[i-k-1])]-(i==k?0:sb[i-k-1]);
		else b[i]=0;b[i]%=mod;
		if((i>k) && (s[i-k]=='B')) b[i]=0;
		if(s[i]=='X') sb[i]=(2*sb[i-1]+b[i])%mod;
		else sb[i]=(sb[i-1]+b[i])%mod;
	}
	for(int i=n,l=n+1,r=n+1;i>=1;i--)
	{
		if(s[i]=='X' || s[i]=='W') l--;
		else r=l=i;
		if(r-l>=k) w[i]=p[(i+k==n?0:sumr[i+k+1])]-sw[i+k+1];
		else w[i]=0;w[i]%=mod;
		if(s[i+k]=='W') w[i]=0;
		if(s[i]=='X') sw[i]=(2*sw[i+1]+w[i])%mod;
		else sw[i]=(sw[i+1]+w[i])%mod;
	}
	long long ret=0;
	for(int i=1;i<n;i++)
		ret+=b[i]*sw[i+1],ret%=mod;
	cout<<(ret+mod)%mod<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string.h>

const int N=2000010;
const int inf=0x3f3f3f3f;
const long long mod=1000000007ll;

using namespace std;

int n,k;
char s[N];
long long p[N],suml[N],sumr[N],b[N],w[N],sb[N],sw[N];

int main()
{
	p[0]=1;
	for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
	scanf("%d%d%s",&n,&k,&s[1]);
	for(int i=1;i<=n;i++)
		suml[i]=suml[i-1]+(s[i]=='X');
	for(int i=n;i>=1;i--)
		sumr[i]=sumr[i+1]+(s[i]=='X');
	for(int i=1,l=0,r=0;i<=n;i++)
	{
		if(s[i]=='X' || s[i]=='B') r++;
		else l=r=i;
		if(r-l>=k && s[i-k]!='B') b[i]=p[(i<=k?0:suml[i-k-1])]-(i<=k?0:sb[i-k-1]);
		else b[i]=0;b[i]%=mod;
		if(s[i]=='X') sb[i]=(2*sb[i-1]+b[i])%mod;
		else sb[i]=(sb[i-1]+b[i])%mod;
	}
	for(int i=n,l=n+1,r=n+1;i>=1;i--)
	{
		if(s[i]=='X' || s[i]=='W') l--;
		else r=l=i;
		if(r-l>=k && s[i+k]!='W') w[i]=p[(i+k>=n?0:sumr[i+k+1])]-sw[i+k+1];
		else w[i]=0;w[i]%=mod;
		if(s[i]=='X') sw[i]=(2*sw[i+1]+w[i])%mod;
		else sw[i]=(sw[i+1]+w[i])%mod;
	}
	long long ret=0;
	for(int i=1;i<n;i++)
		ret+=b[i]*sw[i+1],ret%=mod;
	cout<<(ret+mod)%mod<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string.h>

const int N=200010;
const int inf=0x3f3f3f3f;
const long long mod=1000000007ll;

using namespace std;

int n,k;
char s[N];
long long p[N],suml[N],sumr[N],b[N],w[N],sb[N],sw[N];

int main()
{
	p[0]=1;
	for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
	scanf("%d%d%s",&n,&k,&s[1]);
	for(int i=1;i<=n;i++)
		suml[i]=suml[i-1]+(s[i]=='X');
	for(int i=n;i>=1;i--)
		sumr[i]=sumr[i+1]+(s[i]=='X');
	for(int i=1,l=0,r=0;i<=n;i++)
	{
		if(s[i]=='X' || s[i]=='B') r++;
		else l=r=i;
		if(r-l>=k) b[i]=p[(i<=k?0:suml[i-k-1])]-(i==k?0:sb[i-k-1]);
		else b[i]=0;b[i]%=mod;
		if((i>k) && (s[i-k]=='B')) b[i]=0;
		if(s[i]=='X') sb[i]=(2*sb[i-1]+b[i])%mod;
		else sb[i]=(sb[i-1]+b[i])%mod;
	}
	for(int i=n,l=n+1,r=n+1;i>=1;i--)
	{
		if(s[i]=='X' || s[i]=='W') l--;
		else r=l=i;
		if(r-l>=k) w[i]=p[(i+k==n?0:sumr[i+k+1])]-sw[i+k+1];
		else w[i]=0;w[i]%=mod;
		if(s[i+k]=='W') w[i]=0;
		if(s[i]=='X') sw[i]=(2*sw[i+1]+w[i])%mod;
		else sw[i]=(sw[i+1]+w[i])%mod;
	}
	long long ret=0;
	for(int i=1;i<n;i++)
		ret+=b[i]*sw[i+1],ret%=mod;
	cout<<(ret+mod)%mod<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string.h>

const int N=100010;
const int inf=0x3f3f3f3f;
const long long mod=1000000007ll;

using namespace std;

int n,k;
char s[N];
long long p[N],suml[N],sumr[N],b[N],w[N],sb[N],sw[N];

int main()
{
	p[0]=1;
	for(int i=1;i<N;i++) p[i]=p[i-1]*2%mod;
	scanf("%d%d%s",&n,&k,&s[1]);
	for(int i=1;i<=n;i++)
		suml[i]=suml[i-1]+(s[i]=='X');
	for(int i=n;i>=1;i--)
		sumr[i]=sumr[i+1]+(s[i]=='X');
	for(int i=1,l=0,r=0;i<=n;i++)
	{
		if(s[i]=='X' || s[i]=='B') r++;
		else l=r=i;
		if(r-l>=k) b[i]=p[(i<=k?0:suml[i-k-1])]-(i==k?0:sb[i-k-1]);
		else b[i]=0;b[i]%=mod;
		if((i>k) && (s[i-k]=='B')) b[i]=0;
		if(s[i]=='X') sb[i]=(2*sb[i-1]+b[i])%mod;
		else sb[i]=(sb[i-1]+b[i])%mod;
	}
	for(int i=n,l=n+1,r=n+1;i>=1;i--)
	{
		if(s[i]=='X' || s[i]=='W') l--;
		else r=l=i;
		if(r-l>=k) w[i]=p[(i+k==n?0:sumr[i+k+1])]-sw[i+k+1];
		else w[i]=0;w[i]%=mod;
		if(s[i+k]=='W') w[i]=0;
		if(s[i]=='X') sw[i]=(2*sw[i+1]+w[i])%mod;
		else sw[i]=(sw[i+1]+w[i])%mod;
	}
	long long ret=0;
	for(int i=1;i<n;i++)
		ret+=b[i]*sw[i+1],ret%=mod;
	cout<<ret<<endl;
	return 0;
}


//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define mod 1000000007
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
ll dp[1000005],gen[100005];
ll dp2[1000005];
int rui[100005];
int rui2[100005];
int rui3[100005];
int two[100005];
int main()
{
	int n,k; string s;
	cin >> n >> k >> s;
	reverse(s.begin(),s.end()); s.pb('#');
	reverse(s.begin(),s.end());
	for(int i=1;i<=n;i++) rui[i]=rui[i-1]+(s[i]=='W');
	for(int i=1;i<=n;i++) rui2[i]=rui2[i-1]+(s[i]=='B');
	for(int i=1;i<=n;i++) rui3[i]=rui3[i-1]+(s[i]=='X');
	dp[0]=1LL;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='X') dp[i]=dp[i-1]*2LL;
		else dp[i]=dp[i-1];
		dp[i]%=mod;
		if(i<k) continue;
		if(rui[i]-rui[i-k]==0 && s[i-k]!='B')
		{
			dp[i]-=dp[max(0,i-k-1)]; gen[i]=dp[max(0,i-k-1)];
			dp[i]=(dp[i]+mod)%mod;
		}
	}
	dp2[n+1]=1LL;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='X') dp2[i]=dp2[i+1]*2LL;
		else dp2[i]=dp2[i+1];
		dp2[i]%=mod;
		if(i>n-k+1) continue;
		if(rui2[i+k-1]-rui2[i-1]==0 && s[i+k]!='W')
		{
			dp2[i]-=dp2[min(n+1,i+k+1)];
			dp2[i]=(dp2[i]+mod)%mod;
		}
	}
	two[0]=1;
	for(int i=1;i<=100000;i++) two[i]=(two[i-1]*2)%mod;
	long long ret=0LL;
	long long prev=0,prev2=0;
	for(int i=1;i<n;i++)
	{
		long long cal=gen[i];
		int vac=rui3[n]-rui3[i];
		long long x=(two[vac]-dp2[i+1]+mod)%mod;
		ret=(ret+(cal*x)%mod)%mod;
	}
	cout << ret << endl;
}


//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define mod 1000000007
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
ll dp[1000005],gen[100005];
ll dp2[1000005];
int rui[1000005];
int rui2[1000005];
int rui3[1000005];
ll two[1000005];
int main()
{
	int n,k; string s;
	cin >> n >> k >> s;
	reverse(s.begin(),s.end()); s.pb('#');
	reverse(s.begin(),s.end());
	for(int i=1;i<=n;i++) rui[i]=rui[i-1]+(s[i]=='W');
	for(int i=1;i<=n;i++) rui2[i]=rui2[i-1]+(s[i]=='B');
	for(int i=1;i<=n;i++) rui3[i]=rui3[i-1]+(s[i]=='X');
	dp[0]=1LL;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='X') dp[i]=dp[i-1]*2LL;
		else dp[i]=dp[i-1];
		dp[i]%=mod;
		if(i<k) continue;
		if(rui[i]-rui[i-k]==0 && s[i-k]!='B')
		{
			dp[i]-=dp[max(0,i-k-1)]; gen[i]=dp[max(0,i-k-1)];
			dp[i]=(dp[i]+mod)%mod;
		}
	}
	dp2[n+1]=1LL;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='X') dp2[i]=dp2[i+1]*2LL;
		else dp2[i]=dp2[i+1];
		dp2[i]%=mod;
		if(i>n-k+1) continue;
		if(rui2[i+k-1]-rui2[i-1]==0 && s[i+k]!='W')
		{
			dp2[i]-=dp2[min(n+1,i+k+1)];
			dp2[i]=(dp2[i]+mod)%mod;
		}
	}
	two[0]=1;
	for(int i=1;i<=1000000;i++) two[i]=(two[i-1]*2)%mod;
	long long ret=0LL;
	long long prev=0,prev2=0;
	for(int i=1;i<n;i++)
	{
		long long cal=gen[i];
		int vac=rui3[n]-rui3[i];
		long long x=(two[vac]-dp2[i+1]+mod)%mod;
		ret=(ret+(cal*x)%mod)%mod;
	}
	cout << ret << endl;
}


//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define mod 1000000007
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
ll dp[1000005],gen[100005];
ll dp2[1000005];
int rui[100005];
int rui2[100005];
int rui3[100005];
ll two[1000005];
int main()
{
	int n,k; string s;
	cin >> n >> k >> s;
	reverse(s.begin(),s.end()); s.pb('#');
	reverse(s.begin(),s.end());
	for(int i=1;i<=n;i++) rui[i]=rui[i-1]+(s[i]=='W');
	for(int i=1;i<=n;i++) rui2[i]=rui2[i-1]+(s[i]=='B');
	for(int i=1;i<=n;i++) rui3[i]=rui3[i-1]+(s[i]=='X');
	dp[0]=1LL;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='X') dp[i]=dp[i-1]*2LL;
		else dp[i]=dp[i-1];
		dp[i]%=mod;
		if(i<k) continue;
		if(rui[i]-rui[i-k]==0 && s[i-k]!='B')
		{
			dp[i]-=dp[max(0,i-k-1)]; gen[i]=dp[max(0,i-k-1)];
			dp[i]=(dp[i]+mod)%mod;
		}
	}
	dp2[n+1]=1LL;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='X') dp2[i]=dp2[i+1]*2LL;
		else dp2[i]=dp2[i+1];
		dp2[i]%=mod;
		if(i>n-k+1) continue;
		if(rui2[i+k-1]-rui2[i-1]==0 && s[i+k]!='W')
		{
			dp2[i]-=dp2[min(n+1,i+k+1)];
			dp2[i]=(dp2[i]+mod)%mod;
		}
	}
	two[0]=1;
	for(int i=1;i<=1000000;i++) two[i]=(two[i-1]*2)%mod;
	long long ret=0LL;
	long long prev=0,prev2=0;
	for(int i=1;i<=n;i++)
	{
		long long cal=gen[i];
		int vac=rui3[n]-rui3[i];
		long long x=(two[vac]-dp2[i+1]+mod)%mod;
		ret=(ret+(cal*x)%mod)%mod;
	}
	cout << ret << endl;
}


//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define mod 1000000007
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
ll dp[1000005],gen[100005];
ll dp2[1000005];
int rui[1000005];
int rui2[1000005];
int rui3[1000005];
ll two[1000005];
int main()
{
	int n,k; string s;
	cin >> n >> k >> s;
	reverse(s.begin(),s.end()); s.pb('#');
	reverse(s.begin(),s.end());
	for(int i=1;i<=n;i++) rui[i]=rui[i-1]+(s[i]=='W');
	for(int i=1;i<=n;i++) rui2[i]=rui2[i-1]+(s[i]=='B');
	for(int i=1;i<=n;i++) rui3[i]=rui3[i-1]+(s[i]=='X');
	dp[0]=1LL;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='X') dp[i]=dp[i-1]*2LL;
		else dp[i]=dp[i-1];
		dp[i]%=mod;
		if(i<k) continue;
		if(rui[i]-rui[i-k]==0 && s[i-k]!='B')
		{
			dp[i]-=dp[max(0,i-k-1)]; gen[i]=dp[max(0,i-k-1)];
			dp[i]=(dp[i]+mod)%mod;
		}
	}
	dp2[n+1]=1LL;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='X') dp2[i]=dp2[i+1]*2LL;
		else dp2[i]=dp2[i+1];
		dp2[i]%=mod;
		if(i>n-k+1) continue;
		if(rui2[i+k-1]-rui2[i-1]==0 && s[i+k]!='W')
		{
			dp2[i]-=dp2[min(n+1,i+k+1)];
			dp2[i]=(dp2[i]+mod)%mod;
		}
	}
	two[0]=1;
	for(int i=1;i<=1000000;i++) two[i]=(two[i-1]*2)%mod;
	long long ret=0LL;
	long long prev=0,prev2=0;
	for(int i=1;i<=n;i++)
	{
		long long cal=gen[i];
		int vac=rui3[n]-rui3[i];
		long long x=(two[vac]-dp2[i+1]+mod)%mod;
		ret=(ret+(cal*x)%mod)%mod;
	}
	cout << ret << endl;
}


//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
//これは、頭が悪く競プロが世界で一番できないHIR180が
//IOI2014日本代表になるまでのN日間の記録である。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define mod 1000000007
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
ll dp[1000005],gen[1000005];
ll dp2[1000005];
int rui[1000005];
int rui2[1000005];
int rui3[1000005];
ll two[1000005];
int main()
{
	int n,k; string s;
	cin >> n >> k >> s;
	reverse(s.begin(),s.end()); s.pb('#');
	reverse(s.begin(),s.end());
	for(int i=1;i<=n;i++) rui[i]=rui[i-1]+(s[i]=='W');
	for(int i=1;i<=n;i++) rui2[i]=rui2[i-1]+(s[i]=='B');
	for(int i=1;i<=n;i++) rui3[i]=rui3[i-1]+(s[i]=='X');
	dp[0]=1LL;
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='X') dp[i]=dp[i-1]*2LL;
		else dp[i]=dp[i-1];
		dp[i]%=mod;
		if(i<k) continue;
		if(rui[i]-rui[i-k]==0 && s[i-k]!='B')
		{
			dp[i]-=dp[max(0,i-k-1)]; gen[i]=dp[max(0,i-k-1)];
			dp[i]=(dp[i]+mod)%mod;
		}
	}
	dp2[n+1]=1LL;
	for(int i=n;i>=1;i--)
	{
		if(s[i]=='X') dp2[i]=dp2[i+1]*2LL;
		else dp2[i]=dp2[i+1];
		dp2[i]%=mod;
		if(i>n-k+1) continue;
		if(rui2[i+k-1]-rui2[i-1]==0 && s[i+k]!='W')
		{
			dp2[i]-=dp2[min(n+1,i+k+1)];
			dp2[i]=(dp2[i]+mod)%mod;
		}
	}
	two[0]=1;
	for(int i=1;i<=1000000;i++) two[i]=(two[i-1]*2LL)%mod;
	long long ret=0LL;
	long long prev=0,prev2=0;
	for(int i=1;i<=n;i++)
	{
		long long cal=gen[i];
		int vac=rui3[n]-rui3[i];
		long long x=(two[vac]-dp2[i+1]+mod)%mod;
		ret=(ret+(cal*x)%mod)%mod;
	}
	cout << ret << endl;
}


#include <iostream>
using namespace std;
int n,k;
long long fb[1000005],fw[1000005],fx[1000005];
long long dl[2000005];
long long s[1000005];
char st[1000005];
const long long  mod=1000000007;
int work(long long success[],long long f[],char st[],long long s[],char ch){
    int l=n,r=n;
    f[l]=s[0];
    long long sum=f[l];
    for(int i=1;i<=n;i++){
        if(st[i]==ch){l--;f[l]=0;}
        if(st[i]=='X'){l--;f[l]=sum;sum=(sum*2)%mod;}
        if(st[i]=='B'+'W'-ch){r=l;f[l]=sum;}
        if(r-l==k){success[i]=f[r--];sum-=success[i];sum+=mod;sum%=mod;}
        f[l]+=s[i];sum+=s[i];f[l]%=mod;sum%=mod;
    }
}
int main(){
    cin >> n >> k;
    cin >> st+1;
    s[0]=1;
    work(fb,dl,st,s,'B');
    work(fw,dl,st,fb,'W');
    long long ans=0,t=1;
    for(int i=1;i<=n;i++){fw[i]+=fw[i-1];if(st[i]=='X')fw[i]+=fw[i-1];fw[i]%=mod;}
    cout << fw[n];
}


#include <iostream>
using namespace std;
int n,k;
long long fb[100005],fw[100005],fx[100005];
long long dl[200005];
long long s[100005];
char st[100005];
const long long  mod=1000000007;
int work(long long success[],long long f[],char st[],long long s[],char ch){
    int l=n,r=n+1;
    f[l]=s[0];
    long long sum=f[l];
    for(int i=1;i<=n;i++){
        if(st[i]==ch){l--;f[l]=1;sum++;sum%=mod;}
        if(st[i]=='X'){l--;f[l]=sum;sum=(sum*2)%mod;}
        if(st[i]=='B'+'W'-ch){r=l+1;f[l]=sum;}
        if(r-l==k){success[i]=f[r--];}
        f[l]+=s[i];sum+=s[i];f[l]%=mod;sum%=mod;
    }
}
int main(){
    cin >> n >> k;
    cin >> st+1;
    s[0]=1;
    work(fb,dl,st,s,'B');
    work(fw,dl,st,fb,'W');
    long long ans=0,t=1;
    for(int i=n;i>0;i--){ans+=(fw[i]*t)%mod;ans%=mod;if(s[i]=='X')t=(t<<1)%1000000007;}
    cout << ans;
}