/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
static boolean compareArr(int[] countTXT,int[] countPATT)
{
for(int i=0; i<256; i++)
{
if(countTXT[i]!=countPATT[i])
return false;
}
return true;
}
{
int countTXT[] = new int[256];
int countPATT[] = new int[256];
for(int i=0; i<patt.length(); i++)
{
countTXT[txt.charAt(i)]++;
countPATT[patt.charAt(i)]++;
}
for(int i=patt.length(); i<txt.length(); i++)
{
if(compareArr(countTXT,countPATT)==true)
System.
out.
print((i
-patt.
length())+" ");
countTXT[txt.charAt(i)]++;
countTXT[txt.charAt(i-patt.length())]--;
}
if(compareArr(countTXT,countPATT)==true)
System.
out.
print((txt.
length()-patt.
length())+" "); }
{
search(patt, txt);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXN0YXRpYyBib29sZWFuIGNvbXBhcmVBcnIoaW50W10gY291bnRUWFQsaW50W10gY291bnRQQVRUKQoJewoJCWZvcihpbnQgaT0wOyBpPDI1NjsgaSsrKQoJCXsKCQkJaWYoY291bnRUWFRbaV0hPWNvdW50UEFUVFtpXSkKCQkJIHJldHVybiBmYWxzZTsKCQl9CgkJcmV0dXJuIHRydWU7Cgl9CglzdGF0aWMgdm9pZCBzZWFyY2goU3RyaW5nIHBhdHQsIFN0cmluZyB0eHQpCgl7CgkJaW50IGNvdW50VFhUW10gPSBuZXcgaW50WzI1Nl07CgkJaW50IGNvdW50UEFUVFtdID0gbmV3IGludFsyNTZdOwoJCQoJCWZvcihpbnQ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