<?php

include("vendor/autoload.php");

for($p1 = 1000; $p1<9999-(2*3330); $p1++)
{
    if(CodingTests\Prime::isPrime($p1)) 
    {
        $p2 = $p1 + 3330;
        if(CodingTests\Prime::isPrime($p2)) 
        {
            $p3 = $p2 + 3330;
            if(CodingTests\Prime::isPrime($p3)) 
            {   
               $p1_occ = count_chars($p1);
               ksort($p1_occ);
               $p2_occ = count_chars($p2);
               ksort($p2_occ);
               $p3_occ = count_chars($p3);
               ksort($p3_occ);

               if( $p1_occ == $p2_occ && $p2_occ == $p3_occ) 
               {
                    echo "Permutation $p1$p2$p3\n";
               }
            }
        }
    }

}