#include #include using namespace std; #define MAXN 100000 char str[MAXN+5]; int main() { // freopen ("input.txt","r",stdin); int t, t1, k, k1; scanf ("%d", &t); getchar (); for (t1 = 1; t1 <= t; t1 ++) { memset (str, 0, sizeof(str)); gets(str); scanf ("%d", &k); getchar (); printf ("Case #%d:\n", t1); int i, n = strlen(str), x = n/k, c = n%k, c1; for (k1 = 0; k1 < x; k1 ++)// 159263748 { c1 = c, i = k1; while (c1 > 0 && i < n) { printf ("%c", str[i]); i += x+1; c1 --; } while (i < n) { printf ("%c", str[i]); i += x; } } for (i = x; c > 0; i += x+1) { printf ("%c", str[i]); c --; } putchar ('\n'); } return 0; }