#include int main (void) { int k, K; int n, i, j, t; char matches; char s[1003]; char y[101][1002]; int c[1002]; FILE *in = fopen ("biomed.in", "r"); fscanf (in, "%d\n", &K); for (k = 1; k <= K; k ++) { fscanf (in, "%d\n", &n); fgets (s, 1003, in); s[strlen(s)-1] = 0; for (i = 0; i < n; i ++) { fgets (y[i], 1003, in); y[i][strlen(y[i])-1] = 0; } c[0] = 0; for (i = 1; i <= strlen(s); i ++) { c[i] = strlen(s)+1; for (j = 0; j < n; j ++) if (strlen(y[j]) <= i) { matches = 1; for (t = 0; t < strlen(y[j]); t ++) if (y[j][t] != s[i-strlen(y[j])+t]) matches = 0; if (matches && (c[i-strlen(y[j])]+1 < c[i])) c[i] = c[i-strlen(y[j])]+1; } } printf ("Data Set %d:\n", k); if (c[strlen(s)] < strlen(s)+1) printf ("%d\n", c[strlen(s)]); else printf ("Impossible\n"); } fclose (in); return 0; }