#include<iostream> #include<cstring> #include<algorithm> using namespace std; int cnt; struct node{ char data[15]; int len; }Node[10]; bool decode(){ bool flag; int k; for(int i=0;i<cnt-1;i++){ for(int j=i+1;j<cnt;j++){ flag = false; if(Node[i].len>Node[j].len){ for(k=0;k<Node[j].len;k++){ if(Node[i].data[k]!=Node[j].data[k]){ break; } } if(k==Node[j].len){ flag = true; } } if(flag)return false; flag = false; if(Node[i].len<Node[j].len){ for(k=0;k<Node[i].len;k++){ if(Node[i].data[k]!=Node[j].data[k]){ break; } } if(k==Node[i].len){ flag = true; } } if(flag)return false; } } return true; } int main(){ cnt = 0; char ch[15]; int num = 1; while(scanf("%s",ch)==1){ if(ch[0]=='9'){ if(decode())printf("Set %d is immediately decodable\n",num); else printf("Set %d is not immediately decodable\n",num); cnt = 0; num++; } strcpy(Node[cnt].data,ch); Node[cnt].len = strlen(ch); cnt++; } return 0; }