#include <stdio.h>
#include <time.h>

#ifndef RJ
//#define RJ                   // Uncheck for debugging
#endif

int q,                       // Number of unsolved Cell positions Board wise
    r[81],                   // Used for sorting and eliminating unsolved Cell positions
    s[81],                   // Sudoku solved 81 Cell positions Board wise
    g[81],                   // Bitwise Candidates for each unsolved Cell positions Board wise
    n[3];                    // Number of Naked Singles, Hidden Singles and Guesses Board wise

static int b[512] = {        // Bitwise Candidates
          0,        1,        2,       12,        3,       13,       23,      123,
          4,       14,       24,      124,       34,      134,      234,     1234,
          5,       15,       25,      125,       35,      135,      235,     1235,
         45,      145,      245,     1245,      345,     1345,     2345,    12345,
          6,       16,       26,      126,       36,      136,      236,     1236,
         46,      146,      246,     1246,      346,     1346,     2346,    12346,
         56,      156,      256,     1256,      356,     1356,     2356,    12356,
        456,     1456,     2456,    12456,     3456,    13456,    23456,   123456,
          7,       17,       27,      127,       37,      137,      237,     1237,
         47,      147,      247,     1247,      347,     1347,     2347,    12347,
         57,      157,      257,     1257,      357,     1357,     2357,    12357,
        457,     1457,     2457,    12457,     3457,    13457,    23457,   123457,
         67,      167,      267,     1267,      367,     1367,     2367,    12367,
        467,     1467,     2467,    12467,     3467,    13467,    23467,   123467,
        567,     1567,     2567,    12567,     3567,    13567,    23567,   123567,
       4567,    14567,    24567,   124567,    34567,   134567,   234567,  1234567,
          8,       18,       28,      128,       38,      138,      238,     1238,
         48,      148,      248,     1248,      348,     1348,     2348,    12348,
         58,      158,      258,     1258,      358,     1358,     2358,    12358,
        458,     1458,     2458,    12458,     3458,    13458,    23458,   123458,
         68,      168,      268,     1268,      368,     1368,     2368,    12368,
        468,     1468,     2468,    12468,     3468,    13468,    23468,   123468,
        568,     1568,     2568,    12568,     3568,    13568,    23568,   123568,
       4568,    14568,    24568,   124568,    34568,   134568,   234568,  1234568,
         78,      178,      278,     1278,      378,     1378,     2378,    12378,
        478,     1478,     2478,    12478,     3478,    13478,    23478,   123478,
        578,     1578,     2578,    12578,     3578,    13578,    23578,   123578,
       4578,    14578,    24578,   124578,    34578,   134578,   234578,  1234578,
        378,     1678,     2678,    12678,     3678,    13678,    23678,   123678,
       4678,    14678,    24678,   124678,    34678,   134678,   234678,  1234678,
       5678,    15678,    25678,   125678,    35678,   135678,   235678,  1235678,
      45678,   145678,   245678,  1245678,   345678,  1345678,  2345678, 12345678,
          9,       19,       29,      129,       39,      139,      239,     1239,
         49,      149,      249,     1249,      349,     1349,     2349,    12349,
         59,      159,      259,     1259,      359,     1359,     2359,    12359,
        459,     1459,     2459,    12459,     3459,    13459,    23459,   123459,
         69,      169,      269,     1269,      369,     1369,     2369,    12369,
        469,     1469,     2469,    12469,     3469,    13469,    23469,   123469,
        569,     1569,     2569,    12569,     3569,    13569,    23569,   123569,
       4569,    14569,    24569,   124569,    34569,   134569,   234569,  1234569,
         79,      179,      279,     1279,      379,     1379,     2379,    12379,
        479,     1479,     2479,    12479,     3479,    13479,    23479,   123479,
        579,     1579,     2579,    12579,     3579,    13579,    23579,   123579,
       4579,    14579,    24579,   124579,    34579,   134579,   234579,  1234579,
        679,     1679,     2679,    12679,     3679,    13679,    23679,   123679,
       4679,    14679,    24679,   124679,    34679,   134679,   234679,  1234679,
       5679,    15679,    25679,   125679,    35679,   135679,   235679,  1235679,
      45679,   145679,   245679,  1245679,   345679,  1345679,  2345679, 12345679,
         89,      189,      289,     1289,      389,     1389,     2389,    12389,
        489,     1489,     2489,    12489,     3489,    13489,    23489,   123489,
        589,     1589,     2589,    12589,     3589,    13589,    23589,   123589,
       4589,    14589,    24589,   124589,    34589,   134589,   234589,  1234589,
        689,     1689,     2689,    12689,     3689,    13689,    23689,   123689,
       4689,    14689,    24689,   124689,    34689,   134689,   234689,  1234689,
       5689,    15689,    25689,   125689,    35689,   135689,   235689,  1235689,
      45689,   145689,   245689,  1245689,   345689,  1345689,  2345689, 12345689,
        789,     1789,     2789,    12789,     3789,    13789,    23789,   123789,
       4789,    14789,    24789,   124789,    34789,   134789,   234789,  1234789,
       5789,    15789,    25789,   125789,    35789,   135789,   235789,  1235789,
      45789,   145789,   245789,  1245789,   345789,  1345789,  2345789, 12345789,
       6789,    16789,    26789,   126789,    36789,   136789,   236789,  1236789,
      46789,   146789,   246789,  1246789,   346789,  1346789,  2346789, 12346789,
      56789,   156789,   256789,  1256789,   356789,  1356789,  2356789, 12356789,
     456789,  1456789,  2456789, 12456789,  3456789, 13456789, 23456789,123456789},
           B[513] = {        // Bit Count
   0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
   5, 6, 6, 7, 6, 7, 7, 8, 6, 7, 7, 8, 7, 8, 8, 9,10},
           w[81][20] = {     // Affected unsolved 20 Cell positions
  { 3, 4, 5, 6, 7, 8, 1, 2,10,11,19,20, 9,18,27,36,45,54,63,72},
  { 3, 4, 5, 6, 7, 8, 0, 2, 9,11,18,20,10,19,28,37,46,55,64,73},
  { 3, 4, 5, 6, 7, 8, 0, 1, 9,10,18,19,11,20,29,38,47,56,65,74},
  { 0, 1, 2, 6, 7, 8, 4, 5,13,14,22,23,12,21,30,39,48,57,66,75},
  { 0, 1, 2, 6, 7, 8, 3, 5,12,14,21,23,13,22,31,40,49,58,67,76},
  { 0, 1, 2, 6, 7, 8, 3, 4,12,13,21,22,14,23,32,41,50,59,68,77},
  { 0, 1, 2, 3, 4, 5, 7, 8,16,17,25,26,15,24,33,42,51,60,69,78},
  { 0, 1, 2, 3, 4, 5, 6, 8,15,17,24,26,16,25,34,43,52,61,70,79},
  { 0, 1, 2, 3, 4, 5, 6, 7,15,16,24,25,17,26,35,44,53,62,71,80},
  {12,13,14,15,16,17,10,11, 1, 2,19,20, 0,18,27,36,45,54,63,72},
  {12,13,14,15,16,17, 9,11, 0, 2,18,20, 1,19,28,37,46,55,64,73},
  {12,13,14,15,16,17, 9,10, 0, 1,18,19, 2,20,29,38,47,56,65,74},
  { 9,10,11,15,16,17,13,14, 4, 5,22,23, 3,21,30,39,48,57,66,75},
  { 9,10,11,15,16,17,12,14, 3, 5,21,23, 4,22,31,40,49,58,67,76},
  { 9,10,11,15,16,17,12,13, 3, 4,21,22, 5,23,32,41,50,59,68,77},
  { 9,10,11,12,13,14,16,17, 7, 8,25,26, 6,24,33,42,51,60,69,78},
  { 9,10,11,12,13,14,15,17, 6, 8,24,26, 7,25,34,43,52,61,70,79},
  { 9,10,11,12,13,14,15,16, 6, 7,24,25, 8,26,35,44,53,62,71,80},
  {21,22,23,24,25,26,19,20, 1, 2,10,11, 0, 9,27,36,45,54,63,72},
  {21,22,23,24,25,26,18,20, 0, 2, 9,11, 1,10,28,37,46,55,64,73},
  {21,22,23,24,25,26,18,19, 0, 1, 9,10, 2,11,29,38,47,56,65,74},
  {18,19,20,24,25,26,22,23, 4, 5,13,14, 3,12,30,39,48,57,66,75},
  {18,19,20,24,25,26,21,23, 3, 5,12,14, 4,13,31,40,49,58,67,76},
  {18,19,20,24,25,26,21,22, 3, 4,12,13, 5,14,32,41,50,59,68,77},
  {18,19,20,21,22,23,25,26, 7, 8,16,17, 6,15,33,42,51,60,69,78},
  {18,19,20,21,22,23,24,26, 6, 8,15,17, 7,16,34,43,52,61,70,79},
  {18,19,20,21,22,23,24,25, 6, 7,15,16, 8,17,35,44,53,62,71,80},
  {30,31,32,33,34,35,28,29,37,38,46,47,36,45, 0, 9,18,54,63,72},
  {30,31,32,33,34,35,27,29,36,38,45,47,37,46, 1,10,19,55,64,73},
  {30,31,32,33,34,35,27,28,36,37,45,46,38,47, 2,11,20,56,65,74},
  {27,28,29,33,34,35,31,32,40,41,49,50,39,48, 3,12,21,57,66,75},
  {27,28,29,33,34,35,30,32,39,41,48,50,40,49, 4,13,22,58,67,76},
  {27,28,29,33,34,35,30,31,39,40,48,49,41,50, 5,14,23,59,68,77},
  {27,28,29,30,31,32,34,35,43,44,52,53,42,51, 6,15,24,60,69,78},
  {27,28,29,30,31,32,33,35,42,44,51,53,43,52, 7,16,25,61,70,79},
  {27,28,29,30,31,32,33,34,42,43,51,52,44,53, 8,17,26,62,71,80},
  {39,40,41,42,43,44,37,38,28,29,46,47,27,45, 0, 9,18,54,63,72},
  {39,40,41,42,43,44,36,38,27,29,45,47,28,46, 1,10,19,55,64,73},
  {39,40,41,42,43,44,36,37,27,28,45,46,29,47, 2,11,20,56,65,74},
  {36,37,38,42,43,44,40,41,31,32,49,50,30,48, 3,12,21,57,66,75},
  {36,37,38,42,43,44,39,41,30,32,48,50,31,49, 4,13,22,58,67,76},
  {36,37,38,42,43,44,39,40,30,31,48,49,32,50, 5,14,23,59,68,77},
  {36,37,38,39,40,41,43,44,34,35,52,53,33,51, 6,15,24,60,69,78},
  {36,37,38,39,40,41,42,44,33,35,51,53,34,52, 7,16,25,61,70,79},
  {36,37,38,39,40,41,42,43,33,34,51,52,35,53, 8,17,26,62,71,80},
  {48,49,50,51,52,53,46,47,28,29,37,38,27,36, 0, 9,18,54,63,72},
  {48,49,50,51,52,53,45,47,27,29,36,38,28,37, 1,10,19,55,64,73},
  {48,49,50,51,52,53,45,46,27,28,36,37,29,38, 2,11,20,56,65,74},
  {45,46,47,51,52,53,49,50,31,32,40,41,30,39, 3,12,21,57,66,75},
  {45,46,47,51,52,53,48,50,30,32,39,41,31,40, 4,13,22,58,67,76},
  {45,46,47,51,52,53,48,49,30,31,39,40,32,41, 5,14,23,59,68,77},
  {45,46,47,48,49,50,52,53,34,35,43,44,33,42, 6,15,24,60,69,78},
  {45,46,47,48,49,50,51,53,33,35,42,44,34,43, 7,16,25,61,70,79},
  {45,46,47,48,49,50,51,52,33,34,42,43,35,44, 8,17,26,62,71,80},
  {57,58,59,60,61,62,55,56,64,65,73,74,63,72, 0, 9,18,27,36,45},
  {57,58,59,60,61,62,54,56,63,65,72,74,64,73, 1,10,19,28,37,46},
  {57,58,59,60,61,62,54,55,63,64,72,73,65,74, 2,11,20,29,38,47},
  {54,55,56,60,61,62,58,59,67,68,76,77,66,75, 3,12,21,30,39,48},
  {54,55,56,60,61,62,57,59,66,68,75,77,67,76, 4,13,22,31,40,49},
  {54,55,56,60,61,62,57,58,66,67,75,76,68,77, 5,14,23,32,41,50},
  {54,55,56,57,58,59,61,62,70,71,79,80,69,78, 6,15,24,33,42,51},
  {54,55,56,57,58,59,60,62,69,71,78,80,70,79, 7,16,25,34,43,52},
  {54,55,56,57,58,59,60,61,69,70,78,79,71,80, 8,17,26,35,44,53},
  {66,67,68,69,70,71,64,65,55,56,73,74,54,72, 0, 9,18,27,36,45},
  {66,67,68,69,70,71,63,65,54,56,72,74,55,73, 1,10,19,28,37,46},
  {66,67,68,69,70,71,63,64,54,55,72,73,56,74, 2,11,20,29,38,47},
  {63,64,65,69,70,71,67,68,58,59,76,77,57,75, 3,12,21,30,39,48},
  {63,64,65,69,70,71,66,68,57,59,75,77,58,76, 4,13,22,31,40,49},
  {63,64,65,69,70,71,66,67,57,58,75,76,59,77, 5,14,23,32,41,50},
  {63,64,65,66,67,68,70,71,61,62,79,80,60,78, 6,15,24,33,42,51},
  {63,64,65,66,67,68,69,71,60,62,78,80,61,79, 7,16,25,34,43,52},
  {63,64,65,66,67,68,69,70,60,61,78,79,62,80, 8,17,26,35,44,53},
  {75,76,77,78,79,80,73,74,55,56,64,65,54,63, 0, 9,18,27,36,45},
  {75,76,77,78,79,80,72,74,54,56,63,65,55,64, 1,10,19,28,37,46},
  {75,76,77,78,79,80,72,73,54,55,63,64,56,65, 2,11,20,29,38,47},
  {72,73,74,78,79,80,76,77,58,59,67,68,57,66, 3,12,21,30,39,48},
  {72,73,74,78,79,80,75,77,57,59,66,68,58,67, 4,13,22,31,40,49},
  {72,73,74,78,79,80,75,76,57,58,66,67,59,68, 5,14,23,32,41,50},
  {72,73,74,75,76,77,79,80,61,62,70,71,60,69, 6,15,24,33,42,51},
  {72,73,74,75,76,77,78,80,60,62,69,71,61,70, 7,16,25,34,43,52},
  {72,73,74,75,76,77,78,79,60,61,69,70,62,71, 8,17,26,35,44,53}},
           l[27][9] = {      // Unit Cell positions for Naked/Hidden tuples
  { 0, 1, 2, 3, 4, 5, 6, 7, 8}, { 9,10,11,12,13,14,15,16,17}, {18,19,20,21,22,23,24,25,26},
  {27,28,29,30,31,32,33,34,35}, {36,37,38,39,40,41,42,43,44}, {45,46,47,48,49,50,51,52,53},
  {54,55,56,57,58,59,60,61,62}, {63,64,65,66,67,68,69,70,71}, {72,73,74,75,76,77,78,79,80},
  { 0, 9,18,27,36,45,54,63,72}, { 1,10,19,28,37,46,55,64,73}, { 2,11,20,29,38,47,56,65,74},
  { 3,12,21,30,39,48,57,66,75}, { 4,13,22,31,40,49,58,67,76}, { 5,14,23,32,41,50,59,68,77},
  { 6,15,24,33,42,51,60,69,78}, { 7,16,25,34,43,52,61,70,79}, { 8,17,26,35,44,53,62,71,80},
  { 0, 1, 2, 9,10,11,18,19,20}, { 3, 4, 5,12,13,14,21,22,23}, { 6, 7, 8,15,16,17,24,25,26},
  {27,28,29,36,37,38,45,46,47}, {30,31,32,39,40,41,48,49,50}, {33,34,35,42,43,44,51,52,53},
  {54,55,56,63,64,65,72,73,74}, {57,58,59,66,67,68,75,76,77}, {60,61,62,69,70,71,78,79,80}},
           h[246][9] = {     // 36 pairs/84 triplets/126 quads Cell positions first then Unit other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 6, 7, 8, 0, 1, 2, 3, 5}, { 5, 6, 7, 8, 0, 1, 2, 3, 4}},
           j[54][15] = {     // 3 Cell positions Box-Line wise and affected 6 Line + 6 Box Cell positions for Intersection Removals
  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,18,19,20},
  { 3, 4, 5, 0, 1, 2, 6, 7, 8,12,13,14,21,22,23},
  { 6, 7, 8, 0, 1, 2, 3, 4, 5,15,16,17,24,25,26},
  { 9,10,11,12,13,14,15,16,17, 0, 1, 2,18,19,20},
  {12,13,14, 9,10,11,15,16,17, 3, 4, 5,21,22,23},
  {15,16,17, 9,10,11,12,13,14, 6, 7, 8,24,25,26},
  {18,19,20,21,22,23,24,25,26, 0, 1, 2, 9,10,11},
  {21,22,23,18,19,20,24,25,26, 3, 4, 5,12,13,14},
  {24,25,26,18,19,20,21,22,23, 6, 7, 8,15,16,17},
  {27,28,29,30,31,32,33,34,35,36,37,38,45,46,47},
  {30,31,32,27,28,29,33,34,35,39,40,41,48,49,50},
  {33,34,35,27,28,29,30,31,32,42,43,44,51,52,53},
  {36,37,38,39,40,41,42,43,44,27,28,29,45,46,47},
  {39,40,41,36,37,38,42,43,44,30,31,32,48,49,50},
  {42,43,44,36,37,38,39,40,41,33,34,35,51,52,53},
  {45,46,47,48,49,50,51,52,53,27,28,29,36,37,38},
  {48,49,50,45,46,47,51,52,53,30,31,32,39,40,41},
  {51,52,53,45,46,47,48,49,50,33,34,35,42,43,44},
  {54,55,56,57,58,59,60,61,62,63,64,65,72,73,74},
  {57,58,59,54,55,56,60,61,62,66,67,68,75,76,77},
  {60,61,62,54,55,56,57,58,59,69,70,71,78,79,80},
  {63,64,65,66,67,68,69,70,71,54,55,56,72,73,74},
  {66,67,68,63,64,65,69,70,71,57,58,59,75,76,77},
  {69,70,71,63,64,65,66,67,68,60,61,62,78,79,80},
  {72,73,74,75,76,77,78,79,80,54,55,56,63,64,65},
  {75,76,77,72,73,74,78,79,80,57,58,59,66,67,68},
  {78,79,80,72,73,74,75,76,77,60,61,62,69,70,71},
  { 0, 9,18,27,36,45,54,63,72, 1, 2,10,11,19,20},
  {27,36,45, 0, 9,18,54,63,72,28,29,37,38,46,47},
  {54,63,72, 0, 9,18,27,36,45,55,56,64,65,73,74},
  { 1,10,19,28,37,46,55,64,73, 0, 2, 9,11,18,20},
  {28,37,46, 1,10,19,55,64,73,27,29,36,38,45,47},
  {55,64,73, 1,10,19,28,37,46,54,56,63,65,72,74},
  { 2,11,20,29,38,47,56,65,74, 0, 1, 9,10,18,19},
  {29,38,47, 2,11,20,56,65,74,27,28,36,37,45,46},
  {56,65,74, 2,11,20,29,38,47,54,55,63,64,72,73},
  { 3,12,21,30,39,48,57,66,75, 4, 5,13,14,22,23},
  {30,39,48, 3,12,21,57,66,75,31,32,40,41,49,50},
  {57,66,75, 3,12,21,30,39,48,58,59,67,68,76,77},
  { 4,13,22,31,40,49,58,67,76, 3, 5,12,14,21,23},
  {31,40,49, 4,13,22,58,67,76,30,32,39,41,48,50},
  {58,67,76, 4,13,22,31,40,49,57,59,66,68,75,77},
  { 5,14,23,32,41,50,59,68,77, 3, 4,12,13,21,22},
  {32,41,50, 5,14,23,59,68,77,30,31,39,40,48,49},
  {59,68,77, 5,14,23,32,41,50,57,58,66,67,75,76},
  { 6,15,24,33,42,51,60,69,78, 7, 8,16,17,25,26},
  {33,42,51, 6,15,24,60,69,78,34,35,43,44,52,53},
  {60,69,78, 6,15,24,33,42,51,61,62,70,71,79,80},
  { 7,16,25,34,43,52,61,70,79, 6, 8,15,17,24,26},
  {34,43,52, 7,16,25,61,70,79,33,35,42,44,51,53},
  {61,70,79, 7,16,25,34,43,52,60,62,69,71,78,80},
  { 8,17,26,35,44,53,62,71,80, 6, 7,15,16,24,25},
  {35,44,53, 8,17,26,62,71,80,33,34,42,43,51,52},
  {62,71,80, 8,17,26,35,44,53,60,61,69,70,78,79}};

int solve (int p)
{
  int a,
      x,
      y = 0,                 // Represent Naked Single
      z = 512;               // Assign greatest value for first time checking

  for (a = p; a < q; ++a)    // Search Naked/Hidden Single Candidate for each unsolved Cell position
  {
    if (B[z] > B[g[r[a]]])   // Check least Candidates for each unsolved Cell position
      if (B[z = g[r[x = a]]] == 1)
        goto NHSCF;          // Found Naked Single Candidate
    int K = g[r[a]] & (g[r[a]] ^ (g[w[r[a]][0]] | g[w[r[a]][1]] | g[w[r[a]][2]] |
      g[w[r[a]][3]] | g[w[r[a]][4]] | g[w[r[a]][5]] | g[w[r[a]][6]] | g[w[r[a]][7]]));
                             // Assign Hidden Candidates for each unsolved Cell position Row wise
    if (B[K] == 1)           // Check Hidden Single Candidate Row wise
      z = K;                 // Assign Hidden Single Candidate
    else
    {                        // Assign Hidden Candidates for each unsolved Cell position Column wise
      K = g[r[a]] & (g[r[a]] ^ (g[w[r[a]][12]] | g[w[r[a]][13]] | g[w[r[a]][14]] |
        g[w[r[a]][15]] | g[w[r[a]][16]] | g[w[r[a]][17]] | g[w[r[a]][18]] | g[w[r[a]][19]]));
      if (B[K] == 1)         // Check Hidden Single Candidate Column wise
        z = K;               // Assign Hidden Single Candidate
      else
      {                      // Assign Hidden Candidates for each unsolved Cell position Box wise
        K = g[r[a]] & (g[r[a]] ^ (g[w[r[a]][6]] | g[w[r[a]][7]] | g[w[r[a]][8]] |
          g[w[r[a]][9]] | g[w[r[a]][10]] | g[w[r[a]][11]] | g[w[r[a]][12]] | g[w[r[a]][13]]));
        if (B[K] == 1)       // Check Hidden Single Candidate Box wise
          z = K;             // Assign Hidden Single Candidate
        else
          continue;
      }
    }
    x = a;                   // Assign Hidden Single Cell position
    y = 1;                   // Represent Hidden Single
    goto NHSCF;
  }
  for (; y < 27; ++y)        // Search Naked/Hidden Tuples for each Unit
  {
    int X = (g[l[y][0]] ? 1 : 0) + (g[l[y][1]] ? 1 : 0) + (g[l[y][2]] ? 1 : 0) +
      (g[l[y][3]] ? 1 : 0) + (g[l[y][4]] ? 1 : 0) + (g[l[y][5]] ? 1 : 0) +
      (g[l[y][6]] ? 1 : 0) + (g[l[y][7]] ? 1 : 0) + (g[l[y][8]] ? 1 : 0);
                             // Count unsolved Cell positions
    if (X < 4)
      continue;              // Skip Unit for less than 4 unsolved Cell positions
    for (a = 0; a < 36; ++a) // Search Unit 36 pair Cell positions for Naked/Hidden pair
    {
      if (!g[l[y][h[a][0]]] || !g[l[y][h[a][1]]])
      {                      // Skip solved Cell positions
        if (!g[l[y][h[a][0]]])
          a += 7 - h[a][0];
        continue;
      }
      int K[2] = {g[l[y][h[a][0]]] | g[l[y][h[a][1]]], g[l[y][h[a][2]]] |
        g[l[y][h[a][3]]] | g[l[y][h[a][4]]] | g[l[y][h[a][5]]] |
        g[l[y][h[a][6]]] | g[l[y][h[a][7]]] | g[l[y][h[a][8]]]};

      if (B[K[0]] == 2)      // Check Naked pair Candidates in Unit pair Cell positions
      {
        if (K[0] & K[1])     // Check Naked pair Candidates in Unit other Cell positions
        {
          int k[7] = {g[l[y][h[a][2]]], g[l[y][h[a][3]]], g[l[y][h[a][4]]],
            g[l[y][h[a][5]]], g[l[y][h[a][6]]], g[l[y][h[a][7]]], g[l[y][h[a][8]]]};
                             // Backup and remove Naked pair Candidates from Unit other Cell positions
          g[l[y][h[a][2]]] &= ~K[0];
          g[l[y][h[a][3]]] &= ~K[0];
          g[l[y][h[a][4]]] &= ~K[0];
          g[l[y][h[a][5]]] &= ~K[0];
          g[l[y][h[a][6]]] &= ~K[0];
          g[l[y][h[a][7]]] &= ~K[0];
          g[l[y][h[a][8]]] &= ~K[0];
#ifdef RJ
          printf ("%d) Found Naked pair Candidates %d at Unit %d Cells %d %d\n",
            a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]]);
#endif
          if (solve (p))
            return 1;
#ifdef RJ
          printf ("%d) Restore Naked pair Candidates %d at Unit %d Cells %d %d\n",
            a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]]);
#endif
          g[l[y][h[a][2]]] = k[0];
          g[l[y][h[a][3]]] = k[1];
          g[l[y][h[a][4]]] = k[2];
          g[l[y][h[a][5]]] = k[3];
          g[l[y][h[a][6]]] = k[4];
          g[l[y][h[a][7]]] = k[5];
          g[l[y][h[a][8]]] = k[6];
          return 0;          // Restore Naked pair Candidates to Unit other Cell positions
        }
        continue;
      }
      K[0] &= K[0] ^ K[1];   // Found more than 2 Candidates in Unit pair Cell positions
      if (B[K[0]] == 2)      // Check Hidden pair Candidates in Unit pair Cell positions
      {
        int k[2] = {g[l[y][h[a][0]]], g[l[y][h[a][1]]]};
                             // Backup and remove other than Hidden pair Candidates from Unit pair Cell positions
        g[l[y][h[a][0]]] &= K[0];
        g[l[y][h[a][1]]] &= K[0];
#ifdef RJ
        printf ("%d) Found Hidden pair Candidates %d at Unit %d Cells %d %d\n",
          a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]]);
#endif
        if (solve (p))
          return 1;
#ifdef RJ
        printf ("%d) Restore Hidden pair Candidates %d at Unit %d Cells %d %d\n",
          a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]]);
#endif
        g[l[y][h[a][0]]] = k[0];
        g[l[y][h[a][1]]] = k[1];
        return 0;            // Restore other than Hidden pair Candidates to Unit pair Cell positions
      }
    }
    if (X < 6)
      continue;              // Skip triplets and quads for less than 6 unsolved Cell positions
    for (; a < 120; ++a)     // Search Unit 84 triplet Cell positions
    {
      if (!g[l[y][h[a][0]]] || !g[l[y][h[a][1]]] || !g[l[y][h[a][2]]])
      {                      // Skip solved Cell positions
        if (!g[l[y][h[a][0]]])
        {
          int A[7] = {27,20,14, 9, 5, 2, 0};

          a += A[h[a][0]];
        }
        else
          if (!g[l[y][h[a][1]]])
            a += 7 - h[a][1];
        continue;
      }
      int K[2] = {g[l[y][h[a][0]]] | g[l[y][h[a][1]]] | g[l[y][h[a][2]]],
        g[l[y][h[a][3]]] | g[l[y][h[a][4]]] | g[l[y][h[a][5]]] |
        g[l[y][h[a][6]]] | g[l[y][h[a][7]]] | g[l[y][h[a][8]]]};

      if (B[K[0]] == 3)      // Check Naked triplet Candidates in Unit triplet Cell positions
      {
        if (K[0] & K[1])     // Check Naked triplet Candidates in Unit other Cell positions
        {
          int k[6] = {g[l[y][h[a][3]]], g[l[y][h[a][4]]], g[l[y][h[a][5]]],
            g[l[y][h[a][6]]], g[l[y][h[a][7]]], g[l[y][h[a][8]]]};
                             // Backup and remove Naked triplet Candidates from Unit other Cell positions
          g[l[y][h[a][3]]] &= ~K[0];
          g[l[y][h[a][4]]] &= ~K[0];
          g[l[y][h[a][5]]] &= ~K[0];
          g[l[y][h[a][6]]] &= ~K[0];
          g[l[y][h[a][7]]] &= ~K[0];
          g[l[y][h[a][8]]] &= ~K[0];
#ifdef RJ
          printf ("%d) Found Naked triplet Candidates %d at Unit %d Cells %d %d %d\n",
            a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]]);
#endif
          if (solve (p))
            return 1;
#ifdef RJ
          printf ("%d) Restore Naked triplet Candidates %d at Unit %d Cells %d %d %d\n",
            a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]]);
#endif
          g[l[y][h[a][3]]] = k[0];
          g[l[y][h[a][4]]] = k[1];
          g[l[y][h[a][5]]] = k[2];
          g[l[y][h[a][6]]] = k[3];
          g[l[y][h[a][7]]] = k[4];
          g[l[y][h[a][8]]] = k[5];
          return 0;          // Restore Naked triplet Candidates to Unit other Cell positions
        }
        continue;
      }
      K[0] &= K[0] ^ K[1];   // Found more than 3 Candidates in Unit triplet Cell positions
      if (B[K[0]] == 3)      // Check Hidden triplet Candidates in Unit triplet Cell positions
      {
        int k[3] = {g[l[y][h[a][0]]], g[l[y][h[a][1]]], g[l[y][h[a][2]]]};
                             // Backup and remove other than Hidden triplet Candidates from Unit triplet Cell positions
        g[l[y][h[a][0]]] &= K[0];
        g[l[y][h[a][1]]] &= K[0];
        g[l[y][h[a][2]]] &= K[0];
#ifdef RJ
        printf ("%d) Found Hidden triplet Candidates %d at Unit %d Cells %d %d %d\n",
          a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]]);
#endif
        if (solve (p))
          return 1;
#ifdef RJ
        printf ("%d) Restore Hidden triplet Candidates %d at Unit %d Cells %d %d %d\n",
          a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]]);
#endif
        g[l[y][h[a][0]]] = k[0];
        g[l[y][h[a][1]]] = k[1];
        g[l[y][h[a][2]]] = k[2];
        return 0;            // Restore other than Hidden triplet Candidates to Unit triplet Cell positions
      }
    }
    if (X < 8)
      continue;              // Skip quads for less than 8 unsolved Cell positions
    for (; a < 246; ++a)     // Search Unit 126 quad Cell positions in Unit quad Cell positions
    {
      if (!g[l[y][h[a][0]]] || !g[l[y][h[a][1]]] || !g[l[y][h[a][2]]] || !g[l[y][h[a][3]]])
      {                      // Skip solved Cell positions
        if (!g[l[y][h[a][0]]])
        {
          int A[6] = {55,34,19, 9, 3, 0};

          a += A[h[a][0]];
        }
        else
          if (!g[l[y][h[a][1]]])
          {
            int A[7] = {27,20,14, 9, 5, 2, 0};

            a += A[h[a][1]];
          }
          else
            if (!g[l[y][h[a][2]]])
              a += 7 - h[a][2];
        continue;
      }
      int K[2] = {g[l[y][h[a][0]]] | g[l[y][h[a][1]]] | g[l[y][h[a][2]]] |
        g[l[y][h[a][3]]], g[l[y][h[a][4]]] | g[l[y][h[a][5]]] |
        g[l[y][h[a][6]]] | g[l[y][h[a][7]]] | g[l[y][h[a][8]]]};

      if (B[K[0]] == 4)      // Check Naked quad Candidates in Unit quad Cell positions
      {
        if (K[0] & K[1])     // Check Naked quad Candidates in Unit other Cell positions
        {
          int k[5] = {g[l[y][h[a][4]]], g[l[y][h[a][5]]], g[l[y][h[a][6]]],
            g[l[y][h[a][7]]], g[l[y][h[a][8]]]};
                             // Backup and remove Naked quad Candidates from Unit other Cell positions
          g[l[y][h[a][4]]] &= ~K[0];
          g[l[y][h[a][5]]] &= ~K[0];
          g[l[y][h[a][6]]] &= ~K[0];
          g[l[y][h[a][7]]] &= ~K[0];
          g[l[y][h[a][8]]] &= ~K[0];
#ifdef RJ
          printf ("%d) Found Naked quad Candidates %d at Unit %d Cells %d %d %d %d\n",
            a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]], l[y][h[a][3]]);
#endif
          if (solve (p))
            return 1;
#ifdef RJ
          printf ("%d) Restore Naked quad Candidates %d at Unit %d Cells %d %d %d %d\n",
            a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]], l[y][h[a][3]]);
#endif
          g[l[y][h[a][4]]] = k[0];
          g[l[y][h[a][5]]] = k[1];
          g[l[y][h[a][6]]] = k[2];
          g[l[y][h[a][7]]] = k[3];
          g[l[y][h[a][8]]] = k[4];
          return 0;          // Restore Naked quad Candidates to Unit other Cell positions
        }
        continue;
      }
      K[0] &= K[0] ^ K[1];   // Found more than 4 Candidates in Unit quad Cell positions
      if (B[K[0]] == 4)      // Check Hidden quad Candidates in Unit quad Cell positions
      {
        int k[4] = {g[l[y][h[a][0]]], g[l[y][h[a][1]]], g[l[y][h[a][2]]], g[l[y][h[a][3]]]};
                             // Backup and remove other than Hidden quad Candidates from Unit quad Cell positions
        g[l[y][h[a][0]]] &= K[0];
        g[l[y][h[a][1]]] &= K[0];
        g[l[y][h[a][2]]] &= K[0];
        g[l[y][h[a][3]]] &= K[0];
#ifdef RJ
        printf ("%d) Found Hidden quad Candidates %d at Unit %d Cells %d %d %d %d\n",
          a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]], l[y][h[a][3]]);
#endif
        if (solve (p))
          return 1;
#ifdef RJ
        printf ("%d) Restore Hidden quad Candidates %d at Unit %d Cells %d %d %d %d\n",
          a, b[K[0]], y, l[y][h[a][0]], l[y][h[a][1]], l[y][h[a][2]], l[y][h[a][3]]);
#endif
        g[l[y][h[a][0]]] = k[0];
        g[l[y][h[a][1]]] = k[1];
        g[l[y][h[a][2]]] = k[2];
        g[l[y][h[a][3]]] = k[3];
        return 0;            // Restore other than Hidden quad Candidates to Unit quad Cell positions
      }
    }
  }
  for (y = 0; y < 54; ++y)   // Search 54 Box-Line Cell positions for Intersection Removal Candidate
    for (a = 0; a < 9; ++a)  // Search Intersection Removal Candidate for each Box-Line Cell positions
      if ((g[j[y][0]] >> a) & 1 || (g[j[y][1]] >> a) & 1 || (g[j[y][2]] >> a) & 1)
      {                      // Found Intersection Removal Candidate in Box-Line Cell positions
        if ((g[j[y][3]] >> a) & 1 || (g[j[y][4]] >> a) & 1 || (g[j[y][5]] >> a) & 1 ||
          (g[j[y][6]] >> a) & 1 || (g[j[y][7]] >> a) & 1 || (g[j[y][8]] >> a) & 1)
        {                    // Found Intersection Removal Candidate in Line other Cell positions
          if (!((g[j[y][9]] >> a) & 1 || (g[j[y][10]] >> a) & 1 || (g[j[y][11]] >> a) & 1 ||
            (g[j[y][12]] >> a) & 1 || (g[j[y][13]] >> a) & 1 || (g[j[y][14]] >> a) & 1))
          {                  // Not found Intersection Removal Candidate in Box other Cell positions
            int k = (g[j[y][3]] >> a) & 1 | ((g[j[y][4]] >> a) & 1) << 1 |
              ((g[j[y][5]] >> a) & 1) << 2 | ((g[j[y][6]] >> a) & 1) << 3 |
              ((g[j[y][7]] >> a) & 1) << 4 | ((g[j[y][8]] >> a) & 1) << 5;
                             // Backup and remove Intersection Removal Candidate in Line other Cell positions
            g[j[y][3]] &= ~(1 << a);
            g[j[y][4]] &= ~(1 << a);
            g[j[y][5]] &= ~(1 << a);
            g[j[y][6]] &= ~(1 << a);
            g[j[y][7]] &= ~(1 << a);
            g[j[y][8]] &= ~(1 << a);
#ifdef RJ
            printf ("%d) Found Pointing and Claiming Intersection Removal Candidate %d at Cells %d %d %d\n",
              y, a + 1, j[y][0], j[y][1], j[y][2]);
#endif
            if (solve (p))
              return 1;
#ifdef RJ
            printf ("%d) Restore Pointing and Claiming Intersection Removal Candidate %d at Cells %d %d %d\n",
              y, a + 1, j[y][0], j[y][1], j[y][2]);
#endif
            g[j[y][3]] |= (k & 1) << a;
            g[j[y][4]] |= ((k >> 1) & 1) << a;
            g[j[y][5]] |= ((k >> 2) & 1) << a;
            g[j[y][6]] |= ((k >> 3) & 1) << a;
            g[j[y][7]] |= ((k >> 4) & 1) << a;
            g[j[y][8]] |= ((k >> 5) & 1) << a;
            return 0;        // Restore Intersection Removal Candidate in Line other Cell positions
          }
          continue;
        }                    // Not found Intersection Removal Candidate in Line other Cell positions
        if ((g[j[y][9]] >> a) & 1 || (g[j[y][10]] >> a) & 1 || (g[j[y][11]] >> a) & 1 ||
          (g[j[y][12]] >> a) & 1 || (g[j[y][13]] >> a) & 1 || (g[j[y][14]] >> a) & 1)
        {                    // Found Intersection Removal Candidate in Box other Cell positions
          int k = (g[j[y][9]] >> a) & 1 | ((g[j[y][10]] >> a) & 1) << 1 |
            ((g[j[y][11]] >> a) & 1) << 2 | ((g[j[y][12]] >> a) & 1) << 3 |
            ((g[j[y][13]] >> a) & 1) << 4 | ((g[j[y][14]] >> a) & 1) << 5;
                             // Backup and remove Intersection Removal Candidate in Box other Cell positions
          g[j[y][9]] &= ~(1 << a);
          g[j[y][10]] &= ~(1 << a);
          g[j[y][11]] &= ~(1 << a);
          g[j[y][12]] &= ~(1 << a);
          g[j[y][13]] &= ~(1 << a);
          g[j[y][14]] &= ~(1 << a);
#ifdef RJ
          printf ("%d) Found Box-Line Reduction Intersection Removal Candidate %d at Cells %d %d %d\n",
            y, a + 1, j[y][0], j[y][1], j[y][2]);
#endif
          if (solve (p))
            return 1;
#ifdef RJ
          printf ("%d) Restore Box-Line Reduction Intersection Removal Candidate %d at Cells %d %d %d\n",
            y, a + 1, j[y][0], j[y][1], j[y][2]);
#endif
          g[j[y][9]] |= (k & 1) << a;
          g[j[y][10]] |= ((k >> 1) & 1) << a;
          g[j[y][11]] |= ((k >> 2) & 1) << a;
          g[j[y][12]] |= ((k >> 3) & 1) << a;
          g[j[y][13]] |= ((k >> 4) & 1) << a;
          g[j[y][14]] |= ((k >> 5) & 1) << a;
          return 0;          // Restore Intersection Removal Candidate in Box other Cell positions
        }
      }
  for (y = 0; y < 18; ++y)   // Search Basic Fishes for each Line
  {
    int k[10],               // Backup Line Cell positions and Basic Fish Candidate
        Y = y < 9 ? 0 : 9;   // Assign either Row or Column wise

    for (k[9] = y - Y, a = Y; a < Y + 9; ++a)
      k[a - Y] = (g[l[a][0]] >> k[9]) & 1 | ((g[l[a][1]] >> k[9]) & 1) << 1 |
        ((g[l[a][2]] >> k[9]) & 1) << 2 | ((g[l[a][3]] >> k[9]) & 1) << 3 |
        ((g[l[a][4]] >> k[9]) & 1) << 4 | ((g[l[a][5]] >> k[9]) & 1) << 5 |
        ((g[l[a][6]] >> k[9]) & 1) << 6 | ((g[l[a][7]] >> k[9]) & 1) << 7 |
        ((g[l[a][8]] >> k[9]) & 1) << 8;
    for (a = 0; a < 36; ++a) // Search X-Wing Candidate in Line 36 pair Cell positions
    {
      int A = k[h[a][0]],
          K[2],
          X = -1;

      if (B[A] != 2 || A != k[h[a][1]])
      {                      // Skip for X-Wing Candidate not found in Lines pair Cell positions
        if (B[A] != 2)
          a += 7 - h[a][0];
        continue;
      }
      for (int L = A, Z = -1; L; L &= L - 1)
      {
        K[++Z] = b[L & -L] - 1;
        if (!((k[h[a][2]] >> K[Z]) & 1 || (k[h[a][3]] >> K[Z]) & 1 ||
          (k[h[a][4]] >> K[Z]) & 1 || (k[h[a][5]] >> K[Z]) & 1 || (k[h[a][6]] >> K[Z]) & 1 ||
          (k[h[a][7]] >> K[Z]) & 1 || (k[h[a][8]] >> K[Z]) & 1))
          continue;          // Skip opposite Line for X-Wing Candidate not found in opposite Line other Cell positions
        X = K[Z] - Y + 9;    // Remove X-Wing Candidate from opposite Line other Cell positions
        g[l[X][h[a][2]]] &= ~(1 << k[9]);
        g[l[X][h[a][3]]] &= ~(1 << k[9]);
        g[l[X][h[a][4]]] &= ~(1 << k[9]);
        g[l[X][h[a][5]]] &= ~(1 << k[9]);
        g[l[X][h[a][6]]] &= ~(1 << k[9]);
        g[l[X][h[a][7]]] &= ~(1 << k[9]);
        g[l[X][h[a][8]]] &= ~(1 << k[9]);
      }
      if (X < 0)
        continue;            // Skip for X-Wing Candidate not found in opposite Lines other Cell positions
#ifdef RJ
      printf ("%d) Found %s X-Wing for Candidate %d at r%d%dc%d%d\n",
        a, Y ? "Column wise" : "Row wise", k[9] + 1, (Y ? K[0] : h[a][0]) + 1,
        (Y ? K[1] : h[a][1]) + 1, (Y ? h[a][0] : K[0]) + 1, (Y ? h[a][1] : K[1]) + 1);
#endif
      if (solve (p))
        return 1;
#ifdef RJ
      printf ("%d) Restore %s X-Wing for Candidate %d at r%d%dc%d%d\n",
        a, Y ? "Column wise" : "Row wise", k[9] + 1, (Y ? K[0] : h[a][0]) + 1,
        (Y ? K[1] : h[a][1]) + 1, (Y ? h[a][0] : K[0]) + 1, (Y ? h[a][1] : K[1]) + 1);
#endif
      for (int Z = 0; Z < 2; ++Z)
      {                      // Restore X-Wing Candidate to opposite Lines other Cell positions
        X = K[Z] - Y + 9;
        g[l[X][h[a][2]]] |= ((k[h[a][2]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][3]]] |= ((k[h[a][3]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][4]]] |= ((k[h[a][4]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][5]]] |= ((k[h[a][5]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][6]]] |= ((k[h[a][6]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][7]]] |= ((k[h[a][7]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][8]]] |= ((k[h[a][8]] >> K[Z]) & 1) << k[9];
      }
      return 0;
    }
    for (; a < 120; ++a)     // Search Sword Fish Candidate in Line 84 triplet Cell positions
    {
      int A = k[h[a][0]] | k[h[a][1]] | k[h[a][2]],
          K[3],
          X = -1;

      if (!k[h[a][0]] || !k[h[a][1]] || !k[h[a][2]] || B[A] != 3)
      {                      // Skip for either solved Cell positions or Sord Fish Candidate not found in Lines triplet Cell positions
        if (!k[h[a][0]] || B[k[h[a][0]]] > 3)
        {
          int A[7] = {27,20,14, 9, 5, 2, 0};

          a += A[h[a][0]];
        }
        else
          if (!k[h[a][1]] || B[k[h[a][1]]] > 3)
            a += 7 - h[a][1];
        continue;
      }
      for (int L = A, Z = -1; L; L &= L - 1)
      {
        K[++Z] = b[L & -L] - 1;
        if (!((k[h[a][3]] >> K[Z]) & 1 || (k[h[a][4]] >> K[Z]) & 1 || (k[h[a][5]] >> K[Z]) & 1 ||
          (k[h[a][6]] >> K[Z]) & 1 || (k[h[a][7]] >> K[Z]) & 1 || (k[h[a][8]] >> K[Z]) & 1))
          continue;          // Skip opposite Line for Sword Fish Candidate not found in opposite Line other Cell positions
        X = K[Z] - Y + 9;    // Remove Sword Fish Candidate from opposite Line other Cell positions
        g[l[X][h[a][3]]] &= ~(1 << k[9]);
        g[l[X][h[a][4]]] &= ~(1 << k[9]);
        g[l[X][h[a][5]]] &= ~(1 << k[9]);
        g[l[X][h[a][6]]] &= ~(1 << k[9]);
        g[l[X][h[a][7]]] &= ~(1 << k[9]);
        g[l[X][h[a][8]]] &= ~(1 << k[9]);
      }
      if (X < 0)
        continue;            // Skip for Sword Fish Candidate not found in opposite Lines other Cell positions
#ifdef RJ
      printf ("%d) Found %s Sword Fish for Candidate %d at r%d%d%dc%d%d%d\n",
        a, Y ? "Column wise" : "Row wise", k[9] + 1, (Y ? K[0] : h[a][0]) + 1,
        (Y ? K[1] : h[a][1]) + 1, (Y ? K[2] : h[a][2]) + 1, (Y ? h[a][0] : K[0]) + 1,
        (Y ? h[a][1] : K[1]) + 1, (Y ? h[a][2] : K[2]) + 1);
#endif
      if (solve (p))
        return 1;
#ifdef RJ
      printf ("%d) Restore %s Sword Fish for Candidate %d at r%d%d%dc%d%d%d\n",
        a, Y ? "Column wise" : "Row wise", k[9] + 1, (Y ? K[0] : h[a][0]) + 1,
        (Y ? K[1] : h[a][1]) + 1, (Y ? K[2] : h[a][2]) + 1, (Y ? h[a][0] : K[0]) + 1,
        (Y ? h[a][1] : K[1]) + 1, (Y ? h[a][2] : K[2]) + 1);
#endif
      for (int Z = 0; Z < 3; ++Z)
      {                      // Restore Sword Fish Candidate to opposite Lines other Cell positions
        X = K[Z] - Y + 9;
        g[l[X][h[a][3]]] |= ((k[h[a][3]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][4]]] |= ((k[h[a][4]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][5]]] |= ((k[h[a][5]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][6]]] |= ((k[h[a][6]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][7]]] |= ((k[h[a][7]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][8]]] |= ((k[h[a][8]] >> K[Z]) & 1) << k[9];
      }
      return 0;
    }
    for (; a < 246; ++a)     // Search Jelly Fish Candidate in Line 126 quad Cell positions
    {
      int A = k[h[a][0]] | k[h[a][1]] | k[h[a][2]] | k[h[a][3]],
          K[4],
          X = -1;

      if (!k[h[a][0]] || !k[h[a][1]] || !k[h[a][2]] || !k[h[a][3]] || B[A] != 4)
      {                      // Skip for either solved Cell positions or Jelly Fish Candidate not found in Line quad Cell positions
        if (!k[h[a][0]] || B[k[h[a][0]]] > 4)
        {
          int A[6] = {55,34,19, 9, 3, 0};

          a += A[h[a][0]];
        }
        else
          if (!k[h[a][1]] || B[k[h[a][1]]] > 4)
          {
            int A[7] = {27,20,14, 9, 5, 2, 0};

            a += A[h[a][1]];
          }
          else
            if (!k[h[a][2]] || B[k[h[a][2]]] > 4)
              a += 7 - h[a][2];
        continue;
      }
      for (int L = A, Z = -1; L; L &= L - 1)
      {
        K[++Z] = b[L & -L] - 1;
        if (!((k[h[a][4]] >> K[Z]) & 1 || (k[h[a][5]] >> K[Z]) & 1 ||
          (k[h[a][6]] >> K[Z]) & 1 || (k[h[a][7]] >> K[Z]) & 1 || (k[h[a][8]] >> K[Z]) & 1))
          continue;          // Skip for Jelly Fish Candidate not found in opposite Line other Cell positions
        X = K[Z] - Y + 9;    // Remove Jelly Fish Candidate from opposite Line other Cell positions
        g[l[X][h[a][4]]] &= ~(1 << k[9]);
        g[l[X][h[a][5]]] &= ~(1 << k[9]);
        g[l[X][h[a][6]]] &= ~(1 << k[9]);
        g[l[X][h[a][7]]] &= ~(1 << k[9]);
        g[l[X][h[a][8]]] &= ~(1 << k[9]);
      }
      if (X < 0)
        continue;            // Skip for Jelly Fish Candidate not found in opposite Lines other Cell positions
#ifdef RJ
      printf ("%d) Found %s Jelly Fish for Candidate %d at r%d%d%d%dc%d%d%d%d\n",
        a, Y ? "Column wise" : "Row wise", k[9] + 1, (Y ? K[0] : h[a][0]) + 1,
        (Y ? K[1] : h[a][1]) + 1, (Y ? K[2] : h[a][2]) + 1, (Y ? K[3] : h[a][3]) + 1,
        (Y ? h[a][0] : K[0]) + 1, (Y ? h[a][1] : K[1]) + 1, (Y ? h[a][2] : K[2]) + 1,
        (Y ? h[a][3] : K[3]) + 1);
#endif
      if (solve (p))
        return 1;
#ifdef RJ
      printf ("%d) Restore %s Jelly Fish for Candidate %d at r%d%d%d%dc%d%d%d%d\n",
        a, Y ? "Column wise" : "Row wise", k[9] + 1, (Y ? K[0] : h[a][0]) + 1,
        (Y ? K[1] : h[a][1]) + 1, (Y ? K[2] : h[a][2]) + 1, (Y ? K[3] : h[a][3]) + 1,
        (Y ? h[a][0] : K[0]) + 1, (Y ? h[a][1] : K[1]) + 1, (Y ? h[a][2] : K[2]) + 1,
        (Y ? h[a][3] : K[3]) + 1);
#endif
      for (int Z = 0; Z < 4; ++Z)
      {                      // Restore Jelly Fish Candidate to opposite Lines other Cell positions
        X = K[Z] - Y + 9;
        g[l[X][h[a][4]]] |= ((k[h[a][4]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][5]]] |= ((k[h[a][5]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][6]]] |= ((k[h[a][6]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][7]]] |= ((k[h[a][7]] >> K[Z]) & 1) << k[9];
        g[l[X][h[a][8]]] |= ((k[h[a][8]] >> K[Z]) & 1) << k[9];
      }
      return 0;
    }
  }
  y = 2;                     // Represent Guess
NHSCF:
  if (x > p)                 // Check current Cell position for sorting and eliminating
  {
    a = r[p];
    r[p] = r[x];
    r[x] = a;
  }
  int K = g[r[p]];           // Backup current Cell position Candidates

  for (g[r[p]] = 0; s[r[p]] = b[z & -z]; z &= z - 1)
  {                          // Remove current Cell position Candidates and solve current Cell position Candidate wise
    int k = 0;

    for (++n[y], a = 0; a < 20; ++a)
      if (g[w[r[p]][a]] & (1 << (s[r[p]] - 1)))
      {
        k |= 1 << a;         // Backup affected 20 Cell positions current Candidate
        g[w[r[p]][a]] &= ~(1 << (s[r[p]] - 1));
      }                      // Remove current Candidate from affected 20 Cell positions
#ifdef RJ
    printf ("%d) Apply %s Candidate %d from Candidates %d at Cell %d\n",
      p, y ? (y > 1 ? "Trial and Error" : "Hidden Single") : "Naked Single",
      s[r[p]], b[K], r[p]);
#endif
    if (a > 19 && (p + 1 >= q || solve (p + 1)))
      return 1;              // If either all Cell positions solved or recursive solve for next unsolved Cell position
#ifdef RJ
    printf ("%d) Restore %s Candidate %d from Candidates %d at Cell %d\n",
      p, y ? (y > 1 ? "Trial and Error" : "Hidden Single") : "Naked Single",
      s[r[p]], b[K], r[p]);
#endif
    while (a > 0)            // Restore current Candidate to affected 20 Cell positions
      g[w[r[p]][--a]] |= ((k >> a) & 1) << (s[r[p]] - 1);
  }
  g[r[p]] = K;               // Restore Candidates to current Cell position
  return 0;
}

int check (int p, int q)
{
  for (int a = 0; a < 20; ++a)
    if (s[w[p][a]] == q)     // Check duplicate Candidate in affected 20 clue Cell positions
      return 0;
  return 1;
}

int invalid (void)
{
  for (int p = 0; p < 81; ++p)
    if (!s[p])               // Check unsolved Cell position
    {
      for (int a = 0; a < 9; ++a)
        g[p] |= check (p, a + 1) << a;
                             // Check constraint and assign Candidate for unsolved Cell position
      if (!g[p])             // Check no Candidate assigned
        return 1;
      r[q++] = p;            // Assign unsolved Cell position for sorting and eliminating
    }
    else
      if (!check (p, s[p]))  // Check constraint for clue Cell position
        return 1;
  return 0;
}

int main (void)
{
  int a = -1,
      m,
      i = 0,
      t = 0,
      u = 0,
      v = 0,
      y = 0;

  float c,
        d = 0,
        e = 0,
        f = 0,
        k = 0;

  FILE *o = fopen ("sudoku.txt", "r");

  if (o == NULL)
    printf ("Unable to open sudoku.txt file for read !!\n");
  else
    do
    {
      if ((m = fgetc (o)) != 10 && m != EOF && a < 80)
        s[++a] = m >= '1' && m <= '9' ? m - '0' : 0;
      else                   // Assign clue Cell positions
        if (m == 10 || m == EOF)
        {
#ifdef RJ
          printf ("\n");
#endif
          while (a < 80)     // Clear remaining unsolved Cell positions
            s[++a] = 0;
          q = n[0] = n[1] = n[2] = 0;
          c = clock ();
          if (invalid ())
          {
            c = (clock () - c) / CLOCKS_PER_SEC * 1000;
            d += c;
            printf ("%ld) Error: Invalid Sudoku! # I%ld", ++t, ++i);
          }
          else
            if (!q)
            {
              c = (clock () - c) / CLOCKS_PER_SEC * 1000;
              k += c;
              printf ("%ld) Valid Sudoku # V%ld", ++t, ++y);
            }
            else
              if (solve (0))
              {
                c = (clock () - c) / CLOCKS_PER_SEC * 1000;
                e += c;
                printf ("%ld) ", ++t);
                for (a = 0; a < 81; ++a)
                  printf ("%c", s[a] + '0');
                printf (" # S%ld", ++v);
              }
              else
              {
                c = (clock () - c) / CLOCKS_PER_SEC * 1000;
                f += c;
                printf ("%ld) Error: Unsolvable Sudoku! # U%ld", ++t, ++u);
              }
          printf (" # N%ld # H%ld # G%ld # %f\n", n[0], n[1], n[2], c);
          a = -1;
        }
#ifdef RJ
      if (m != EOF)
        printf ("%c", m);
#endif
    }
    while (m != EOF);
  printf ("=======================================\n");
  printf ("Total Sudoku puzzle read   : %ld\n", t);
  printf ("Total time for all puzzles : %f\n", d + e + f + y);
  printf ("Average time per puzzle    : %f\n", t ? (d + e + f + y) / t : 0);
  printf ("Number of valid puzzles    : %ld\n", y);
  printf ("Time for valid puzzles     : %f\n", k);
  printf ("Average time per valid     : %f\n", y ? k / y : 0);
  printf ("Number of invalid puzzles  : %ld\n", i);
  printf ("Time for invalid puzzles   : %f\n", d);
  printf ("Average time per invalid   : %f\n", i ? d / i : 0);
  printf ("Number of solved puzzles   : %ld\n", v);
  printf ("Time for solved puzzles    : %f\n", e);
  printf ("Average time per solved    : %f\n", v ? e / v : 0);
  printf ("Number of unsolved puzzle  : %ld\n", u);
  printf ("Time for unsolved puzzles  : %f\n", f);
  printf ("Average time per unsolved  : %f\n", u ? f / u : 0);
  if (fclose (o) == EOF)
    printf ("Unable to close sudoku.txt file !!");
}
