#include #include #include #include #include #include using namespace std; char s[110000]; int len; int n, divd, mod; int main (){ int i, j, k, T, ii; int Ti; scanf ( "%d", &T ); Ti = 0; while ( T -- ){ getchar (); gets (s); len = strlen (s); scanf ( "%d", &n ); divd = len / n; mod = len % n; printf ( "Case #%d:\n", ++Ti ); for ( i = 0; i < divd; i ++ ){ ii = i; j = 1; while ( ii < len ){ printf ( "%c", s[ii] ); if ( j <= mod ) ii += divd+1; else ii += divd; j ++; } } for ( i = 0; i < mod; i ++ ){ printf ( "%c", s[i*(divd+1)+divd] ); } printf ( "\n" ); } return 0; }