#include #include #include using namespace::std; const int maxn = 1e5 + 10; int t, n, len, k; char s[maxn], p[maxn]; void GetLine(char *s) { char ch; while ((ch = getchar()) == '\n'); s[0] = ch; int cnt = 1; while ((ch = getchar()) != '\n') { s[cnt++] = ch; } s[cnt] = '\0'; } int main() { cin >> t; int a = 1; while (t--) { GetLine(s); scanf("%d", &n); len = strlen(s); k = len / n; int cnt = 0; for (int i = 0; i < n; i++) for (int j = 0; i + j * n < len; j++) { p[i + j * n] = s[cnt++]; } p[len] = '\0'; printf("Case #%d:\n%s\n", a++, p); } return 0; }