import java.io.*;
import java.net.*;

public class PortChecker {
    public static void main(String[] args) throws Exception {
        final int DEFAULT_PORT = 57294;
        for (int i = 10; i >=0; i--) {
            System.out.print("port" + i + " / " + (DEFAULT_PORT+i) + " ");
            try {
            	Socket socket = new Socket("localhost", DEFAULT_PORT+i);
            	PrintWriter out = new PrintWriter (new OutputStreamWriter(socket.getOutputStream()));
            	out.println("eval print(\"success\");");
            	out.close();
            	socket.close();		

            } catch (IOException e) {
             	System.out.println("failed");
                continue;
            }
            System.out.println("succeeded");
        }
    }
}