import java.net.*; import java.io.*; public class randur{ public static void main(String argumendid[]){ try{ ServerSocket ss=new ServerSocket(3001); Socket s[]; s=new Socket[3]; s[1]=ss.accept(); PrintWriter[] v=new PrintWriter[3]; v[1]=new PrintWriter(s[1].getOutputStream(), true); int x[]=new int[3]; x[1]=9; int y[]=new int[3]; y[1]=0; s[2]=ss.accept(); v[2]=new PrintWriter(s[2].getOutputStream(), true); x[2]=9; y[2]=0; boolean voit=false; int i=1,h=2; while(!voit){ if(i==1){i=2;h=1;}else{i=1;h=2;}; int vastus[]=loim.arvuta(s[h],x[h],y[h],x[i],y[i]); x[h]=vastus[0]; y[h]=vastus[1]; if((x[i]==0)&(y[i]==9)){ voit=true; v[i].println("!"); v[h].println("("); } } s[1].close(); s[2].close(); }catch(Exception e){System.out.println("Viga: "+e);} } } class loim{ public static int[] arvuta(Socket sc, int x, int y, int xx, int yy){ try{ BufferedReader sisse=new BufferedReader(new InputStreamReader(sc.getInputStream())); PrintWriter valja=new PrintWriter(sc.getOutputStream(), true); valja.println("t"+xx+"|"+yy); valja.println("s"+x+"|"+y); valja.println("SK"); boolean veel=true; while(veel){ try{ int ay=0; int ax=0; String s=sisse.readLine(); veel=false; if(s.equals("8")){ax--;} if(s.equals("4")){ay--;} if(s.equals("6")){ay++;} if(s.equals("2")){ax++;} ax=x+ax; ay=y+ay; if((ax>9)|(ax<0)){veel=true;valja.println("v");System.out.println(ax+" "+ay);} else{ if((ay<0)|(ay>9)){veel=true;valja.println("v");System.out.println(ax+" "+ay);} else{ if(((ax==0)&(ay==5))|((ax==1)&(ay==8))|((ax==2)&(ay==1))|((ax==3)&(ay==3))|((ax==3)&(ay==6))|((ax==4)&(ay==5))){ if(((ax==5)&(ay==4))|((ax==6)&(ay==3))|((ax==6)&(ay==7))|((ax==7)&(ay==1))|((ax==8)&(ay==8))|((ax==9)&(ay==5))){ veel=true;valja.println("v");System.out.println(ax+" "+ay);} }else{ try{ x=ax; y=ay; valja.println("s"+x+"|"+y); }catch(Exception q){System.out.println("Viga: "+q);} } } } }catch(Exception e){System.out.println("Viga: "+e);} } }catch(Exception e){System.out.println("Viga: "+e);} int tulemus[]={x, y}; return tulemus; } }