#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 //---------------------------------------------------------- /* 全部区切る場合が辞書順最小かな? 区切らない、とすると区切る場合よりも辞書順が大きくなる 後ろから見て、dp[i] := [i,N)における、作れる文字列の個数 */ void solve() { ll N,K; cin>>N>>K; string S; cin>>S; auto cut=[&](int i) { if(i==N-1) return false; if(S[i]=='1') return true; if(S[i]=='2' && S[i+1]<='6') return true; return false; }; auto tochar=[&](int i) { int x=S[i]-'0'; x*=10; x+=S[i+1]-'0'; return char('a'+x-1); }; vector dp(N+1); dp[N]=1; for(int i=N-1; i>=0; i--) { if(S[i]=='0') { dp[i-1]+=dp[i+1]; i--; continue; } dp[i]+=dp[i+1]; if(cut(i)) dp[i]+=dp[i+2]; chmin(dp[i],INFL); } debug(dp); string ans; K--; for(int i=0; i>T; while(T--) solve(); }