#include using namespace std; #define ALL(x) (x).begin(), (x).end() #define REP(i,n) for(int i=0; ib ? a=b, true : false; } using ll=long long; const int INF=1e9+10; const ll INFL=4e18; #ifdef DEBUG #include "./debug.hpp" #else #define debug(...) #define print_line #endif /// @brief ビット演算 namespace Bit{ /// @brief 1であるビットの個数を返す int PopCount(int n) { return __builtin_popcount(n); } /// @brief 1であるビットの個数を返す int PopCount(ll n) { return __builtin_popcountll(n); } /// @brief popcountの偶奇を返す int Parity(int n) { return __builtin_parity(n); } /// @brief popcountの偶奇を返す int Parity(ll n) { return __builtin_parityll(n); } /// @brief 最上位ビットの位置を返す int TopBit(int n) { return n ? 31-__builtin_clz(n) : -1; } /// @brief 最上位ビットの位置を返す int TopBit(ll n) { return n ? 63-__builtin_clzll(n) : -1; } /// @brief 2進表現の長さを返す int BitLength(int n) { return n ? 32-__builtin_clz(n) : 1; } //// @brief 2進表現の長さを返す int BitLength(ll n) { return n ? 64-__builtin_clzll(n) : 1; } /// @brief 最下位ビットの位置を返す int LowBit(int n) { return n ? __builtin_ctz(n) : -1; } /// @brief 最下位ビットの位置を返す int LowBit(ll n) { return n ? __builtin_ctzll(n) : -1; } /// @brief 2のべき乗か否かを返す bool IsPowerOfTwo(int n) { return n && (n&-n)==n; } /// @brief 0~n-1 ビットを立てたビットマスクを返す ll Mask(int n) { return (1LL<>i&1); } /// @brief 整数 n の2進表現を返す /// @param len ビット数 /// @param rev 反転するか否か string ToBinary(ll n,int len=32,bool rev=false) { string ret; for(int i=0; i>N>>K; K--; if(N<=20) { int cur=0; REP(b,1<>i&1) s.push_back('M'); else s.push_back('A'); } bool ok=false; REP(i,N-3) if(s.substr(i,3)=="MMA") ok=true; if(ok) cur++; if(cur>K) { cout<>T; while(T--) solve(); }