public static void main ( String [] args ) {
        String s1 = "", s2="";
	ArrayList<Integer> data = new ArrayList<Integer>();
   
	for ( int i=1000; i<=9999; i++ ) {
	    s1 = i+"";
	    data.clear();
	    if ( isPrime(i) ) {
		data.add(i);
	    }
	    for ( int j=i+1; j<=9999; j++ ) {
		s2 = j+"";
		if ( isPrime(j) && isPer(s1,s2) ) {
		    data.add(j);
		}
	    }
	    if ( form(data) ) {
		break;
	    }
	    
	}

    }