import java.util.*;
import java.io.*;
import java.net.*;
import java.lang.*;

public class queenworker 
{
   public static void main(String args[]) throws IOException
   {
      int job_id = 1;
      int task_id = Integer.parseInt(args[0]);

      String gp_name = "gp1";
      String main_pt = "p1";
      int main_pno;
      String pt_name;
      int pt_no;

      int i, j, k, status;

      JMPF def_obj;
 
      pt_name = String.valueOf(task_id);
      def_obj = new JMPF(job_id, task_id);
      pt_no = def_obj.CreatePort(pt_name);
      status = def_obj.LocatePortGroup(gp_name, true);
      status = def_obj.AddMember(gp_name, pt_no);

      main_pno = def_obj.LocatePort(main_pt);

      int n = def_obj.BlockReceiveInt(pt_no);
      int no = 1;
      for (i = 1; i < n-1; i++)
         no = no + no * i;

      String arraystr[] = new String[no+1];
      int arrayval[][] = new int[no+1][n+1];
      String arrayflag[] = new String[no+1];

      String string = "";
      StringTokenizer st;
      String str;

      DataInputStream dis = def_obj.CreateDIS(pt_no);
      for (i = 1; i <= no; i++)
      {
         arraystr[i] = def_obj.ReceiveString(dis);
         System.out.println("The received string is : " + arraystr[i]);
         st = new StringTokenizer(arraystr[i]);
         for ( j = 1; j <= n; j++)
            arrayval[i][j] = Integer.parseInt(st.nextToken());
      }

      boolean flag = true; 
      for (i = 1; i <= no; i++)
      {
         flag = true;
         for (j = 1; j < n; j++)
         {
            k = j + 1;
            if ((Math.abs(arrayval[i][j] - arrayval[i][k])) == 1)
               flag = false;
         }
         if (flag == true)
            arrayflag[i] = "true";
         else if (flag == false)
            arrayflag[i] = "false";
      }
      for (i = 1; i <= no; i++)
      {
         str = arraystr[i] + " " + arrayflag[i];
         System.out.println("The sending string is " + str);
         status = def_obj.Send(main_pno, str);
      }

      def_obj.ClosePorts();
   }
}


