Lookup table C code

From Polymath1Wiki
Jump to: navigation, search
  1. include <stdio.h>
  2. include <stdlib.h>
  3. include <string.h>
  4. include <time.h>
  1. define NUM_LINES_3D 25 // 25 non-horizontal lines in [3]^3

// the bitmasks of the 25 lines in [3]^3 const long line_bitmasks[NUM_LINES_3D] = {262657l,263172l,266304l,270592l,525314l,532608l,1049601l,1050628l,1056832l,1065216l,2101256l,2105376l,4202512l,8396808l,8405024l,16781313l,16785412l,16810048l,16843008l,33562626l,33620096l,67117057l,67125252l,67174464l,67240192l};



/* stat[i] is 0,1,2,3 depending on whether i (represented base 3) is of type a,b,c,d. */

const int stat[27] = {0,1,0, 1,2,1, 0,1,0,

                     1,2,1, 2,3,2, 1,2,1,

0,1,0, 1,2,1, 0,1,0};


long *data[9][13][7][2]; // data[a][b][c][d] will point to all the (a,b,c,d) Moser sets

long numstat[9][13][7][2]; /* numstat[a][b][c][d] is the number of Moser sets with statistics (a,b,c,d) */

void init_numstat(void) // This was precomputed

{
	int a,b,c,d,s[4];

/* Initialise numstat */ for (a=0; a<9; a++) for (b=0; b<13; b++) for (c=0; c<7; c++) for (d=0; d<2; d++) numstat[a][b][c][d]=0;


      numstat[0][0][2][1] = 12l;
      numstat[0][0][3][1] = 8l;
      numstat[0][2][0][1] = 60l;
      numstat[0][2][1][0] = 384l;
      numstat[0][2][1][1] = 348l;
      numstat[0][2][2][0] = 930l;
      numstat[0][2][2][1] = 672l;
      numstat[0][2][3][0] = 1200l;
      numstat[0][2][3][1] = 432l;
      numstat[0][2][4][0] = 870l;
      numstat[0][2][5][0] = 336l;
      numstat[0][2][6][0] = 54l;
      numstat[0][3][0][1] = 160l;
      numstat[0][3][1][0] = 1200l;
      numstat[0][3][1][1] = 864l;
      numstat[0][3][2][0] = 2712l;
      numstat[0][3][2][1] = 1536l;
      numstat[0][3][3][0] = 3248l;
      numstat[0][3][3][1] = 896l;
      numstat[0][3][4][0] = 2172l;
      numstat[0][3][5][0] = 768l;
      numstat[0][3][6][0] = 112l;
      numstat[0][4][0][1] = 240l;
      numstat[0][4][1][0] = 2436l;
      numstat[0][4][1][1] = 1158l;
      numstat[0][4][2][0] = 4911l;
      numstat[0][4][2][1] = 1788l;
      numstat[0][4][3][0] = 5172l;
      numstat[0][4][3][1] = 864l;
      numstat[0][4][4][0] = 2988l;
      numstat[0][4][5][0] = 894l;
      numstat[0][4][6][0] = 108l;
      numstat[0][5][0][1] = 192l;
      numstat[0][5][1][0] = 3360l;
      numstat[0][5][1][1] = 792l;
      numstat[0][5][2][0] = 5712l;
      numstat[0][5][2][1] = 1008l;
      numstat[0][5][3][0] = 4920l;
      numstat[0][5][3][1] = 384l;
      numstat[0][5][4][0] = 2232l;
      numstat[0][5][5][0] = 504l;
      numstat[0][5][6][0] = 48l;
      numstat[0][6][0][1] = 64l;
      numstat[0][6][1][0] = 3192l;
      numstat[0][6][1][1] = 216l;
      numstat[0][6][2][0] = 4248l;
      numstat[0][6][2][1] = 216l;
      numstat[0][6][3][0] = 2696l;
      numstat[0][6][3][1] = 64l;
      numstat[0][6][4][0] = 816l;
      numstat[0][6][5][0] = 108l;
      numstat[0][6][6][0] = 8l;
      numstat[0][7][1][0] = 2064l;
      numstat[0][7][2][0] = 1932l;
      numstat[0][7][3][0] = 768l;
      numstat[0][7][4][0] = 108l;
      numstat[0][8][1][0] = 870l;
      numstat[0][8][2][0] = 480l;
      numstat[0][8][3][0] = 96l;
      numstat[0][9][1][0] = 216l;
      numstat[0][9][2][0] = 48l;
      numstat[0][9][3][0] = 8l;
      numstat[0][10][1][0] = 24l;
      numstat[2][0][0][1] = 24l;
      numstat[2][0][1][0] = 156l;
      numstat[2][0][1][1] = 132l;
      numstat[2][0][2][0] = 360l;
      numstat[2][0][2][1] = 240l;
      numstat[2][0][3][0] = 440l;
      numstat[2][0][3][1] = 144l;
      numstat[2][0][4][0] = 300l;
      numstat[2][0][5][0] = 108l;
      numstat[2][0][6][0] = 16l;
      numstat[2][1][0][0] = 324l;
      numstat[2][1][0][1] = 276l;
      numstat[2][1][1][0] = 1800l;
      numstat[2][1][1][1] = 1512l;
      numstat[2][1][2][0] = 4140l;
      numstat[2][1][2][1] = 2736l;
      numstat[2][1][3][0] = 5040l;
      numstat[2][1][3][1] = 1632l;
      numstat[2][1][4][0] = 3420l;
      numstat[2][1][5][0] = 1224l;
      numstat[2][1][6][0] = 180l;
      numstat[2][2][0][0] = 1716l;
      numstat[2][2][0][1] = 1320l;
      numstat[2][2][1][0] = 9216l;
      numstat[2][2][1][1] = 6960l;
      numstat[2][2][2][0] = 20460l;
      numstat[2][2][2][1] = 12096l;
      numstat[2][2][3][0] = 24000l;
      numstat[2][2][3][1] = 6912l;
      numstat[2][2][4][0] = 15660l;
      numstat[2][2][5][0] = 5376l;
      numstat[2][2][6][0] = 756l;
      numstat[2][3][0][0] = 5500l;
      numstat[2][3][0][1] = 3360l;
      numstat[2][3][1][0] = 27600l;
      numstat[2][3][1][1] = 16416l;
      numstat[2][3][2][0] = 56952l;
      numstat[2][3][2][1] = 26112l;
      numstat[2][3][3][0] = 61712l;
      numstat[2][3][3][1] = 13440l;
      numstat[2][3][4][0] = 36924l;
      numstat[2][3][5][0] = 11520l;
      numstat[2][3][6][0] = 1456l;
      numstat[2][4][0][0] = 11880l;
      numstat[2][4][0][1] = 4800l;
      numstat[2][4][1][0] = 53592l;
      numstat[2][4][1][1] = 20844l;
      numstat[2][4][2][0] = 98220l;
      numstat[2][4][2][1] = 28608l;
      numstat[2][4][3][0] = 93096l;
      numstat[2][4][3][1] = 12096l;
      numstat[2][4][4][0] = 47808l;
      numstat[2][4][5][0] = 12516l;
      numstat[2][4][6][0] = 1296l;
      numstat[2][5][0][0] = 18216l;
      numstat[2][5][0][1] = 3648l;
      numstat[2][5][1][0] = 70560l;
      numstat[2][5][1][1] = 13464l;
      numstat[2][5][2][0] = 108528l;
      numstat[2][5][2][1] = 15120l;
      numstat[2][5][3][0] = 83640l;
      numstat[2][5][3][1] = 4992l;
      numstat[2][5][4][0] = 33480l;
      numstat[2][5][5][0] = 6552l;
      numstat[2][5][6][0] = 528l;
      numstat[2][6][0][0] = 20328l;
      numstat[2][6][0][1] = 1152l;
      numstat[2][6][1][0] = 63840l;
      numstat[2][6][1][1] = 3456l;
      numstat[2][6][2][0] = 76464l;
      numstat[2][6][2][1] = 3024l;
      numstat[2][6][3][0] = 43136l;
      numstat[2][6][3][1] = 768l;
      numstat[2][6][4][0] = 11424l;
      numstat[2][6][5][0] = 1296l;
      numstat[2][6][6][0] = 80l;
      numstat[2][7][0][0] = 16632l;
      numstat[2][7][1][0] = 39216l;
      numstat[2][7][2][0] = 32844l;
      numstat[2][7][3][0] = 11520l;
      numstat[2][7][4][0] = 1404l;
      numstat[2][8][0][0] = 9900l;
      numstat[2][8][1][0] = 15660l;
      numstat[2][8][2][0] = 7680l;
      numstat[2][8][3][0] = 1344l;
      numstat[2][9][0][0] = 4180l;
      numstat[2][9][1][0] = 3672l;
      numstat[2][9][2][0] = 720l;
      numstat[2][9][3][0] = 104l;
      numstat[2][10][0][0] = 1188l;
      numstat[2][10][1][0] = 384l;
      numstat[2][11][0][0] = 204l;
      numstat[2][12][0][0] = 16l;
      numstat[3][0][0][1] = 32l;
      numstat[3][0][1][0] = 264l;
      numstat[3][0][1][1] = 144l;
      numstat[3][0][2][0] = 504l;
      numstat[3][0][2][1] = 216l;
      numstat[3][0][3][0] = 488l;
      numstat[3][0][3][1] = 104l;
      numstat[3][0][4][0] = 240l;
      numstat[3][0][5][0] = 48l;
      numstat[3][1][0][0] = 600l;
      numstat[3][1][0][1] = 336l;
      numstat[3][1][1][0] = 2808l;
      numstat[3][1][1][1] = 1488l;
      numstat[3][1][2][0] = 5328l;
      numstat[3][1][2][1] = 2208l;
      numstat[3][1][3][0] = 5136l;
      numstat[3][1][3][1] = 1056l;
      numstat[3][1][4][0] = 2520l;
      numstat[3][1][5][0] = 504l;
      numstat[3][2][0][0] = 2928l;
      numstat[3][2][0][1] = 1464l;
      numstat[3][2][1][0] = 13152l;
      numstat[3][2][1][1] = 6120l;
      numstat[3][2][2][0] = 23952l;
      numstat[3][2][2][1] = 8592l;
      numstat[3][2][3][0] = 22176l;
      numstat[3][2][3][1] = 3888l;
      numstat[3][2][4][0] = 10464l;
      numstat[3][2][5][0] = 2016l;
      numstat[3][3][0][0] = 8600l;
      numstat[3][3][0][1] = 3392l;
      numstat[3][3][1][0] = 35736l;
      numstat[3][3][1][1] = 12768l;
      numstat[3][3][2][0] = 59952l;
      numstat[3][3][2][1] = 15888l;
      numstat[3][3][3][0] = 50912l;
      numstat[3][3][3][1] = 6176l;
      numstat[3][3][4][0] = 21936l;
      numstat[3][3][5][0] = 3840l;
      numstat[3][4][0][0] = 16920l;
      numstat[3][4][0][1] = 4416l;
      numstat[3][4][1][0] = 62400l;
      numstat[3][4][1][1] = 14208l;
      numstat[3][4][2][0] = 91824l;
      numstat[3][4][2][1] = 14352l;
      numstat[3][4][3][0] = 67416l;
      numstat[3][4][3][1] = 3960l;
      numstat[3][4][4][0] = 24672l;
      numstat[3][4][5][0] = 3600l;
      numstat[3][5][0][0] = 23472l;
      numstat[3][5][0][1] = 3072l;
      numstat[3][5][1][0] = 73176l;
      numstat[3][5][1][1] = 8016l;
      numstat[3][5][2][0] = 88944l;
      numstat[3][5][2][1] = 6096l;
      numstat[3][5][3][0] = 52272l;
      numstat[3][5][3][1] = 1056l;
      numstat[3][5][4][0] = 14688l;
      numstat[3][5][5][0] = 1608l;
      numstat[3][6][0][0] = 23520l;
      numstat[3][6][0][1] = 896l;
      numstat[3][6][1][0] = 58368l;
      numstat[3][6][1][1] = 1824l;
      numstat[3][6][2][0] = 54216l;
      numstat[3][6][2][1] = 1008l;
      numstat[3][6][3][0] = 22904l;
      numstat[3][6][3][1] = 112l;
      numstat[3][6][4][0] = 4176l;
      numstat[3][6][5][0] = 264l;
      numstat[3][7][0][0] = 17136l;
      numstat[3][7][1][0] = 31272l;
      numstat[3][7][2][0] = 19896l;
      numstat[3][7][3][0] = 5112l;
      numstat[3][7][4][0] = 432l;
      numstat[3][8][0][0] = 9000l;
      numstat[3][8][1][0] = 10776l;
      numstat[3][8][2][0] = 3936l;
      numstat[3][8][3][0] = 480l;
      numstat[3][9][0][0] = 3320l;
      numstat[3][9][1][0] = 2160l;
      numstat[3][9][2][0] = 312l;
      numstat[3][9][3][0] = 32l;
      numstat[3][10][0][0] = 816l;
      numstat[3][10][1][0] = 192l;
      numstat[3][11][0][0] = 120l;
      numstat[3][12][0][0] = 8l;
      numstat[4][0][0][1] = 16l;
      numstat[4][0][1][0] = 246l;
      numstat[4][0][1][1] = 54l;
      numstat[4][0][2][0] = 336l;
      numstat[4][0][2][1] = 72l;
      numstat[4][0][3][0] = 212l;
      numstat[4][0][3][1] = 32l;
      numstat[4][0][4][0] = 60l;
      numstat[4][0][5][0] = 6l;
      numstat[4][1][0][0] = 660l;
      numstat[4][1][0][1] = 144l;
      numstat[4][1][1][0] = 2280l;
      numstat[4][1][1][1] = 456l;
      numstat[4][1][2][0] = 3072l;
      numstat[4][1][2][1] = 600l;
      numstat[4][1][3][0] = 1896l;
      numstat[4][1][3][1] = 264l;
      numstat[4][1][4][0] = 516l;
      numstat[4][1][5][0] = 48l;
      numstat[4][2][0][0] = 2802l;
      numstat[4][2][0][1] = 540l;
      numstat[4][2][1][0] = 9132l;
      numstat[4][2][1][1] = 1488l;
      numstat[4][2][2][0] = 11652l;
      numstat[4][2][2][1] = 1824l;
      numstat[4][2][3][0] = 6720l;
      numstat[4][2][3][1] = 744l;
      numstat[4][2][4][0] = 1662l;
      numstat[4][2][5][0] = 132l;
      numstat[4][3][0][0] = 7064l;
      numstat[4][3][0][1] = 1088l;
      numstat[4][3][1][0] = 20760l;
      numstat[4][3][1][1] = 2376l;
      numstat[4][3][2][0] = 23904l;
      numstat[4][3][2][1] = 2472l;
      numstat[4][3][3][0] = 12120l;
      numstat[4][3][3][1] = 792l;
      numstat[4][3][4][0] = 2496l;
      numstat[4][3][5][0] = 144l;
      numstat[4][4][0][0] = 11742l;
      numstat[4][4][0][1] = 1254l;
      numstat[4][4][1][0] = 29550l;
      numstat[4][4][1][1] = 1920l;
      numstat[4][4][2][0] = 29040l;
      numstat[4][4][2][1] = 1440l;
      numstat[4][4][3][0] = 12000l;
      numstat[4][4][3][1] = 192l;
      numstat[4][4][4][0] = 1806l;
      numstat[4][4][5][0] = 48l;
      numstat[4][5][0][0] = 13512l;
      numstat[4][5][0][1] = 792l;
      numstat[4][5][1][0] = 27360l;
      numstat[4][5][1][1] = 744l;
      numstat[4][5][2][0] = 21576l;
      numstat[4][5][2][1] = 360l;
      numstat[4][5][3][0] = 6720l;
      numstat[4][5][4][0] = 672l;
      numstat[4][6][0][0] = 11004l;
      numstat[4][6][0][1] = 216l;
      numstat[4][6][1][0] = 16536l;
      numstat[4][6][1][1] = 120l;
      numstat[4][6][2][0] = 9804l;
      numstat[4][6][2][1] = 48l;
      numstat[4][6][3][0] = 2096l;
      numstat[4][6][4][0] = 132l;
      numstat[4][7][0][0] = 6384l;
      numstat[4][7][1][0] = 6336l;
      numstat[4][7][2][0] = 2640l;
      numstat[4][7][3][0] = 288l;
      numstat[4][8][0][0] = 2634l;
      numstat[4][8][1][0] = 1416l;
      numstat[4][8][2][0] = 384l;
      numstat[4][9][0][0] = 772l;
      numstat[4][9][1][0] = 144l;
      numstat[4][9][2][0] = 24l;
      numstat[4][10][0][0] = 162l;
      numstat[4][11][0][0] = 24l;
      numstat[4][12][0][0] = 2l;
      numstat[5][0][1][0] = 120l;
      numstat[5][0][2][0] = 96l;
      numstat[5][0][3][0] = 24l;
      numstat[5][1][0][0] = 432l;
      numstat[5][1][1][0] = 888l;
      numstat[5][1][2][0] = 696l;
      numstat[5][1][3][0] = 168l;
      numstat[5][2][0][0] = 1464l;
      numstat[5][2][1][0] = 2712l;
      numstat[5][2][2][0] = 1944l;
      numstat[5][2][3][0] = 408l;
      numstat[5][3][0][0] = 2856l;
      numstat[5][3][1][0] = 4440l;
      numstat[5][3][2][0] = 2640l;
      numstat[5][3][3][0] = 384l;
      numstat[5][4][0][0] = 3528l;
      numstat[5][4][1][0] = 4224l;
      numstat[5][4][2][0] = 1824l;
      numstat[5][4][3][0] = 96l;
      numstat[5][5][0][0] = 2856l;
      numstat[5][5][1][0] = 2352l;
      numstat[5][5][2][0] = 648l;
      numstat[5][6][0][0] = 1512l;
      numstat[5][6][1][0] = 720l;
      numstat[5][6][2][0] = 120l;
      numstat[5][7][0][0] = 504l;
      numstat[5][7][1][0] = 96l;
      numstat[5][8][0][0] = 96l;
      numstat[5][9][0][0] = 8l;
      numstat[6][0][1][0] = 24l;
      numstat[6][0][2][0] = 12l;
      numstat[6][1][0][0] = 156l;
      numstat[6][1][1][0] = 120l;
      numstat[6][1][2][0] = 60l;
      numstat[6][2][0][0] = 360l;
      numstat[6][2][1][0] = 216l;
      numstat[6][2][2][0] = 96l;
      numstat[6][3][0][0] = 440l;
      numstat[6][3][1][0] = 168l;
      numstat[6][3][2][0] = 48l;
      numstat[6][4][0][0] = 300l;
      numstat[6][4][1][0] = 48l;
      numstat[6][5][0][0] = 108l;
      numstat[6][6][0][0] = 16l;
      numstat[7][1][0][0] = 24l;
      numstat[7][2][0][0] = 24l;
      numstat[7][3][0][0] = 8l;
}
  1. define NUM_PARETO 367 // 367 distinct interesting (a,b,c,d) stats; we eliminate stats that start with 1, or have at most one non-zero

int a[NUM_PARETO], b[NUM_PARETO], c[NUM_PARETO], d[NUM_PARETO]; // the (a,b,c,d) stats, ordered by numstat

  1. define NUM_ACD 49 // number of interesting possible acd statistics for 3D Moser sets

int a_base[NUM_ACD], c_base[NUM_ACD], d_base[NUM_ACD];

void init_pareto(void) // this was precomputed

{
 int i=0;

a[i] = 4; b[i] = 12; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 0; c[i] = 5; d[i] = 0; i++; a[i] = 0; b[i] = 6; c[i] = 6; d[i] = 0; i++; a[i] = 0; b[i] = 9; c[i] = 3; d[i] = 0; i++; a[i] = 0; b[i] = 0; c[i] = 3; d[i] = 1; i++; a[i] = 3; b[i] = 12; c[i] = 0; d[i] = 0; i++; a[i] = 5; b[i] = 9; c[i] = 0; d[i] = 0; i++; a[i] = 7; b[i] = 3; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 0; c[i] = 2; d[i] = 1; i++; a[i] = 6; b[i] = 0; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 0; c[i] = 6; d[i] = 0; i++; a[i] = 2; b[i] = 12; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 0; c[i] = 0; d[i] = 1; i++; a[i] = 6; b[i] = 6; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 10; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 0; c[i] = 0; d[i] = 1; i++; a[i] = 4; b[i] = 9; c[i] = 2; d[i] = 0; i++; a[i] = 4; b[i] = 11; c[i] = 0; d[i] = 0; i++; a[i] = 5; b[i] = 0; c[i] = 3; d[i] = 0; i++; a[i] = 6; b[i] = 0; c[i] = 1; d[i] = 0; i++; a[i] = 7; b[i] = 1; c[i] = 0; d[i] = 0; i++; a[i] = 7; b[i] = 2; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 9; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 0; c[i] = 0; d[i] = 1; i++; a[i] = 4; b[i] = 0; c[i] = 3; d[i] = 1; i++; a[i] = 0; b[i] = 5; c[i] = 6; d[i] = 0; i++; a[i] = 0; b[i] = 9; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 0; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 6; c[i] = 2; d[i] = 1; i++; a[i] = 6; b[i] = 3; c[i] = 2; d[i] = 0; i++; a[i] = 6; b[i] = 4; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 2; c[i] = 6; d[i] = 0; i++; a[i] = 4; b[i] = 0; c[i] = 1; d[i] = 1; i++; a[i] = 0; b[i] = 2; c[i] = 0; d[i] = 1; i++; a[i] = 4; b[i] = 0; c[i] = 4; d[i] = 0; i++; a[i] = 6; b[i] = 1; c[i] = 2; d[i] = 0; i++; a[i] = 0; b[i] = 6; c[i] = 0; d[i] = 1; i++; a[i] = 0; b[i] = 6; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 0; c[i] = 2; d[i] = 1; i++; a[i] = 2; b[i] = 6; c[i] = 6; d[i] = 0; i++; a[i] = 0; b[i] = 8; c[i] = 3; d[i] = 0; i++; a[i] = 5; b[i] = 0; c[i] = 2; d[i] = 0; i++; a[i] = 5; b[i] = 4; c[i] = 3; d[i] = 0; i++; a[i] = 5; b[i] = 7; c[i] = 1; d[i] = 0; i++; a[i] = 5; b[i] = 8; c[i] = 0; d[i] = 0; i++; a[i] = 6; b[i] = 2; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 9; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 0; c[i] = 3; d[i] = 1; i++; a[i] = 0; b[i] = 4; c[i] = 6; d[i] = 0; i++; a[i] = 0; b[i] = 6; c[i] = 5; d[i] = 0; i++; a[i] = 0; b[i] = 7; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 0; c[i] = 5; d[i] = 0; i++; a[i] = 6; b[i] = 5; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 6; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 3; d[i] = 1; i++; a[i] = 3; b[i] = 11; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 6; c[i] = 1; d[i] = 1; i++; a[i] = 5; b[i] = 0; c[i] = 1; d[i] = 0; i++; a[i] = 5; b[i] = 6; c[i] = 2; d[i] = 0; i++; a[i] = 6; b[i] = 1; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 0; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 2; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 6; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 0; c[i] = 3; d[i] = 1; i++; a[i] = 3; b[i] = 0; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 3; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 9; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 0; d[i] = 1; i++; a[i] = 2; b[i] = 0; c[i] = 1; d[i] = 0; i++; a[i] = 6; b[i] = 1; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 0; d[i] = 1; i++; a[i] = 4; b[i] = 10; c[i] = 0; d[i] = 0; i++; a[i] = 5; b[i] = 1; c[i] = 3; d[i] = 0; i++; a[i] = 6; b[i] = 3; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 1; c[i] = 6; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 0; d[i] = 1; i++; a[i] = 3; b[i] = 10; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 3; d[i] = 1; i++; a[i] = 2; b[i] = 11; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 0; c[i] = 3; d[i] = 0; i++; a[i] = 0; b[i] = 9; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 6; c[i] = 1; d[i] = 1; i++; a[i] = 0; b[i] = 6; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 0; c[i] = 2; d[i] = 1; i++; a[i] = 4; b[i] = 6; c[i] = 0; d[i] = 1; i++; a[i] = 6; b[i] = 2; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 4; c[i] = 0; d[i] = 1; i++; a[i] = 2; b[i] = 0; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 0; c[i] = 4; d[i] = 0; i++; a[i] = 4; b[i] = 0; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 0; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 3; d[i] = 1; i++; a[i] = 2; b[i] = 1; c[i] = 0; d[i] = 1; i++; a[i] = 4; b[i] = 7; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 0; c[i] = 4; d[i] = 0; i++; a[i] = 6; b[i] = 4; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 9; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 1; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 2; c[i] = 5; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 0; d[i] = 1; i++; a[i] = 4; b[i] = 0; c[i] = 2; d[i] = 0; i++; a[i] = 0; b[i] = 2; c[i] = 1; d[i] = 1; i++; a[i] = 2; b[i] = 0; c[i] = 2; d[i] = 0; i++; a[i] = 4; b[i] = 5; c[i] = 2; d[i] = 1; i++; a[i] = 6; b[i] = 2; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 2; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 3; d[i] = 1; i++; a[i] = 2; b[i] = 10; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 8; c[i] = 2; d[i] = 0; i++; a[i] = 5; b[i] = 3; c[i] = 3; d[i] = 0; i++; a[i] = 5; b[i] = 2; c[i] = 3; d[i] = 0; i++; a[i] = 0; b[i] = 2; c[i] = 3; d[i] = 1; i++; a[i] = 3; b[i] = 7; c[i] = 4; d[i] = 0; i++; a[i] = 5; b[i] = 1; c[i] = 0; d[i] = 0; i++; a[i] = 2; b[i] = 0; c[i] = 3; d[i] = 0; i++; a[i] = 6; b[i] = 3; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 1; d[i] = 1; i++; a[i] = 0; b[i] = 8; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 8; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 0; c[i] = 3; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 5; d[i] = 0; i++; a[i] = 3; b[i] = 0; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 5; d[i] = 0; i++; a[i] = 5; b[i] = 7; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 6; d[i] = 0; i++; a[i] = 4; b[i] = 2; c[i] = 0; d[i] = 1; i++; a[i] = 3; b[i] = 1; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 2; d[i] = 1; i++; a[i] = 5; b[i] = 5; c[i] = 2; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 2; c[i] = 2; d[i] = 1; i++; a[i] = 4; b[i] = 5; c[i] = 4; d[i] = 0; i++; a[i] = 5; b[i] = 1; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 9; c[i] = 2; d[i] = 0; i++; a[i] = 5; b[i] = 6; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 2; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 5; c[i] = 1; d[i] = 1; i++; a[i] = 2; b[i] = 2; c[i] = 6; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 5; d[i] = 0; i++; a[i] = 0; b[i] = 7; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 9; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 3; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 5; c[i] = 0; d[i] = 1; i++; a[i] = 0; b[i] = 6; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 10; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 1; d[i] = 1; i++; a[i] = 0; b[i] = 4; c[i] = 3; d[i] = 1; i++; a[i] = 0; b[i] = 2; c[i] = 4; d[i] = 0; i++; a[i] = 0; b[i] = 8; c[i] = 1; d[i] = 0; i++; a[i] = 5; b[i] = 1; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 4; c[i] = 5; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 3; d[i] = 1; i++; a[i] = 3; b[i] = 6; c[i] = 0; d[i] = 1; i++; a[i] = 0; b[i] = 2; c[i] = 2; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 6; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 1; c[i] = 3; d[i] = 1; i++; a[i] = 3; b[i] = 5; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 3; c[i] = 0; d[i] = 1; i++; a[i] = 2; b[i] = 6; c[i] = 0; d[i] = 1; i++; a[i] = 0; b[i] = 4; c[i] = 1; d[i] = 1; i++; a[i] = 2; b[i] = 10; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 2; c[i] = 3; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 1; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 0; d[i] = 1; i++; a[i] = 2; b[i] = 4; c[i] = 6; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 5; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 0; d[i] = 1; i++; a[i] = 2; b[i] = 8; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 7; c[i] = 4; d[i] = 0; i++; a[i] = 4; b[i] = 8; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 2; d[i] = 1; i++; a[i] = 2; b[i] = 3; c[i] = 6; d[i] = 0; i++; a[i] = 3; b[i] = 2; c[i] = 0; d[i] = 1; i++; a[i] = 5; b[i] = 2; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 2; c[i] = 1; d[i] = 1; i++; a[i] = 2; b[i] = 1; c[i] = 1; d[i] = 1; i++; a[i] = 5; b[i] = 6; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 5; c[i] = 5; d[i] = 0; i++; a[i] = 2; b[i] = 1; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 2; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 4; c[i] = 2; d[i] = 1; i++; a[i] = 2; b[i] = 1; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 2; c[i] = 2; d[i] = 1; i++; a[i] = 5; b[i] = 4; c[i] = 2; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 3; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 1; d[i] = 1; i++; a[i] = 0; b[i] = 7; c[i] = 2; d[i] = 0; i++; a[i] = 5; b[i] = 2; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 2; c[i] = 5; d[i] = 0; i++; a[i] = 0; b[i] = 7; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 6; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 9; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 2; d[i] = 1; i++; a[i] = 0; b[i] = 5; c[i] = 4; d[i] = 0; i++; a[i] = 4; b[i] = 1; c[i] = 1; d[i] = 0; i++; a[i] = 5; b[i] = 5; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 3; c[i] = 1; d[i] = 1; i++; a[i] = 0; b[i] = 4; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 3; c[i] = 2; d[i] = 1; i++; a[i] = 4; b[i] = 3; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 4; d[i] = 0; i++; a[i] = 4; b[i] = 8; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 7; c[i] = 2; d[i] = 0; i++; a[i] = 5; b[i] = 3; c[i] = 2; d[i] = 0; i++; a[i] = 0; b[i] = 6; c[i] = 3; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 2; d[i] = 0; i++; a[i] = 5; b[i] = 2; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 1; c[i] = 2; d[i] = 1; i++; a[i] = 4; b[i] = 2; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 1; d[i] = 0; i++; a[i] = 5; b[i] = 3; c[i] = 0; d[i] = 0; i++; a[i] = 5; b[i] = 5; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 2; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 4; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 5; c[i] = 0; d[i] = 1; i++; a[i] = 4; b[i] = 1; c[i] = 2; d[i] = 0; i++; a[i] = 0; b[i] = 6; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 3; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 9; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 0; d[i] = 1; i++; a[i] = 3; b[i] = 3; c[i] = 0; d[i] = 1; i++; a[i] = 2; b[i] = 1; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 1; d[i] = 1; i++; a[i] = 5; b[i] = 4; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 5; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 0; d[i] = 1; i++; a[i] = 2; b[i] = 9; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 3; c[i] = 5; d[i] = 0; i++; a[i] = 3; b[i] = 2; c[i] = 3; d[i] = 1; i++; a[i] = 3; b[i] = 8; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 3; d[i] = 1; i++; a[i] = 2; b[i] = 1; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 9; c[i] = 0; d[i] = 0; i++; a[i] = 5; b[i] = 4; c[i] = 1; d[i] = 0; i++; a[i] = 0; b[i] = 6; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 0; d[i] = 1; i++; a[i] = 5; b[i] = 3; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 0; d[i] = 1; i++; a[i] = 0; b[i] = 4; c[i] = 2; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 3; d[i] = 1; i++; a[i] = 2; b[i] = 1; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 7; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 3; d[i] = 0; i++; a[i] = 0; b[i] = 4; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 1; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 5; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 0; d[i] = 0; i++; a[i] = 0; b[i] = 5; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 5; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 2; c[i] = 1; d[i] = 1; i++; a[i] = 3; b[i] = 3; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 7; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 7; c[i] = 0; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 5; d[i] = 0; i++; a[i] = 4; b[i] = 2; c[i] = 3; d[i] = 0; i++; a[i] = 4; b[i] = 5; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 3; d[i] = 1; i++; a[i] = 2; b[i] = 2; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 3; c[i] = 0; d[i] = 0; i++; a[i] = 2; b[i] = 8; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 5; c[i] = 1; d[i] = 1; i++; a[i] = 3; b[i] = 2; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 3; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 8; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 2; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 6; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 8; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 2; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 8; c[i] = 1; d[i] = 0; i++; a[i] = 4; b[i] = 6; c[i] = 0; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 5; d[i] = 0; i++; a[i] = 2; b[i] = 7; c[i] = 3; d[i] = 0; i++; a[i] = 4; b[i] = 2; c[i] = 2; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 0; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 2; d[i] = 1; i++; a[i] = 2; b[i] = 4; c[i] = 3; d[i] = 1; i++; a[i] = 4; b[i] = 3; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 5; d[i] = 0; i++; a[i] = 3; b[i] = 3; c[i] = 1; d[i] = 1; i++; a[i] = 3; b[i] = 2; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 3; d[i] = 1; i++; a[i] = 2; b[i] = 5; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 5; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 1; d[i] = 1; i++; a[i] = 3; b[i] = 4; c[i] = 2; d[i] = 1; i++; a[i] = 3; b[i] = 5; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 2; d[i] = 1; i++; a[i] = 2; b[i] = 2; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 8; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 3; c[i] = 2; d[i] = 1; i++; a[i] = 2; b[i] = 3; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 6; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 7; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 7; c[i] = 0; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 7; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 0; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 2; d[i] = 0; i++; a[i] = 4; b[i] = 3; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 1; d[i] = 1; i++; a[i] = 4; b[i] = 5; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 3; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 2; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 5; c[i] = 0; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 0; d[i] = 0; i++; a[i] = 4; b[i] = 3; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 2; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 2; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 2; d[i] = 1; i++; a[i] = 4; b[i] = 5; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 2; d[i] = 1; i++; a[i] = 4; b[i] = 4; c[i] = 2; d[i] = 0; i++; a[i] = 4; b[i] = 4; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 7; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 7; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 3; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 4; d[i] = 0; i++; a[i] = 2; b[i] = 7; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 4; d[i] = 0; i++; a[i] = 3; b[i] = 3; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 5; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 6; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 3; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 3; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 1; d[i] = 0; i++; a[i] = 3; b[i] = 5; c[i] = 1; d[i] = 0; i++; a[i] = 2; b[i] = 6; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 3; d[i] = 0; i++; a[i] = 3; b[i] = 5; c[i] = 2; d[i] = 0; i++; a[i] = 3; b[i] = 4; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 3; d[i] = 0; i++; a[i] = 2; b[i] = 4; c[i] = 2; d[i] = 0; i++; a[i] = 2; b[i] = 5; c[i] = 2; d[i] = 0; i++;


 i=0;
 a_base[i] = 2; c_base[i] = 0; d_base[i] = 0; i++;
 a_base[i] = 3; c_base[i] = 0; d_base[i] = 0; i++;
 a_base[i] = 4; c_base[i] = 0; d_base[i] = 0; i++;
 a_base[i] = 5; c_base[i] = 0; d_base[i] = 0; i++;
 a_base[i] = 6; c_base[i] = 0; d_base[i] = 0; i++;
 a_base[i] = 7; c_base[i] = 0; d_base[i] = 0; i++;
 a_base[i] = 0; c_base[i] = 1; d_base[i] = 0; i++;
 a_base[i] = 2; c_base[i] = 1; d_base[i] = 0; i++;
 a_base[i] = 3; c_base[i] = 1; d_base[i] = 0; i++;
 a_base[i] = 4; c_base[i] = 1; d_base[i] = 0; i++;
 a_base[i] = 5; c_base[i] = 1; d_base[i] = 0; i++;
 a_base[i] = 6; c_base[i] = 1; d_base[i] = 0; i++;
 a_base[i] = 0; c_base[i] = 2; d_base[i] = 0; i++;
 a_base[i] = 2; c_base[i] = 2; d_base[i] = 0; i++;
 a_base[i] = 3; c_base[i] = 2; d_base[i] = 0; i++;
 a_base[i] = 4; c_base[i] = 2; d_base[i] = 0; i++;
 a_base[i] = 5; c_base[i] = 2; d_base[i] = 0; i++;
 a_base[i] = 6; c_base[i] = 2; d_base[i] = 0; i++;
 a_base[i] = 0; c_base[i] = 3; d_base[i] = 0; i++;
 a_base[i] = 2; c_base[i] = 3; d_base[i] = 0; i++;
 a_base[i] = 3; c_base[i] = 3; d_base[i] = 0; i++;
 a_base[i] = 4; c_base[i] = 3; d_base[i] = 0; i++;
 a_base[i] = 5; c_base[i] = 3; d_base[i] = 0; i++;
 a_base[i] = 0; c_base[i] = 4; d_base[i] = 0; i++;
 a_base[i] = 2; c_base[i] = 4; d_base[i] = 0; i++;
 a_base[i] = 3; c_base[i] = 4; d_base[i] = 0; i++;
 a_base[i] = 4; c_base[i] = 4; d_base[i] = 0; i++;
 a_base[i] = 0; c_base[i] = 5; d_base[i] = 0; i++;
 a_base[i] = 2; c_base[i] = 5; d_base[i] = 0; i++;
 a_base[i] = 3; c_base[i] = 5; d_base[i] = 0; i++;
 a_base[i] = 4; c_base[i] = 5; d_base[i] = 0; i++;
 a_base[i] = 0; c_base[i] = 6; d_base[i] = 0; i++;
 a_base[i] = 2; c_base[i] = 6; d_base[i] = 0; i++;
 a_base[i] = 0; c_base[i] = 0; d_base[i] = 1; i++;
 a_base[i] = 2; c_base[i] = 0; d_base[i] = 1; i++;
 a_base[i] = 3; c_base[i] = 0; d_base[i] = 1; i++;
 a_base[i] = 4; c_base[i] = 0; d_base[i] = 1; i++;
 a_base[i] = 0; c_base[i] = 1; d_base[i] = 1; i++;
 a_base[i] = 2; c_base[i] = 1; d_base[i] = 1; i++;
 a_base[i] = 3; c_base[i] = 1; d_base[i] = 1; i++;
 a_base[i] = 4; c_base[i] = 1; d_base[i] = 1; i++;
 a_base[i] = 0; c_base[i] = 2; d_base[i] = 1; i++;
 a_base[i] = 2; c_base[i] = 2; d_base[i] = 1; i++;
 a_base[i] = 3; c_base[i] = 2; d_base[i] = 1; i++;
 a_base[i] = 4; c_base[i] = 2; d_base[i] = 1; i++;
 a_base[i] = 0; c_base[i] = 3; d_base[i] = 1; i++;
 a_base[i] = 2; c_base[i] = 3; d_base[i] = 1; i++;
 a_base[i] = 3; c_base[i] = 3; d_base[i] = 1; i++;
 a_base[i] = 4; c_base[i] = 3; d_base[i] = 1; i++;
}


void init_data(void) {

int i,j,k;

long NUM_SETS_3D = 1;

   for (i=0; i<27; i++) NUM_SETS_3D *= 2;

// allocate space

init_numstat(); // load statistics

   init_pareto();        // load pareto counts

int aa, bb, cc, dd;

for (aa=0; aa<9; aa++) for (bb=0; bb<13; bb++) for (cc=0; cc<7; cc++) for (dd=0; dd<2; dd++) if (numstat[aa][bb][cc][dd] > 0) { data[aa][bb][cc][dd] = malloc(numstat[aa][bb][cc][dd]*sizeof(long)); }


   /* enumerate the 230 line-free sets in [3]^2 by brute force */
   int moser_2d[512];

int lincount=0;

   for (i=0; i < 512; i++)
    {
     moser_2d[i] = 0;

if ((i & 7) == 7) continue; if ((i & 56) == 56) continue; if ((i & 73) == 73) continue; if ((i & 84) == 84) continue; if ((i & 146) == 146) continue; if ((i & 273) == 273) continue; if ((i & 292) == 292) continue; if ((i & 448) == 448) continue; moser_2d[i] = 1; lincount++; }

printf("Number of 2D Moser sets: %d\n", lincount);

   /* Now enumerate all line-free sets in [3]^3 by brute force. */
   long set, tmpset;

long slice1, slice2, slice3; int s[4]; long temp_numstat[9][13][7][2]; long num_linefree=0;

/* Initialise temp_numstat */ for (aa=0; aa<9; aa++) for (bb=0; bb<13; bb++) for (cc=0; cc<7; cc++) for (dd=0; dd<2; dd++) temp_numstat[aa][bb][cc][dd]=0;

   printf("Computing 3D Moser sets...\n");

for (slice1 = 0; slice1 < 512; slice1++) if (moser_2d[slice1]) for (slice2 = 0; slice2 < 512; slice2++) if (moser_2d[slice2]) for (slice3 = 0; slice3 < 512; slice3++) if (moser_2d[slice3]) { set = slice1 | (slice2 << 9) | (slice3 << 18);

if ((set & line_bitmasks[0]) == line_bitmasks[0]) continue; if ((set & line_bitmasks[1]) == line_bitmasks[1]) continue; if ((set & line_bitmasks[2]) == line_bitmasks[2]) continue; if ((set & line_bitmasks[3]) == line_bitmasks[3]) continue; if ((set & line_bitmasks[4]) == line_bitmasks[4]) continue; if ((set & line_bitmasks[5]) == line_bitmasks[5]) continue; if ((set & line_bitmasks[6]) == line_bitmasks[6]) continue; if ((set & line_bitmasks[7]) == line_bitmasks[7]) continue; if ((set & line_bitmasks[8]) == line_bitmasks[8]) continue; if ((set & line_bitmasks[9]) == line_bitmasks[9]) continue; if ((set & line_bitmasks[10]) == line_bitmasks[10]) continue; if ((set & line_bitmasks[11]) == line_bitmasks[11]) continue; if ((set & line_bitmasks[12]) == line_bitmasks[12]) continue; if ((set & line_bitmasks[13]) == line_bitmasks[13]) continue; if ((set & line_bitmasks[14]) == line_bitmasks[14]) continue; if ((set & line_bitmasks[15]) == line_bitmasks[15]) continue; if ((set & line_bitmasks[16]) == line_bitmasks[16]) continue; if ((set & line_bitmasks[17]) == line_bitmasks[17]) continue; if ((set & line_bitmasks[18]) == line_bitmasks[18]) continue; if ((set & line_bitmasks[19]) == line_bitmasks[19]) continue; if ((set & line_bitmasks[20]) == line_bitmasks[20]) continue; if ((set & line_bitmasks[21]) == line_bitmasks[21]) continue; if ((set & line_bitmasks[22]) == line_bitmasks[22]) continue; if ((set & line_bitmasks[23]) == line_bitmasks[23]) continue; if ((set & line_bitmasks[24]) == line_bitmasks[24]) continue;

/* now compute the a,b,c,d stats */ s[0]=s[1]=s[2]=s[3]=0; tmpset = set; for (j=0; j < 27; j++) { if (tmpset & 1l) s[stat[j]]++; tmpset /= 2; }

/* We can ignore those stats with a leading 1, or with only one non-zero */ if (s[0] == 1) continue; if (s[0] == 0 && s[1] == 1) continue; if (s[0] == 0 && s[1] == 0 && s[2] == 1) continue; if ( (s[0] > 0) + (s[1] > 0) + (s[2] > 0) + (s[3] > 0) <= 1) continue;

      		data[s[0]][s[1]][s[2]][s[3]][temp_numstat[s[0]][s[1]][s[2]][s[3]]] = set;

temp_numstat[s[0]][s[1]][s[2]][s[3]]++; num_linefree++; // if (num_linefree % 10000 == 0) printf("*"); }

printf("Number of 3D Moser sets: %ld\n", num_linefree); // checksum for (aa=0; aa<9; aa++) for (bb=0; bb<13; bb++) for (cc=0; cc<7; cc++) for (dd=0; dd<2; dd++) if (numstat[aa][bb][cc][dd] != temp_numstat[aa][bb][cc][dd]) printf("Inconsistency at %d %d %d %d!  %ld != %ld\n", aa,bb,cc,dd,numstat[aa][bb][cc][dd],temp_numstat[aa][bb][cc][dd]); }


FILE * output;


void test( long forbidden ) // see what statistics are compatible with a forbidden set.

{

int status[NUM_PARETO]; // 0 for impossible, 1 for possible, 2 for undecided

int i,j,k,num; long *search; int hit; int numoptimal=0;

// printf("testing %lo...\n", forbidden);

// compute stats of forbidden long tmp = forbidden; int s[4]; s[0]=s[1]=s[2]=s[3]=0;

 	 for (j=0; j < 27; j++)

{ if (tmp & 1l) s[stat[j]]++; tmp /= 2; }

// printf("stats %d %d %d %d \n", s[0], s[1], s[2], s[3]);

// stats that are larger than what is not forbidden are, of course impossible; all others are initially unknown for (i = 0; i < NUM_PARETO; i++) if ((a[i] <= 8-s[0]) && (b[i] <= 12-s[1]) && (c[i] <= 6-s[2]) && (d[i] <= 1-s[3])) status[i] = 2; else status[i] = 0;

for (i=0; i<NUM_PARETO; i++) if (status[i] == 2) { hit = 0; num = numstat[a[i]][b[i]][c[i]][d[i]]; search = data[a[i]][b[i]][c[i]][d[i]]; for (j=0; j < num; j++) if (!(search[j] & forbidden)) { hit=1; // printf("%d %d %d %d: %lo=%ld (%d of %ld) = %lo\n", a[i], b[i], c[i], d[i], search[j], search[j],j, num, search[j] & forbidden); break; } if (hit) // assign 1 to all stats equal to or smaller than i { for (k=0; k<NUM_PARETO;k++) if (a[k] <= a[i] && b[k] <= b[i] && c[k] <= c[i] && d[k] <= d[i]) if (status[k]==0) printf("Err1!"); else status[k] = 1; } else // assign 0 to all stats equal to or larger than i { // printf("%d %d %d %d empty\n", a[i], b[i], c[i], d[i]); for (k=0; k<NUM_PARETO;k++) if (a[k] >= a[i] && b[k] >= b[i] && c[k] >= c[i] && d[k] >= d[i]) if (status[k]==1) printf("Err0!"); else status[k] = 0; } }


int best;

for (i=0; i < NUM_ACD; i++)

     {

best=-1; for (k=0; k<NUM_PARETO; k++) if (a[k] == a_base[i] && c[k] == c_base[i] && d[k] == d_base[i] && b[k] > best && status[k]==1) best = b[k]; fprintf(output,"%c",(char) best); // printf("%d ", best); } // printf("\n"); }


int perms[48][27]; // The 48 symmetries of the cube long pow2[27]; // The 27 powers of 2

void buildperms(void) {

  int i,j,k,p,x,y,z,u,v,w;
  int n=0;
  long power=1;
  for (i=0; i<27; i++) { pow2[i] = power; power *= 2; }
  for (x=0;x<2;x++)

for (y=0;y<2;y++) for (z=0;z<2;z++) for (p=0;p<6;p++) {  ; for (i=0;i<3;i++) for (j=0;j<3;j++) for (k=0;k<3;k++) { switch (p) { case 0: u=i; v=j; w=k; break; case 1: u=i; v=k; w=j; break; case 2: u=j; v=i; w=k; break; case 3: u=j; v=k; w=i; break; case 4: u=k; v=j; w=i; break; case 5: u=k; v=i; w=j; break; } if (x) u = 2-u; if (y) v = 2-v; if (z) w = 2-w; perms[n][i+3*j+9*k] = u+3*v+9*w; } n++; } }


long minsym(long set) // gives the permutation of set of minimal size

{

long best = set, in, out; int i,j;

for (i=0; i < 48; i++) { in = set; out = 0; for (j=0; j < 27; j++) { if (in & 1) out |= pow2[perms[i][j]]; in >>= 1; } if (out < best) best = out;

         }

return best;

}


int crush[4096]; // maps the label of a b-word to the label of its minimal permutation

const int bc[12] = { 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25 }; // the b points in [3]^3 const int ac[14] = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26 }; // the ac points in [3]^3

void buildhash(void) {


  int i,j,k,count=0;
  long l,m;
  printf("Building hash...\n");
  for (i = 0; i<4096;i++)

{ j=i; l=0; for (k=0;k<12;k++) { if (j & 1) l |= pow2[bc[k]]; j >>=1; } // l is now the b-word associated to i m = minsym(l); j=0; for (k=0;k<12;k++) if (m & pow2[bc[k]]) j |= pow2[k]; // j is now the label of the reduction of l

crush[i]=j;

if (i == crush[i]) { printf("%d ", i); count++; }

}

 printf("Total mins: %d\n", count);

}

int main() {

  int i,j,k,l,m;
  long forb, forb_base;
  output = fopen("lookup.dat", "wb");

// srand ( time(NULL) );

  buildperms();
  buildhash();


  init_data();

// test(0); // test(1);

// return;

  for(i=0; i<4096; i++)
    if (i == crush[i])

{ forb_base = 0; l = i; for (k=0;k<12;k++) { if (l & 1) forb_base |= pow2[bc[k]]; l >>=1; } // printf("\n Testing row %d \n", i); for (j=0; j<16384; j++) { forb = forb_base; l=j; for (k=0;k<14;k++) { if (l & 1) forb |= pow2[ac[k]]; l >>=1; } // forb is now a min-random set with no 222 test(forb); } printf("Stage %d complete.\n", i); }

 fclose(output);

}