#include <bits/stdc++.h>
//#include <ext/hash_map>
using namespace std;
//using namespace __gnu_cxx;
#define oo 1e9
#define ll long long
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define lop(i,n) for(int i=0;i<n;++i)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define pi acos(-1)
/////// Suffix array //////////////
/// O(NlogN) implementation ////
const int MX= 111111 ,alphabetSize= 128 ;
char str[ MX] ;
int n;
int rnk[ MX] ,newRnk[ MX] ,rnkSt[ MX] ,suf[ MX] ,newSuf[ MX] ;
int head[ alphabetSize] ,nxt[ MX] ,lcp[ MX] ;
void buildSA( ) {
memset ( head,- 1 ,sizeof head) ;
for ( n= 0 ; ! n|| str[ n- 1 ] ; ++ n) {
nxt[ n] = head[ ( int ) str[ n] ] ;
head[ ( int ) str[ n] ] = n;
}
int ns= 0 ,ng= 0 ; // next start - next group
for ( int i= 0 ; i< alphabetSize; i++ ) {
if ( head[ i] == - 1 ) continue ;
rnkSt[ ng] = ns;
for ( int j= head[ i] ; j! = - 1 ; j= nxt[ j] ) {
suf[ ns++ ] = j;
rnk[ j] = ng;
}
ng++ ;
}
newSuf[ 0 ] = suf[ 0 ] ;
ng= 0 ;
for ( int len= 1 ; ng! = n- 1 ; len<<= 1 ) {
for ( int i= 0 ; i< n; i++ ) {
int j= suf[ i] - len;
if ( j< 0 ) continue ;
newSuf[ rnkSt[ rnk[ j] ] ++ ] = j;
}
ng= 0 ;
for ( int i= 1 ; i< n; i++ ) {
ng+ = ( rnk[ newSuf[ i- 1 ] ] < rnk[ newSuf[ i] ]
|| ( rnk[ newSuf[ i- 1 ] ] == rnk[ newSuf[ i] ]
&& rnk[ newSuf[ i- 1 ] + len] < rnk[ newSuf[ i] + len] ) ) ;
newRnk[ i] = ng;
if ( newRnk[ i] ! = newRnk[ i- 1 ] ) rnkSt[ ng] = i;
}
for ( int i= 0 ; i< n; i++ ) {
suf[ i] = newSuf[ i] ;
rnk[ suf[ i] ] = newRnk[ i] ;
}
}
}
void buildLCP( ) {
int cnt= 0 ;
for ( int i= 0 ; i< n- 1 ; i++ ) {
int j= suf[ rnk[ i] - 1 ] ;
while ( str[ i+ cnt] == str[ j+ cnt] ) cnt++ ;
lcp[ rnk[ i] ] = cnt;
if ( cnt) cnt-- ;
}
}
char note[ 22222 ] ;
char str2[ MX] ;
string tmp,tmp2;
vector< string> ans;
void solve( ) {
int idx= 0 ;
while ( note[ idx] ) {
while ( note[ idx] && note[ idx] == ' ' ) idx++ ;
if ( ! note[ idx] ) break ;
int l= 0 ,r= n- 1 ;
int nw= idx;
while ( note[ nw] && note[ nw] >= str[ suf[ l] + nw- idx] && note[ nw] <= str[ suf[ r] + nw- idx] ) {
int l1= l,r1= r,mid;
while ( l1< r1) {
mid= l1+ ( r1- l1) / 2 ;
if ( str[ suf[ mid] + nw- idx] >= note[ nw] ) r1= mid;
else l1= mid+ 1 ;
}
l= l1;
l1= l,r1= r;
while ( l1< r1) {
mid= l1+ ( r1- l1+ 1 ) / 2 ;
if ( str[ suf[ mid] + nw- idx] <= note[ nw] ) l1= mid;
else r1= mid- 1 ;
}
r= l1;
if ( note[ nw] == str[ suf[ l] + nw- idx] || note[ nw] == str[ suf[ r] + nw- idx] )
nw++ ;
else break ;
}
nw-- ;
tmp= "" ;
int s= suf[ l] ,e= suf[ l] + nw- idx;
for ( int i= s; i<= e; i++ )
tmp+ = str2[ i] ;
reverse( all( tmp) ) ;
while ( tmp[ 0 ] == ' ' ) tmp.erase ( tmp.begin ( ) ) ;
reverse( all( tmp) ) ;
ans.push_back ( tmp) ;
idx= nw+ 1 ;
}
}
int main( ) {
#ifndef ONLINE_JUDGE
freopen ( "input.txt" , "rt" , stdin ) ;
//freopen("output.txt", "wt", stdout);
#endif
getline( cin ,tmp) ;
for ( int i= 0 ; i< sz( tmp) ; i++ ) note[ i] = tmp[ i] ;
note[ sz( tmp) ] = '\0 ' ;
while ( getline( cin ,tmp) ) tmp2= tmp2+ '#' + tmp;
for ( int i= 0 ; i< sz( tmp2) ; i++ ) {
str2[ i] = tmp2[ i] ;
str[ i] = tolower ( tmp2[ i] ) ;
}
str2[ sz( tmp2) ] = '\0 ' ;
str[ sz( tmp2) ] = '\0 ' ;
buildSA( ) ;
solve( ) ;
cout << sz( ans) << endl;
for ( int i= 0 ; i< sz( ans) ; i++ ) {
for ( int j= 0 ; j< sz( ans[ i] ) ; j++ )
putchar ( ans[ i] [ j] ) ;
printf ( "\n " ) ;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Ci8vI2luY2x1ZGUgPGV4dC9oYXNoX21hcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKLy91c2luZyBuYW1lc3BhY2UgX19nbnVfY3h4OwoKI2RlZmluZSBvbyAgICAgICAxZTkKI2RlZmluZSBsbCAgICAgICBsb25nIGxvbmcKI2RlZmluZSBzYyh4KSAgICBzY2FuZigiJWQiLCZ4KQojZGVmaW5lIHNjbCh4KSAgIHNjYW5mKCIlbGxkIiwmeCkKI2RlZmluZSBsb3AoaSxuKSBmb3IoaW50IGk9MDtpPG47KytpKQojZGVmaW5lIHN6KHgpICAgIChpbnQpeC5zaXplKCkKI2RlZmluZSBhbGwoeCkgICB4LmJlZ2luKCkseC5lbmQoKQojZGVmaW5lIEYgICAgICAgIGZpcnN0CiNkZWZpbmUgUyAgICAgICAgc2Vjb25kCiNkZWZpbmUgcGkgICAgICAgYWNvcygtMSkKCi8vLy8vLy8gU3VmZml4IGFycmF5IC8vLy8vLy8vLy8vLy8vCi8vLyAgTyhObG9nTikgaW1wbGVtZW50YXRpb24gIC8vLy8KY29uc3QgaW50IE1YPTExMTExMSxhbHBoYWJldFNpemU9MTI4OwoKY2hhciBzdHJbTVhdOwppbnQgbjsKaW50IHJua1tNWF0sbmV3Um5rW01YXSxybmtTdFtNWF0sc3VmW01YXSxuZXdTdWZbTVhdOwppbnQgaGVhZFthbHBoYWJldFNpemVdLG54dFtNWF0sbGNwW01YXTsKCnZvaWQgYnVpbGRTQSgpewogIG1lbXNldChoZWFkLC0xLHNpemVvZiBoZWFkKTsKICBmb3Iobj0wOyFufHxzdHJbbi0xXTsrK24pewogICAgbnh0W25dPWhlYWRbKGludClzdHJbbl1dOwogICAgaGVhZFsoaW50KXN0cltuXV09bjsKICB9CiAgaW50IG5zPTAsbmc9MDsgIC8vIG5leHQgc3RhcnQgLSBuZXh0IGdyb3VwCiAgZm9yKGludCBpPTA7aTxhbHBoYWJldFNpemU7aSsrKXsKICAgIGlmKGhlYWRbaV09PS0xKWNvbnRpbnVlOwogICAgcm5rU3RbbmddPW5zOwogICAgZm9yKGludCBqPWhlYWRbaV07aiE9LTE7aj1ueHRbal0pewogICAgICBzdWZbbnMrK109ajsKICAgICAgcm5rW2pdPW5nOwogICAgfQogICAgbmcrKzsKICB9CiAgbmV3U3VmWzBdPXN1ZlswXTsKICBuZz0wOwogIGZvcihpbnQgbGVuPTE7bmchPW4tMTtsZW48PD0xKXsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICBpbnQgaj1zdWZbaV0tbGVuOwogICAgICBpZihqPDApY29udGludWU7CiAgICAgIG5ld1N1ZltybmtTdFtybmtbal1dKytdPWo7CiAgICB9CiAgICBuZz0wOwogICAgZm9yKGludCBpPTE7aTxuO2krKyl7CiAgICAgIG5nKz0ocm5rW25ld1N1ZltpLTFdXTxybmtbbmV3U3VmW2ldXQogICAgICAgICAgfHwocm5rW25ld1N1ZltpLTFdXT09cm5rW25ld1N1ZltpXV0KICAgICAgICAgICYmcm5rW25ld1N1ZltpLTFdK2xlbl08cm5rW25ld1N1ZltpXStsZW5dKSk7CiAgICAgIG5ld1Jua1tpXT1uZzsKICAgICAgaWYobmV3Um5rW2ldIT1uZXdSbmtbaS0xXSlybmtTdFtuZ109aTsKICAgIH0KICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICBzdWZbaV09bmV3U3VmW2ldOwogICAgICBybmtbc3VmW2ldXT1uZXdSbmtbaV07CiAgICB9CiAgfQp9Cgp2b2lkIGJ1aWxkTENQKCl7CiAgaW50IGNudD0wOwogIGZvcihpbnQgaT0wO2k8bi0xO2krKyl7CiAgICBpbnQgaj1zdWZbcm5rW2ldLTFdOwogICAgd2hpbGUoc3RyW2krY250XT09c3RyW2orY250XSljbnQrKzsKICAgIGxjcFtybmtbaV1dPWNudDsKICAgIGlmKGNudCljbnQtLTsKICB9Cn0KCmNoYXIgbm90ZVsyMjIyMl07CmNoYXIgc3RyMltNWF07CnN0cmluZyB0bXAsdG1wMjsKCnZlY3RvcjxzdHJpbmc+IGFuczsKCnZvaWQgc29sdmUoKXsKICBpbnQgaWR4PTA7CiAgd2hpbGUobm90ZVtpZHhdKXsKICAgIHdoaWxlKG5vdGVbaWR4XSYmbm90ZVtpZHhdPT0nICcpaWR4Kys7CiAgICBpZighbm90ZVtpZHhdKWJyZWFrOwogICAgaW50IGw9MCxyPW4tMTsKICAgIGludCBudz1pZHg7CiAgICB3aGlsZShub3RlW253XSYmbm90ZVtud10+PXN0cltzdWZbbF0rbnctaWR4XSYmbm90ZVtud108PXN0cltzdWZbcl0rbnctaWR4XSl7CiAgICAgIGludCBsMT1sLHIxPXIsbWlkOwogICAgICB3aGlsZShsMTxyMSl7CiAgICAgICAgbWlkPWwxKyhyMS1sMSkvMjsKICAgICAgICBpZihzdHJbc3VmW21pZF0rbnctaWR4XT49bm90ZVtud10pcjE9bWlkOwogICAgICAgIGVsc2UgbDE9bWlkKzE7CiAgICAgIH0KICAgICAgbD1sMTsKICAgICAgbDE9bCxyMT1yOwogICAgICB3aGlsZShsMTxyMSl7CiAgICAgICAgbWlkPWwxKyhyMS1sMSsxKS8yOwogICAgICAgIGlmKHN0cltzdWZbbWlkXStudy1pZHhdPD1ub3RlW253XSlsMT1taWQ7CiAgICAgICAgZWxzZSByMT1taWQtMTsKICAgICAgfQogICAgICByPWwxOwogICAgICBpZihub3RlW253XT09c3RyW3N1ZltsXStudy1pZHhdfHxub3RlW253XT09c3RyW3N1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HJvcCB0aGUgcHJpY2Ugb24gbmV3IHRoZXJtb3BhbmVzIG5vdyBvciBlbHNlClJhaW4gVXNlcnMgR3VpZGUKV2hpbGUgJnF1b3Q7cmFpbiZxdW90OyB3YXMgaW50ZW5kZWQgdG8gYmUgYSBnZW5lcmFsIHB1cnBvc2UgdG9vbCwgYXQgdGhlIHRpbWUgb2YKd3JpdGluZyB0aGUgcHJpbWFyeSBnb2FsIHdhcyB0byBzdHVkeSBvbmUgcGFydGljdWxhciBzb2Z0d2FyZSBzeXN0ZW0uCkFzIGEgcmVzdWx0LCBzb21lIHN0ZXBzIHRoYXQgYXJlIG9ubHkgZG9uZSBvbmNlIChzdWNoIGFzIGV4dHJhY3RpbmcKaW5mb3JtYXRpb24gZnJvbSB0aGUgcHJvZ3JhbSB1bmRlciBzdHVkeSkgYXJlIGRvbmUgdXNpbmcgY3VtYmVyc29tZQphZC1ob2MgdGVjaG5pcXVlcyB0aGF0IHJlcXVpcmUgc2lnbmlmaWNhbnQgbWFudWFsIGludGVydmVudGlvbi4gV2hpbGUKJnF1b3Q7cmFpbiZxdW90OyBjYW4gYmUgdXNlZCBvbiBhcmJpdHJhcnkgcHJvZ3JhbXMsIG1vcmUgZGV2ZWxvcG1lbnQgd29yayBuZWVkcwp0byBiZSBkb25lIGJlZm9yZSB0aGlzIGlzIGEgY29udmVuaWVudCBwcm9jZXNzLgo=
drop the price on new thermopanes now or else
Rain Users Guide
While "rain" was intended to be a general purpose tool, at the time of
writing the primary goal was to study one particular software system.
As a result, some steps that are only done once (such as extracting
information from the program under study) are done using cumbersome
ad-hoc techniques that require significant manual intervention. While
"rain" can be used on arbitrary programs, more development work needs
to be done before this is a convenient process.