#include<bits/stdc++.h> using namespace std; struct node { int r; node *next[26]; node() { r=0; memset(next,0,sizeof(next)); } }; node root; int build_trie(string ss) { node *p=&root; int flag=0; for(int i=0;i<ss.size();i++) { if( (*p).next[ss[i]-'0']==NULL) { (*p).next[ss[i]-'0']=new node; } if( (*p).r==1) flag=1; p=(*p).next[ss[i]-'0']; } (*p).r=1; if(flag==1) return 1; else return 0; } int main() { int temp=0; int flag=0; string ss; while(cin>>ss) { if(ss=="9") { temp++; if(flag) cout<<"Set "<<temp<<" is not immediately decodable"<<endl; else cout<<"Set "<<temp<<" is immediately decodable"<<endl; flag=0; for(int i=0;i<=25;i++) root.next[i]=NULL;// zhi zheng qin kong } else { if(flag==1) continue; if(build_trie(ss)==1) flag=1; } } }