#include "GR_assert.h"

typedef struct {
  int iNPerm;
  int (*a2iFaceCell)[2]; 
  int (*a2iFaceVert)[3]; 
  int (*a2iCellFace)[4]; 
} Config;

typedef struct {
  int iNCanon;
  Config *aConf;
} ConfSet;

// A file-local set of data describing the possible outcomes of
// reconfiguration.  The set is indexed by the number of equatorial
// verts in the initial configuration.
static ConfSet aCS[8];
static bool qCSInit = false;

#define NORTH_POLE -2
#define SOUTH_POLE -1
#define NORTH_FACE 1000
#define SOUTH_FACE 2000

static void vInitCanonConfigs()
{
  if (qCSInit) return;
  //@ If the original config has two or fewer verts, there is no
  // canonical config at all.
  aCS[0].iNCanon = aCS[1].iNCanon = aCS[2].iNCanon = 0;
  aCS[0].aConf = aCS[1].aConf = aCS[2].aConf = 0;

  Config *pConf;
  
  //@ One config for three-to-two swapping.
  aCS[3].iNCanon = 1;
  aCS[3].aConf = new Config;
  pConf = aCS[3].aConf;
  pConf->iNPerm = 1;
  pConf->a2iFaceCell = new int[1][2];
  pConf->a2iFaceVert = new int[1][3];
  pConf->a2iCellFace = new int[2][4];
  //@@ Face-cell data			      
  pConf->a2iFaceCell[0][0] = 1;
  pConf->a2iFaceCell[0][1] = 0;
  //@@ Face-vert data			      
  pConf->a2iFaceVert[0][0] = 0;
  pConf->a2iFaceVert[0][1] = 1;
  pConf->a2iFaceVert[0][2] = 2;
  //@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 1;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][0] = 0;
  pConf->a2iCellFace[1][1] = SOUTH_FACE + 0;
  pConf->a2iCellFace[1][2] = SOUTH_FACE + 1;
  pConf->a2iCellFace[1][3] = SOUTH_FACE + 2;

  //@ One config for four-to-four swapping.
  aCS[4].iNCanon = 1;
  aCS[4].aConf = new Config;
  pConf = aCS[4].aConf;
  pConf->iNPerm = 2;
  pConf->a2iFaceCell = new int[4][2];
  pConf->a2iFaceVert = new int[4][3];
  pConf->a2iCellFace = new int[4][4];
  //@@ Face-cell data			      
  pConf->a2iFaceCell[0][0] = 2;
  pConf->a2iFaceCell[0][1] = 0;
  pConf->a2iFaceCell[1][0] = 3;
  pConf->a2iFaceCell[1][1] = 1;
  pConf->a2iFaceCell[2][0] = 1;
  pConf->a2iFaceCell[2][1] = 0;
  pConf->a2iFaceCell[3][0] = 3;
  pConf->a2iFaceCell[3][1] = 2;
  //@@ Face-vert data			      
  pConf->a2iFaceVert[0][0] = 0;
  pConf->a2iFaceVert[0][1] = 1;
  pConf->a2iFaceVert[0][2] = 2;
  pConf->a2iFaceVert[1][0] = 0;
  pConf->a2iFaceVert[1][1] = 2;
  pConf->a2iFaceVert[1][2] = 3;
  pConf->a2iFaceVert[2][0] = 0;
  pConf->a2iFaceVert[2][1] = 2;
  pConf->a2iFaceVert[2][2] = NORTH_POLE;
  pConf->a2iFaceVert[3][0] = 2;
  pConf->a2iFaceVert[3][1] = 0;
  pConf->a2iFaceVert[3][2] = SOUTH_POLE;
  //@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 2;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 1;
  pConf->a2iCellFace[1][1] = 2;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][3] = NORTH_FACE + 3;
  pConf->a2iCellFace[2][0] = 0;
  pConf->a2iCellFace[2][1] = 3;
  pConf->a2iCellFace[2][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[2][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[3][0] = 1;
  pConf->a2iCellFace[3][1] = 3;
  pConf->a2iCellFace[3][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[3][3] = SOUTH_FACE + 3;

  //@ One config for five-to-six swapping
  aCS[5].iNCanon = 1;
  aCS[5].aConf = new Config;
  pConf = aCS[5].aConf;
  pConf->iNPerm = 5;
  pConf->a2iFaceCell = new int[7][2];
  pConf->a2iFaceVert = new int[7][3];
  pConf->a2iCellFace = new int[6][4];
  //@@ Face-cell data			      
  pConf->a2iFaceCell[0][0] = 3;
  pConf->a2iFaceCell[0][1] = 0;
  pConf->a2iFaceCell[1][0] = 4;
  pConf->a2iFaceCell[1][1] = 1;
  pConf->a2iFaceCell[2][0] = 5;
  pConf->a2iFaceCell[2][1] = 2;
  pConf->a2iFaceCell[3][0] = 0;
  pConf->a2iFaceCell[3][1] = 1;
  pConf->a2iFaceCell[4][0] = 3;
  pConf->a2iFaceCell[4][1] = 4;
  pConf->a2iFaceCell[5][0] = 1;
  pConf->a2iFaceCell[5][1] = 2;
  pConf->a2iFaceCell[6][0] = 4;
  pConf->a2iFaceCell[6][1] = 5;
  //@@ Face-vert data			      
  pConf->a2iFaceVert[0][0] = 0;
  pConf->a2iFaceVert[0][1] = 1;
  pConf->a2iFaceVert[0][2] = 2;
  pConf->a2iFaceVert[1][0] = 0;
  pConf->a2iFaceVert[1][1] = 2;
  pConf->a2iFaceVert[1][2] = 3;
  pConf->a2iFaceVert[2][0] = 0;
  pConf->a2iFaceVert[2][1] = 3;
  pConf->a2iFaceVert[2][2] = 4;
  pConf->a2iFaceVert[3][0] = 2;
  pConf->a2iFaceVert[3][1] = 0;
  pConf->a2iFaceVert[3][2] = NORTH_POLE;
  pConf->a2iFaceVert[4][0] = 0;
  pConf->a2iFaceVert[4][1] = 2;
  pConf->a2iFaceVert[4][2] = SOUTH_POLE;
  pConf->a2iFaceVert[5][0] = 3;
  pConf->a2iFaceVert[5][1] = 0;
  pConf->a2iFaceVert[5][2] = NORTH_POLE;
  pConf->a2iFaceVert[6][0] = 0;
  pConf->a2iFaceVert[6][1] = 3;
  pConf->a2iFaceVert[6][2] = SOUTH_POLE;
  //@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 3;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 3;
  pConf->a2iCellFace[1][1] = 5;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 2;
  pConf->a2iCellFace[2][1] = 5;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[2][3] = NORTH_FACE + 4;
  pConf->a2iCellFace[3][0] = 0;
  pConf->a2iCellFace[3][1] = 4;
  pConf->a2iCellFace[3][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[3][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[4][0] = 4;
  pConf->a2iCellFace[4][1] = 6;
  pConf->a2iCellFace[4][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[4][3] = 1;
  pConf->a2iCellFace[5][0] = 2;
  pConf->a2iCellFace[5][1] = 6;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 4;

  //@ Four configs for six-to-ten swapping
  aCS[6].iNCanon = 4;
  aCS[6].aConf = new Config[4];
  pConf = aCS[6].aConf;
  //@@ Fan configuration
  pConf->iNPerm = 6;
  pConf->a2iFaceCell = new int[10][2];
  pConf->a2iFaceVert = new int[10][3];
  pConf->a2iCellFace = new int[8][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[0][0] = 4;
  pConf->a2iFaceCell[0][1] = 0;
  pConf->a2iFaceCell[1][0] = 5;
  pConf->a2iFaceCell[1][1] = 1;
  pConf->a2iFaceCell[2][0] = 6;
  pConf->a2iFaceCell[2][1] = 2;
  pConf->a2iFaceCell[3][0] = 7;
  pConf->a2iFaceCell[3][1] = 3;
  pConf->a2iFaceCell[4][0] = 0;
  pConf->a2iFaceCell[4][1] = 1;
  pConf->a2iFaceCell[5][0] = 4;
  pConf->a2iFaceCell[5][1] = 5;
  pConf->a2iFaceCell[6][0] = 1;
  pConf->a2iFaceCell[6][1] = 2;
  pConf->a2iFaceCell[7][0] = 5;
  pConf->a2iFaceCell[7][1] = 6;
  pConf->a2iFaceCell[8][0] = 2;
  pConf->a2iFaceCell[8][1] = 3;
  pConf->a2iFaceCell[9][0] = 6;
  pConf->a2iFaceCell[9][1] = 7;
  //@@@ Face-vert data		
  pConf->a2iFaceVert[0][0] = 0;
  pConf->a2iFaceVert[0][1] = 1;
  pConf->a2iFaceVert[0][2] = 2;
  pConf->a2iFaceVert[1][0] = 0;
  pConf->a2iFaceVert[1][1] = 2;
  pConf->a2iFaceVert[1][2] = 3;
  pConf->a2iFaceVert[2][0] = 0;
  pConf->a2iFaceVert[2][1] = 3;
  pConf->a2iFaceVert[2][2] = 4;
  pConf->a2iFaceVert[3][0] = 0;
  pConf->a2iFaceVert[3][1] = 4;
  pConf->a2iFaceVert[3][2] = 5;
  pConf->a2iFaceVert[4][0] = 2;
  pConf->a2iFaceVert[4][1] = 0;
  pConf->a2iFaceVert[4][2] = NORTH_POLE;
  pConf->a2iFaceVert[5][0] = 0;
  pConf->a2iFaceVert[5][1] = 2;
  pConf->a2iFaceVert[5][2] = SOUTH_POLE;
  pConf->a2iFaceVert[6][0] = 3;
  pConf->a2iFaceVert[6][1] = 0;
  pConf->a2iFaceVert[6][2] = NORTH_POLE;
  pConf->a2iFaceVert[7][0] = 0;
  pConf->a2iFaceVert[7][1] = 3;
  pConf->a2iFaceVert[7][2] = SOUTH_POLE;
  pConf->a2iFaceVert[8][0] = 4;
  pConf->a2iFaceVert[8][1] = 0;
  pConf->a2iFaceVert[8][2] = NORTH_POLE;
  pConf->a2iFaceVert[9][0] = 0;
  pConf->a2iFaceVert[9][1] = 4;
  pConf->a2iFaceVert[9][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 4;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 4;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 8;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 3;
  pConf->a2iCellFace[3][1] = 8;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 4;
  pConf->a2iCellFace[3][3] = NORTH_FACE + 5;
  pConf->a2iCellFace[4][0] = 0;
  pConf->a2iCellFace[4][1] = 5;
  pConf->a2iCellFace[4][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[4][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[5][0] = 5;
  pConf->a2iCellFace[5][1] = 7;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[5][3] = 1;
  pConf->a2iCellFace[6][0] = 7;
  pConf->a2iCellFace[6][1] = 9;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[6][3] = 2;
  pConf->a2iCellFace[7][0] = 3;
  pConf->a2iCellFace[7][1] = 9;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 4;
  pConf->a2iCellFace[7][3] = SOUTH_FACE + 5;

  //@@ Zig-zag 1 configuration
  pConf++;
  pConf->iNPerm = 3;
  pConf->a2iFaceCell = new int[10][2];
  pConf->a2iFaceVert = new int[10][3];
  pConf->a2iCellFace = new int[8][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[0][0] = 4;
  pConf->a2iFaceCell[0][1] = 0;
  pConf->a2iFaceCell[1][0] = 5;
  pConf->a2iFaceCell[1][1] = 1;
  pConf->a2iFaceCell[2][0] = 6;
  pConf->a2iFaceCell[2][1] = 2;
  pConf->a2iFaceCell[3][0] = 7;
  pConf->a2iFaceCell[3][1] = 3;
  pConf->a2iFaceCell[4][0] = 0;
  pConf->a2iFaceCell[4][1] = 1;
  pConf->a2iFaceCell[5][0] = 4;
  pConf->a2iFaceCell[5][1] = 5;
  pConf->a2iFaceCell[6][0] = 1;
  pConf->a2iFaceCell[6][1] = 2;
  pConf->a2iFaceCell[7][0] = 5;
  pConf->a2iFaceCell[7][1] = 6;
  pConf->a2iFaceCell[8][0] = 2;
  pConf->a2iFaceCell[8][1] = 3;
  pConf->a2iFaceCell[9][0] = 6;
  pConf->a2iFaceCell[9][1] = 7;
  //@@@ Face-vert data		
  pConf->a2iFaceVert[0][0] = 0;
  pConf->a2iFaceVert[0][1] = 1;
  pConf->a2iFaceVert[0][2] = 2;
  pConf->a2iFaceVert[1][0] = 0;
  pConf->a2iFaceVert[1][1] = 2;
  pConf->a2iFaceVert[1][2] = 3;
  pConf->a2iFaceVert[2][0] = 0;
  pConf->a2iFaceVert[2][1] = 3;
  pConf->a2iFaceVert[2][2] = 5;
  pConf->a2iFaceVert[3][0] = 3;
  pConf->a2iFaceVert[3][1] = 4;
  pConf->a2iFaceVert[3][2] = 5;
  pConf->a2iFaceVert[4][0] = 2;
  pConf->a2iFaceVert[4][1] = 0;
  pConf->a2iFaceVert[4][2] = NORTH_POLE;
  pConf->a2iFaceVert[5][0] = 0;
  pConf->a2iFaceVert[5][1] = 2;
  pConf->a2iFaceVert[5][2] = SOUTH_POLE;
  pConf->a2iFaceVert[6][0] = 3;
  pConf->a2iFaceVert[6][1] = 0;
  pConf->a2iFaceVert[6][2] = NORTH_POLE;
  pConf->a2iFaceVert[7][0] = 0;
  pConf->a2iFaceVert[7][1] = 3;
  pConf->a2iFaceVert[7][2] = SOUTH_POLE;
  pConf->a2iFaceVert[8][0] = 3;
  pConf->a2iFaceVert[8][1] = 5;
  pConf->a2iFaceVert[8][2] = NORTH_POLE;
  pConf->a2iFaceVert[9][0] = 5;
  pConf->a2iFaceVert[9][1] = 3;
  pConf->a2iFaceVert[9][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 4;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 4;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 8;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 5;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 3;
  pConf->a2iCellFace[3][1] = 8;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[3][3] = NORTH_FACE + 4;
  pConf->a2iCellFace[4][0] = 0;
  pConf->a2iCellFace[4][1] = 5;
  pConf->a2iCellFace[4][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[4][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[5][0] = 5;
  pConf->a2iCellFace[5][1] = 7;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[5][3] = 1;
  pConf->a2iCellFace[6][0] = 7;
  pConf->a2iCellFace[6][1] = 9;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 5;
  pConf->a2iCellFace[6][3] = 2;
  pConf->a2iCellFace[7][0] = 3;
  pConf->a2iCellFace[7][1] = 9;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[7][3] = SOUTH_FACE + 4;

  //@@ Zig-zag 2 configuration
  pConf++;
  pConf->iNPerm = 3;
  pConf->a2iFaceCell = new int[10][2];
  pConf->a2iFaceVert = new int[10][3];
  pConf->a2iCellFace = new int[8][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[0][0] = 4;
  pConf->a2iFaceCell[0][1] = 0;
  pConf->a2iFaceCell[1][0] = 5;
  pConf->a2iFaceCell[1][1] = 1;
  pConf->a2iFaceCell[2][0] = 6;
  pConf->a2iFaceCell[2][1] = 2;
  pConf->a2iFaceCell[3][0] = 7;
  pConf->a2iFaceCell[3][1] = 3;
  pConf->a2iFaceCell[4][0] = 0;
  pConf->a2iFaceCell[4][1] = 1;
  pConf->a2iFaceCell[5][0] = 4;
  pConf->a2iFaceCell[5][1] = 5;
  pConf->a2iFaceCell[6][0] = 1;
  pConf->a2iFaceCell[6][1] = 2;
  pConf->a2iFaceCell[7][0] = 5;
  pConf->a2iFaceCell[7][1] = 6;
  pConf->a2iFaceCell[8][0] = 2;
  pConf->a2iFaceCell[8][1] = 3;
  pConf->a2iFaceCell[9][0] = 6;
  pConf->a2iFaceCell[9][1] = 7;
  //@@@ Face-vert data		
  pConf->a2iFaceVert[0][0] = 1;
  pConf->a2iFaceVert[0][1] = 2;
  pConf->a2iFaceVert[0][2] = 3;
  pConf->a2iFaceVert[1][0] = 0;
  pConf->a2iFaceVert[1][1] = 1;
  pConf->a2iFaceVert[1][2] = 3;
  pConf->a2iFaceVert[2][0] = 0;
  pConf->a2iFaceVert[2][1] = 3;
  pConf->a2iFaceVert[2][2] = 4;
  pConf->a2iFaceVert[3][0] = 0;
  pConf->a2iFaceVert[3][1] = 4;
  pConf->a2iFaceVert[3][2] = 5;
  pConf->a2iFaceVert[4][0] = 3;
  pConf->a2iFaceVert[4][1] = 1;
  pConf->a2iFaceVert[4][2] = NORTH_POLE;
  pConf->a2iFaceVert[5][0] = 1;
  pConf->a2iFaceVert[5][1] = 3;
  pConf->a2iFaceVert[5][2] = SOUTH_POLE;
  pConf->a2iFaceVert[6][0] = 3;
  pConf->a2iFaceVert[6][1] = 0;
  pConf->a2iFaceVert[6][2] = NORTH_POLE;
  pConf->a2iFaceVert[7][0] = 0;
  pConf->a2iFaceVert[7][1] = 3;
  pConf->a2iFaceVert[7][2] = SOUTH_POLE;
  pConf->a2iFaceVert[8][0] = 4;
  pConf->a2iFaceVert[8][1] = 0;
  pConf->a2iFaceVert[8][2] = NORTH_POLE;
  pConf->a2iFaceVert[9][0] = 0;
  pConf->a2iFaceVert[9][1] = 4;
  pConf->a2iFaceVert[9][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 4;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 1;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][0] = 4;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 8;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 3;
  pConf->a2iCellFace[3][1] = 8;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 4;
  pConf->a2iCellFace[3][3] = NORTH_FACE + 5;
  pConf->a2iCellFace[4][0] = 0;
  pConf->a2iCellFace[4][1] = 5;
  pConf->a2iCellFace[4][2] = SOUTH_FACE + 1;
  pConf->a2iCellFace[4][3] = SOUTH_FACE + 2;
  pConf->a2iCellFace[5][0] = 5;
  pConf->a2iCellFace[5][1] = 7;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[5][3] = 1;
  pConf->a2iCellFace[6][0] = 7;
  pConf->a2iCellFace[6][1] = 9;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[6][3] = 2;
  pConf->a2iCellFace[7][0] = 3;
  pConf->a2iCellFace[7][1] = 9;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 4;
  pConf->a2iCellFace[7][3] = SOUTH_FACE + 5;

  //@@ Triangle configuration
  pConf++;
  pConf->iNPerm = 2;
  pConf->a2iFaceCell = new int[10][2];
  pConf->a2iFaceVert = new int[10][3];
  pConf->a2iCellFace = new int[8][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[0][0] = 4;
  pConf->a2iFaceCell[0][1] = 0;
  pConf->a2iFaceCell[1][0] = 5;
  pConf->a2iFaceCell[1][1] = 1;
  pConf->a2iFaceCell[2][0] = 6;
  pConf->a2iFaceCell[2][1] = 2;
  pConf->a2iFaceCell[3][0] = 7;
  pConf->a2iFaceCell[3][1] = 3;
  pConf->a2iFaceCell[4][0] = 1;
  pConf->a2iFaceCell[4][1] = 0;
  pConf->a2iFaceCell[5][0] = 2;
  pConf->a2iFaceCell[5][1] = 0;
  pConf->a2iFaceCell[6][0] = 3;
  pConf->a2iFaceCell[6][1] = 0;
  pConf->a2iFaceCell[7][0] = 5;
  pConf->a2iFaceCell[7][1] = 4;
  pConf->a2iFaceCell[8][0] = 6;
  pConf->a2iFaceCell[8][1] = 4;
  pConf->a2iFaceCell[9][0] = 7;
  pConf->a2iFaceCell[9][1] = 4;
  //@@@ Face-vert data		
  pConf->a2iFaceVert[0][0] = 0;
  pConf->a2iFaceVert[0][1] = 2;
  pConf->a2iFaceVert[0][2] = 4;
  pConf->a2iFaceVert[1][0] = 0;
  pConf->a2iFaceVert[1][1] = 1;
  pConf->a2iFaceVert[1][2] = 2;
  pConf->a2iFaceVert[2][0] = 2;
  pConf->a2iFaceVert[2][1] = 3;
  pConf->a2iFaceVert[2][2] = 4;
  pConf->a2iFaceVert[3][0] = 0;
  pConf->a2iFaceVert[3][1] = 4;
  pConf->a2iFaceVert[3][2] = 5;
  pConf->a2iFaceVert[4][0] = 2;
  pConf->a2iFaceVert[4][1] = 0;
  pConf->a2iFaceVert[4][2] = NORTH_POLE;
  pConf->a2iFaceVert[5][0] = 4;
  pConf->a2iFaceVert[5][1] = 2;
  pConf->a2iFaceVert[5][2] = NORTH_POLE;
  pConf->a2iFaceVert[6][0] = 0;
  pConf->a2iFaceVert[6][1] = 4;
  pConf->a2iFaceVert[6][2] = NORTH_POLE;
  pConf->a2iFaceVert[7][0] = 0;
  pConf->a2iFaceVert[7][1] = 2;
  pConf->a2iFaceVert[7][2] = SOUTH_POLE;
  pConf->a2iFaceVert[8][0] = 2;
  pConf->a2iFaceVert[8][1] = 4;
  pConf->a2iFaceVert[8][2] = SOUTH_POLE;
  pConf->a2iFaceVert[9][0] = 4;
  pConf->a2iFaceVert[9][1] = 0;
  pConf->a2iFaceVert[9][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 5;
  pConf->a2iCellFace[0][1] = 6;
  pConf->a2iCellFace[0][2] = 0;
  pConf->a2iCellFace[0][3] = 4;
  pConf->a2iCellFace[1][0] = 1;
  pConf->a2iCellFace[1][1] = 4;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[1][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[2][0] = 2;
  pConf->a2iCellFace[2][1] = 5;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[2][3] = NORTH_FACE + 3;
  pConf->a2iCellFace[3][0] = 3;
  pConf->a2iCellFace[3][1] = 6;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 4;
  pConf->a2iCellFace[3][3] = NORTH_FACE + 5;
  pConf->a2iCellFace[4][0] = 8;
  pConf->a2iCellFace[4][1] = 9;
  pConf->a2iCellFace[4][2] = 0;
  pConf->a2iCellFace[4][3] = 7;
  pConf->a2iCellFace[5][0] = 1;
  pConf->a2iCellFace[5][1] = 7;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[6][0] = 2;
  pConf->a2iCellFace[6][1] = 8;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[6][3] = SOUTH_FACE + 3;
  pConf->a2iCellFace[7][0] = 3;
  pConf->a2iCellFace[7][1] = 9;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 4;
  pConf->a2iCellFace[7][3] = SOUTH_FACE + 5;

  //@ Six configs for seven-to-twelve swapping
  aCS[7].iNCanon = 6;
  aCS[7].aConf = new Config[6];
  pConf = aCS[7].aConf;
  //@@ Fan configuration
  pConf->iNPerm = 7;
  pConf->a2iFaceCell = new int[13][2];
  pConf->a2iFaceVert = new int[13][3];
  pConf->a2iCellFace = new int[10][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[ 0][0] = 5;
  pConf->a2iFaceCell[ 0][1] = 0;
  pConf->a2iFaceCell[ 1][0] = 6;
  pConf->a2iFaceCell[ 1][1] = 1;
  pConf->a2iFaceCell[ 2][0] = 7;
  pConf->a2iFaceCell[ 2][1] = 2;
  pConf->a2iFaceCell[ 3][0] = 8;
  pConf->a2iFaceCell[ 3][1] = 3;
  pConf->a2iFaceCell[ 4][0] = 9;
  pConf->a2iFaceCell[ 4][1] = 4;
  pConf->a2iFaceCell[ 5][0] = 0;
  pConf->a2iFaceCell[ 5][1] = 1;
  pConf->a2iFaceCell[ 6][0] = 1;
  pConf->a2iFaceCell[ 6][1] = 2;
  pConf->a2iFaceCell[ 7][0] = 2;
  pConf->a2iFaceCell[ 7][1] = 3;
  pConf->a2iFaceCell[ 8][0] = 3;
  pConf->a2iFaceCell[ 8][1] = 4;
  pConf->a2iFaceCell[ 9][0] = 5;
  pConf->a2iFaceCell[ 9][1] = 6;
  pConf->a2iFaceCell[10][0] = 6;
  pConf->a2iFaceCell[10][1] = 7;
  pConf->a2iFaceCell[11][0] = 7;
  pConf->a2iFaceCell[11][1] = 8;
  pConf->a2iFaceCell[12][0] = 8;
  pConf->a2iFaceCell[12][1] = 9;
  //@@@ Face-vert data
  pConf->a2iFaceVert[ 0][0] = 0;
  pConf->a2iFaceVert[ 0][1] = 1;
  pConf->a2iFaceVert[ 0][2] = 2;
  pConf->a2iFaceVert[ 1][0] = 0;
  pConf->a2iFaceVert[ 1][1] = 2;
  pConf->a2iFaceVert[ 1][2] = 3;
  pConf->a2iFaceVert[ 2][0] = 0;
  pConf->a2iFaceVert[ 2][1] = 3;
  pConf->a2iFaceVert[ 2][2] = 4;
  pConf->a2iFaceVert[ 3][0] = 0;
  pConf->a2iFaceVert[ 3][1] = 4;
  pConf->a2iFaceVert[ 3][2] = 5;
  pConf->a2iFaceVert[ 4][0] = 0;
  pConf->a2iFaceVert[ 4][1] = 5;
  pConf->a2iFaceVert[ 4][2] = 6;
  pConf->a2iFaceVert[ 5][0] = 2;
  pConf->a2iFaceVert[ 5][1] = 0;
  pConf->a2iFaceVert[ 5][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 6][0] = 3;
  pConf->a2iFaceVert[ 6][1] = 0;
  pConf->a2iFaceVert[ 6][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 7][0] = 4;
  pConf->a2iFaceVert[ 7][1] = 0;
  pConf->a2iFaceVert[ 7][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 8][0] = 5;
  pConf->a2iFaceVert[ 8][1] = 0;
  pConf->a2iFaceVert[ 8][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 9][0] = 0;
  pConf->a2iFaceVert[ 9][1] = 2;
  pConf->a2iFaceVert[ 9][2] = SOUTH_POLE;
  pConf->a2iFaceVert[10][0] = 0;
  pConf->a2iFaceVert[10][1] = 3;
  pConf->a2iFaceVert[10][2] = SOUTH_POLE;
  pConf->a2iFaceVert[11][0] = 0;
  pConf->a2iFaceVert[11][1] = 4;
  pConf->a2iFaceVert[11][2] = SOUTH_POLE;
  pConf->a2iFaceVert[12][0] = 0;
  pConf->a2iFaceVert[12][1] = 5;
  pConf->a2iFaceVert[12][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 5;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 5;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 7;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 7;
  pConf->a2iCellFace[3][1] = 8;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 4;
  pConf->a2iCellFace[3][3] = 3;
  pConf->a2iCellFace[4][0] = 4;
  pConf->a2iCellFace[4][1] = 8;
  pConf->a2iCellFace[4][2] = NORTH_FACE + 5;
  pConf->a2iCellFace[4][3] = NORTH_FACE + 6;
  pConf->a2iCellFace[5][0] = 0;
  pConf->a2iCellFace[5][1] = 9;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[6][0] = 9;
  pConf->a2iCellFace[6][1] = 10;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[6][3] = 1;
  pConf->a2iCellFace[7][0] = 10;
  pConf->a2iCellFace[7][1] = 11;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[7][3] = 2;
  pConf->a2iCellFace[8][0] = 11;
  pConf->a2iCellFace[8][1] = 12;
  pConf->a2iCellFace[8][2] = SOUTH_FACE + 4;
  pConf->a2iCellFace[8][3] = 3;
  pConf->a2iCellFace[9][0] = 4;
  pConf->a2iCellFace[9][1] = 12;
  pConf->a2iCellFace[9][2] = SOUTH_FACE + 5;
  pConf->a2iCellFace[9][3] = SOUTH_FACE + 6;

  //@@ Zig-zag configuration
  pConf++;
  pConf->iNPerm = 7;
  pConf->a2iFaceCell = new int[13][2];
  pConf->a2iFaceVert = new int[13][3];
  pConf->a2iCellFace = new int[10][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[ 0][0] = 5;
  pConf->a2iFaceCell[ 0][1] = 0;
  pConf->a2iFaceCell[ 1][0] = 6;
  pConf->a2iFaceCell[ 1][1] = 1;
  pConf->a2iFaceCell[ 2][0] = 7;
  pConf->a2iFaceCell[ 2][1] = 2;
  pConf->a2iFaceCell[ 3][0] = 8;
  pConf->a2iFaceCell[ 3][1] = 3;
  pConf->a2iFaceCell[ 4][0] = 9;
  pConf->a2iFaceCell[ 4][1] = 4;
  pConf->a2iFaceCell[ 5][0] = 0;
  pConf->a2iFaceCell[ 5][1] = 1;
  pConf->a2iFaceCell[ 6][0] = 1;
  pConf->a2iFaceCell[ 6][1] = 2;
  pConf->a2iFaceCell[ 7][0] = 2;
  pConf->a2iFaceCell[ 7][1] = 3;
  pConf->a2iFaceCell[ 8][0] = 3;
  pConf->a2iFaceCell[ 8][1] = 4;
  pConf->a2iFaceCell[ 9][0] = 5;
  pConf->a2iFaceCell[ 9][1] = 6;
  pConf->a2iFaceCell[10][0] = 6;
  pConf->a2iFaceCell[10][1] = 7;
  pConf->a2iFaceCell[11][0] = 7;
  pConf->a2iFaceCell[11][1] = 8;
  pConf->a2iFaceCell[12][0] = 8;
  pConf->a2iFaceCell[12][1] = 9;
  //@@@ Face-vert data
  pConf->a2iFaceVert[ 0][0] = 0;
  pConf->a2iFaceVert[ 0][1] = 1;
  pConf->a2iFaceVert[ 0][2] = 2;
  pConf->a2iFaceVert[ 1][0] = 0;
  pConf->a2iFaceVert[ 1][1] = 2;
  pConf->a2iFaceVert[ 1][2] = 6;
  pConf->a2iFaceVert[ 2][0] = 2;
  pConf->a2iFaceVert[ 2][1] = 3;
  pConf->a2iFaceVert[ 2][2] = 6;
  pConf->a2iFaceVert[ 3][0] = 3;
  pConf->a2iFaceVert[ 3][1] = 5;
  pConf->a2iFaceVert[ 3][2] = 6;
  pConf->a2iFaceVert[ 4][0] = 3;
  pConf->a2iFaceVert[ 4][1] = 4;
  pConf->a2iFaceVert[ 4][2] = 5;
  pConf->a2iFaceVert[ 5][0] = 2;
  pConf->a2iFaceVert[ 5][1] = 0;
  pConf->a2iFaceVert[ 5][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 6][0] = 2;
  pConf->a2iFaceVert[ 6][1] = 6;
  pConf->a2iFaceVert[ 6][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 7][0] = 3;
  pConf->a2iFaceVert[ 7][1] = 6;
  pConf->a2iFaceVert[ 7][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 8][0] = 3;
  pConf->a2iFaceVert[ 8][1] = 5;
  pConf->a2iFaceVert[ 8][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 9][0] = 0;
  pConf->a2iFaceVert[ 9][1] = 2;
  pConf->a2iFaceVert[ 9][2] = SOUTH_POLE;
  pConf->a2iFaceVert[10][0] = 6;
  pConf->a2iFaceVert[10][1] = 2;
  pConf->a2iFaceVert[10][2] = SOUTH_POLE;
  pConf->a2iFaceVert[11][0] = 6;
  pConf->a2iFaceVert[11][1] = 3;
  pConf->a2iFaceVert[11][2] = SOUTH_POLE;
  pConf->a2iFaceVert[12][0] = 5;
  pConf->a2iFaceVert[12][1] = 3;
  pConf->a2iFaceVert[12][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 5;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 5;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 6;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 7;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 7;
  pConf->a2iCellFace[3][1] = 8;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 5;
  pConf->a2iCellFace[3][3] = 3;
  pConf->a2iCellFace[4][0] = 4;
  pConf->a2iCellFace[4][1] = 8;
  pConf->a2iCellFace[4][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[4][3] = NORTH_FACE + 4;
  pConf->a2iCellFace[5][0] = 0;
  pConf->a2iCellFace[5][1] = 9;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[6][0] = 9;
  pConf->a2iCellFace[6][1] = 10;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 6;
  pConf->a2iCellFace[6][3] = 1;
  pConf->a2iCellFace[7][0] = 10;
  pConf->a2iCellFace[7][1] = 11;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[7][3] = 2;
  pConf->a2iCellFace[8][0] = 11;
  pConf->a2iCellFace[8][1] = 12;
  pConf->a2iCellFace[8][2] = SOUTH_FACE + 5;
  pConf->a2iCellFace[8][3] = 3;
  pConf->a2iCellFace[9][0] = 4;
  pConf->a2iCellFace[9][1] = 12;
  pConf->a2iCellFace[9][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[9][3] = SOUTH_FACE + 4;

  //@@ Zig-fan configuration
  pConf++;
  pConf->iNPerm = 7;
  pConf->a2iFaceCell = new int[13][2];
  pConf->a2iFaceVert = new int[13][3];
  pConf->a2iCellFace = new int[10][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[ 0][0] = 5;
  pConf->a2iFaceCell[ 0][1] = 0;
  pConf->a2iFaceCell[ 1][0] = 6;
  pConf->a2iFaceCell[ 1][1] = 1;
  pConf->a2iFaceCell[ 2][0] = 7;
  pConf->a2iFaceCell[ 2][1] = 2;
  pConf->a2iFaceCell[ 3][0] = 8;
  pConf->a2iFaceCell[ 3][1] = 3;
  pConf->a2iFaceCell[ 4][0] = 9;
  pConf->a2iFaceCell[ 4][1] = 4;
  pConf->a2iFaceCell[ 5][0] = 0;
  pConf->a2iFaceCell[ 5][1] = 1;
  pConf->a2iFaceCell[ 6][0] = 1;
  pConf->a2iFaceCell[ 6][1] = 2;
  pConf->a2iFaceCell[ 7][0] = 2;
  pConf->a2iFaceCell[ 7][1] = 3;
  pConf->a2iFaceCell[ 8][0] = 3;
  pConf->a2iFaceCell[ 8][1] = 4;
  pConf->a2iFaceCell[ 9][0] = 5;
  pConf->a2iFaceCell[ 9][1] = 6;
  pConf->a2iFaceCell[10][0] = 6;
  pConf->a2iFaceCell[10][1] = 7;
  pConf->a2iFaceCell[11][0] = 7;
  pConf->a2iFaceCell[11][1] = 8;
  pConf->a2iFaceCell[12][0] = 8;
  pConf->a2iFaceCell[12][1] = 9;
  //@@@ Face-vert data
  pConf->a2iFaceVert[ 0][0] = 1;
  pConf->a2iFaceVert[ 0][1] = 2;
  pConf->a2iFaceVert[ 0][2] = 3;
  pConf->a2iFaceVert[ 1][0] = 0;
  pConf->a2iFaceVert[ 1][1] = 1;
  pConf->a2iFaceVert[ 1][2] = 3;
  pConf->a2iFaceVert[ 2][0] = 0;
  pConf->a2iFaceVert[ 2][1] = 3;
  pConf->a2iFaceVert[ 2][2] = 4;
  pConf->a2iFaceVert[ 3][0] = 0;
  pConf->a2iFaceVert[ 3][1] = 4;
  pConf->a2iFaceVert[ 3][2] = 5;
  pConf->a2iFaceVert[ 4][0] = 0;
  pConf->a2iFaceVert[ 4][1] = 5;
  pConf->a2iFaceVert[ 4][2] = 6;
  pConf->a2iFaceVert[ 5][0] = 3;
  pConf->a2iFaceVert[ 5][1] = 1;
  pConf->a2iFaceVert[ 5][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 6][0] = 3;
  pConf->a2iFaceVert[ 6][1] = 0;
  pConf->a2iFaceVert[ 6][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 7][0] = 4;
  pConf->a2iFaceVert[ 7][1] = 0;
  pConf->a2iFaceVert[ 7][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 8][0] = 5;
  pConf->a2iFaceVert[ 8][1] = 0;
  pConf->a2iFaceVert[ 8][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 9][0] = 1;
  pConf->a2iFaceVert[ 9][1] = 3;
  pConf->a2iFaceVert[ 9][2] = SOUTH_POLE;
  pConf->a2iFaceVert[10][0] = 0;
  pConf->a2iFaceVert[10][1] = 3;
  pConf->a2iFaceVert[10][2] = SOUTH_POLE;
  pConf->a2iFaceVert[11][0] = 0;
  pConf->a2iFaceVert[11][1] = 4;
  pConf->a2iFaceVert[11][2] = SOUTH_POLE;
  pConf->a2iFaceVert[12][0] = 0;
  pConf->a2iFaceVert[12][1] = 5;
  pConf->a2iFaceVert[12][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 5;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 1;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][0] = 5;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 7;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 7;
  pConf->a2iCellFace[3][1] = 8;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 4;
  pConf->a2iCellFace[3][3] = 3;
  pConf->a2iCellFace[4][0] = 4;
  pConf->a2iCellFace[4][1] = 8;
  pConf->a2iCellFace[4][2] = NORTH_FACE + 5;
  pConf->a2iCellFace[4][3] = NORTH_FACE + 6;
  pConf->a2iCellFace[5][0] = 0;
  pConf->a2iCellFace[5][1] = 9;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 1;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 2;
  pConf->a2iCellFace[6][0] = 9;
  pConf->a2iCellFace[6][1] = 10;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[6][3] = 1;
  pConf->a2iCellFace[7][0] = 10;
  pConf->a2iCellFace[7][1] = 11;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[7][3] = 2;
  pConf->a2iCellFace[8][0] = 11;
  pConf->a2iCellFace[8][1] = 12;
  pConf->a2iCellFace[8][2] = SOUTH_FACE + 4;
  pConf->a2iCellFace[8][3] = 3;
  pConf->a2iCellFace[9][0] = 4;
  pConf->a2iCellFace[9][1] = 12;
  pConf->a2iCellFace[9][2] = SOUTH_FACE + 5;
  pConf->a2iCellFace[9][3] = SOUTH_FACE + 6;
  
  //@@ Fan-zig configuration
  pConf++;
  pConf->iNPerm = 7;
  pConf->a2iFaceCell = new int[13][2];
  pConf->a2iFaceVert = new int[13][3];
  pConf->a2iCellFace = new int[10][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[ 0][0] = 5;
  pConf->a2iFaceCell[ 0][1] = 0;
  pConf->a2iFaceCell[ 1][0] = 6;
  pConf->a2iFaceCell[ 1][1] = 1;
  pConf->a2iFaceCell[ 2][0] = 7;
  pConf->a2iFaceCell[ 2][1] = 2;
  pConf->a2iFaceCell[ 3][0] = 8;
  pConf->a2iFaceCell[ 3][1] = 3;
  pConf->a2iFaceCell[ 4][0] = 9;
  pConf->a2iFaceCell[ 4][1] = 4;
  pConf->a2iFaceCell[ 5][0] = 0;
  pConf->a2iFaceCell[ 5][1] = 1;
  pConf->a2iFaceCell[ 6][0] = 1;
  pConf->a2iFaceCell[ 6][1] = 2;
  pConf->a2iFaceCell[ 7][0] = 2;
  pConf->a2iFaceCell[ 7][1] = 3;
  pConf->a2iFaceCell[ 8][0] = 3;
  pConf->a2iFaceCell[ 8][1] = 4;
  pConf->a2iFaceCell[ 9][0] = 5;
  pConf->a2iFaceCell[ 9][1] = 6;
  pConf->a2iFaceCell[10][0] = 6;
  pConf->a2iFaceCell[10][1] = 7;
  pConf->a2iFaceCell[11][0] = 7;
  pConf->a2iFaceCell[11][1] = 8;
  pConf->a2iFaceCell[12][0] = 8;
  pConf->a2iFaceCell[12][1] = 9;
  //@@@ Face-vert data
  pConf->a2iFaceVert[ 0][0] = 0;
  pConf->a2iFaceVert[ 0][1] = 1;
  pConf->a2iFaceVert[ 0][2] = 2;
  pConf->a2iFaceVert[ 1][0] = 0;
  pConf->a2iFaceVert[ 1][1] = 2;
  pConf->a2iFaceVert[ 1][2] = 3;
  pConf->a2iFaceVert[ 2][0] = 0;
  pConf->a2iFaceVert[ 2][1] = 3;
  pConf->a2iFaceVert[ 2][2] = 4;
  pConf->a2iFaceVert[ 3][0] = 0;
  pConf->a2iFaceVert[ 3][1] = 4;
  pConf->a2iFaceVert[ 3][2] = 6;
  pConf->a2iFaceVert[ 4][0] = 4;
  pConf->a2iFaceVert[ 4][1] = 5;
  pConf->a2iFaceVert[ 4][2] = 6;
  pConf->a2iFaceVert[ 5][0] = 2;
  pConf->a2iFaceVert[ 5][1] = 0;
  pConf->a2iFaceVert[ 5][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 6][0] = 3;
  pConf->a2iFaceVert[ 6][1] = 0;
  pConf->a2iFaceVert[ 6][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 7][0] = 4;
  pConf->a2iFaceVert[ 7][1] = 0;
  pConf->a2iFaceVert[ 7][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 8][0] = 4;
  pConf->a2iFaceVert[ 8][1] = 6;
  pConf->a2iFaceVert[ 8][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 9][0] = 0;
  pConf->a2iFaceVert[ 9][1] = 2;
  pConf->a2iFaceVert[ 9][2] = SOUTH_POLE;
  pConf->a2iFaceVert[10][0] = 0;
  pConf->a2iFaceVert[10][1] = 3;
  pConf->a2iFaceVert[10][2] = SOUTH_POLE;
  pConf->a2iFaceVert[11][0] = 0;
  pConf->a2iFaceVert[11][1] = 4;
  pConf->a2iFaceVert[11][2] = SOUTH_POLE;
  pConf->a2iFaceVert[12][0] = 6;
  pConf->a2iFaceVert[12][1] = 4;
  pConf->a2iFaceVert[12][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 5;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 5;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 7;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 7;
  pConf->a2iCellFace[3][1] = 8;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 6;
  pConf->a2iCellFace[3][3] = 3;
  pConf->a2iCellFace[4][0] = 4;
  pConf->a2iCellFace[4][1] = 8;
  pConf->a2iCellFace[4][2] = NORTH_FACE + 4;
  pConf->a2iCellFace[4][3] = NORTH_FACE + 5;
  pConf->a2iCellFace[5][0] = 0;
  pConf->a2iCellFace[5][1] = 9;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[6][0] = 9;
  pConf->a2iCellFace[6][1] = 10;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[6][3] = 1;
  pConf->a2iCellFace[7][0] = 10;
  pConf->a2iCellFace[7][1] = 11;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[7][3] = 2;
  pConf->a2iCellFace[8][0] = 11;
  pConf->a2iCellFace[8][1] = 12;
  pConf->a2iCellFace[8][2] = SOUTH_FACE + 6;
  pConf->a2iCellFace[8][3] = 3;
  pConf->a2iCellFace[9][0] = 4;
  pConf->a2iCellFace[9][1] = 12;
  pConf->a2iCellFace[9][2] = SOUTH_FACE + 4;
  pConf->a2iCellFace[9][3] = SOUTH_FACE + 5;

  //@@ Fan-tri configuration
  pConf++;
  pConf->iNPerm = 7;
  pConf->a2iFaceCell = new int[13][2];
  pConf->a2iFaceVert = new int[13][3];
  pConf->a2iCellFace = new int[10][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[ 0][0] = 5;
  pConf->a2iFaceCell[ 0][1] = 0;
  pConf->a2iFaceCell[ 1][0] = 6;
  pConf->a2iFaceCell[ 1][1] = 1;
  pConf->a2iFaceCell[ 2][0] = 7;
  pConf->a2iFaceCell[ 2][1] = 2;
  pConf->a2iFaceCell[ 3][0] = 8;
  pConf->a2iFaceCell[ 3][1] = 3;
  pConf->a2iFaceCell[ 4][0] = 9;
  pConf->a2iFaceCell[ 4][1] = 4;
  pConf->a2iFaceCell[ 5][0] = 0;
  pConf->a2iFaceCell[ 5][1] = 1;
  pConf->a2iFaceCell[ 6][0] = 1;
  pConf->a2iFaceCell[ 6][1] = 2;
  pConf->a2iFaceCell[ 7][0] = 2;
  pConf->a2iFaceCell[ 7][1] = 3;
  pConf->a2iFaceCell[ 8][0] = 2;
  pConf->a2iFaceCell[ 8][1] = 4;
  pConf->a2iFaceCell[ 9][0] = 5;
  pConf->a2iFaceCell[ 9][1] = 6;
  pConf->a2iFaceCell[10][0] = 6;
  pConf->a2iFaceCell[10][1] = 7;
  pConf->a2iFaceCell[11][0] = 7;
  pConf->a2iFaceCell[11][1] = 8;
  pConf->a2iFaceCell[12][0] = 7;
  pConf->a2iFaceCell[12][1] = 9;
  //@@@ Face-vert data
  pConf->a2iFaceVert[ 0][0] = 0;
  pConf->a2iFaceVert[ 0][1] = 1;
  pConf->a2iFaceVert[ 0][2] = 2;
  pConf->a2iFaceVert[ 1][0] = 0;
  pConf->a2iFaceVert[ 1][1] = 2;
  pConf->a2iFaceVert[ 1][2] = 3;
  pConf->a2iFaceVert[ 2][0] = 0;
  pConf->a2iFaceVert[ 2][1] = 3;
  pConf->a2iFaceVert[ 2][2] = 5;
  pConf->a2iFaceVert[ 3][0] = 0;
  pConf->a2iFaceVert[ 3][1] = 5;
  pConf->a2iFaceVert[ 3][2] = 6;
  pConf->a2iFaceVert[ 4][0] = 3;
  pConf->a2iFaceVert[ 4][1] = 4;
  pConf->a2iFaceVert[ 4][2] = 5;
  pConf->a2iFaceVert[ 5][0] = 2;
  pConf->a2iFaceVert[ 5][1] = 0;
  pConf->a2iFaceVert[ 5][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 6][0] = 3;
  pConf->a2iFaceVert[ 6][1] = 0;
  pConf->a2iFaceVert[ 6][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 7][0] = 5;
  pConf->a2iFaceVert[ 7][1] = 0;
  pConf->a2iFaceVert[ 7][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 8][0] = 3;
  pConf->a2iFaceVert[ 8][1] = 5;
  pConf->a2iFaceVert[ 8][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 9][0] = 0;
  pConf->a2iFaceVert[ 9][1] = 2;
  pConf->a2iFaceVert[ 9][2] = SOUTH_POLE;
  pConf->a2iFaceVert[10][0] = 0;
  pConf->a2iFaceVert[10][1] = 3;
  pConf->a2iFaceVert[10][2] = SOUTH_POLE;
  pConf->a2iFaceVert[11][0] = 0;
  pConf->a2iFaceVert[11][1] = 5;
  pConf->a2iFaceVert[11][2] = SOUTH_POLE;
  pConf->a2iFaceVert[12][0] = 5;
  pConf->a2iFaceVert[12][1] = 3;
  pConf->a2iFaceVert[12][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 5;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 5;
  pConf->a2iCellFace[1][1] = 6;
  pConf->a2iCellFace[1][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[1][3] = 1;
  pConf->a2iCellFace[2][0] = 7;
  pConf->a2iCellFace[2][1] = 8;
  pConf->a2iCellFace[2][2] = 2;
  pConf->a2iCellFace[2][3] = 6;
  pConf->a2iCellFace[3][0] = 3;
  pConf->a2iCellFace[3][1] = 7;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 5;
  pConf->a2iCellFace[3][3] = NORTH_FACE + 6;
  pConf->a2iCellFace[4][0] = 4;
  pConf->a2iCellFace[4][1] = 8;
  pConf->a2iCellFace[4][2] = NORTH_FACE + 3;
  pConf->a2iCellFace[4][3] = NORTH_FACE + 4;
  pConf->a2iCellFace[5][0] = 0;
  pConf->a2iCellFace[5][1] = 9;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[6][0] = 9;
  pConf->a2iCellFace[6][1] = 10;
  pConf->a2iCellFace[6][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[6][3] = 1;
  pConf->a2iCellFace[7][0] = 11;
  pConf->a2iCellFace[7][1] = 12;
  pConf->a2iCellFace[7][2] = 2;
  pConf->a2iCellFace[7][3] = 10;
  pConf->a2iCellFace[8][0] = 3;
  pConf->a2iCellFace[8][1] = 11;
  pConf->a2iCellFace[8][2] = SOUTH_FACE + 5;
  pConf->a2iCellFace[8][3] = SOUTH_FACE + 6;
  pConf->a2iCellFace[9][0] = 4;
  pConf->a2iCellFace[9][1] = 12;
  pConf->a2iCellFace[9][2] = SOUTH_FACE + 3;
  pConf->a2iCellFace[9][3] = SOUTH_FACE + 4;

  //@@ Fan-tri configuration
  pConf++;
  pConf->iNPerm = 7;
  pConf->a2iFaceCell = new int[13][2];
  pConf->a2iFaceVert = new int[13][3];
  pConf->a2iCellFace = new int[10][4];
  //@@@ Face-cell data
  pConf->a2iFaceCell[ 0][0] = 5;
  pConf->a2iFaceCell[ 0][1] = 0;
  pConf->a2iFaceCell[ 1][0] = 6;
  pConf->a2iFaceCell[ 1][1] = 1;
  pConf->a2iFaceCell[ 2][0] = 7;
  pConf->a2iFaceCell[ 2][1] = 2;
  pConf->a2iFaceCell[ 3][0] = 8;
  pConf->a2iFaceCell[ 3][1] = 3;
  pConf->a2iFaceCell[ 4][0] = 9;
  pConf->a2iFaceCell[ 4][1] = 4;
  pConf->a2iFaceCell[ 5][0] = 0;
  pConf->a2iFaceCell[ 5][1] = 1;
  pConf->a2iFaceCell[ 6][0] = 1;
  pConf->a2iFaceCell[ 6][1] = 2;
  pConf->a2iFaceCell[ 7][0] = 2;
  pConf->a2iFaceCell[ 7][1] = 3;
  pConf->a2iFaceCell[ 8][0] = 1;
  pConf->a2iFaceCell[ 8][1] = 4;
  pConf->a2iFaceCell[ 9][0] = 5;
  pConf->a2iFaceCell[ 9][1] = 6;
  pConf->a2iFaceCell[10][0] = 6;
  pConf->a2iFaceCell[10][1] = 7;
  pConf->a2iFaceCell[11][0] = 7;
  pConf->a2iFaceCell[11][1] = 8;
  pConf->a2iFaceCell[12][0] = 6;
  pConf->a2iFaceCell[12][1] = 9;
  //@@@ Face-vert data
  pConf->a2iFaceVert[ 0][0] = 0;
  pConf->a2iFaceVert[ 0][1] = 1;
  pConf->a2iFaceVert[ 0][2] = 2;
  pConf->a2iFaceVert[ 1][0] = 0;
  pConf->a2iFaceVert[ 1][1] = 2;
  pConf->a2iFaceVert[ 1][2] = 4;
  pConf->a2iFaceVert[ 2][0] = 0;
  pConf->a2iFaceVert[ 2][1] = 4;
  pConf->a2iFaceVert[ 2][2] = 5;
  pConf->a2iFaceVert[ 3][0] = 0;
  pConf->a2iFaceVert[ 3][1] = 5;
  pConf->a2iFaceVert[ 3][2] = 6;
  pConf->a2iFaceVert[ 4][0] = 2;
  pConf->a2iFaceVert[ 4][1] = 3;
  pConf->a2iFaceVert[ 4][2] = 4;
  pConf->a2iFaceVert[ 5][0] = 2;
  pConf->a2iFaceVert[ 5][1] = 0;
  pConf->a2iFaceVert[ 5][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 6][0] = 4;
  pConf->a2iFaceVert[ 6][1] = 0;
  pConf->a2iFaceVert[ 6][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 7][0] = 5;
  pConf->a2iFaceVert[ 7][1] = 0;
  pConf->a2iFaceVert[ 7][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 8][0] = 2;
  pConf->a2iFaceVert[ 8][1] = 4;
  pConf->a2iFaceVert[ 8][2] = NORTH_POLE;
  pConf->a2iFaceVert[ 9][0] = 0;
  pConf->a2iFaceVert[ 9][1] = 2;
  pConf->a2iFaceVert[ 9][2] = SOUTH_POLE;
  pConf->a2iFaceVert[10][0] = 0;
  pConf->a2iFaceVert[10][1] = 4;
  pConf->a2iFaceVert[10][2] = SOUTH_POLE;
  pConf->a2iFaceVert[11][0] = 0;
  pConf->a2iFaceVert[11][1] = 5;
  pConf->a2iFaceVert[11][2] = SOUTH_POLE;
  pConf->a2iFaceVert[12][0] = 4;
  pConf->a2iFaceVert[12][1] = 2;
  pConf->a2iFaceVert[12][2] = SOUTH_POLE;
  //@@@ Cell-face data
  pConf->a2iCellFace[0][0] = 0;
  pConf->a2iCellFace[0][1] = 5;
  pConf->a2iCellFace[0][2] = NORTH_FACE + 0;
  pConf->a2iCellFace[0][3] = NORTH_FACE + 1;
  pConf->a2iCellFace[1][0] = 6;
  pConf->a2iCellFace[1][1] = 8;
  pConf->a2iCellFace[1][2] = 1;
  pConf->a2iCellFace[1][3] = 5;
  pConf->a2iCellFace[2][0] = 6;
  pConf->a2iCellFace[2][1] = 7;
  pConf->a2iCellFace[2][2] = NORTH_FACE + 4;
  pConf->a2iCellFace[2][3] = 2;
  pConf->a2iCellFace[3][0] = 3;
  pConf->a2iCellFace[3][1] = 7;
  pConf->a2iCellFace[3][2] = NORTH_FACE + 5;
  pConf->a2iCellFace[3][3] = NORTH_FACE + 6;
  pConf->a2iCellFace[4][0] = 4;
  pConf->a2iCellFace[4][1] = 8;
  pConf->a2iCellFace[4][2] = NORTH_FACE + 2;
  pConf->a2iCellFace[4][3] = NORTH_FACE + 3;
  pConf->a2iCellFace[5][0] = 0;
  pConf->a2iCellFace[5][1] = 9;
  pConf->a2iCellFace[5][2] = SOUTH_FACE + 0;
  pConf->a2iCellFace[5][3] = SOUTH_FACE + 1;
  pConf->a2iCellFace[6][0] = 10;
  pConf->a2iCellFace[6][1] = 12;
  pConf->a2iCellFace[6][2] = 1;
  pConf->a2iCellFace[6][3] = 9;
  pConf->a2iCellFace[7][0] = 10;
  pConf->a2iCellFace[7][1] = 11;
  pConf->a2iCellFace[7][2] = SOUTH_FACE + 4;
  pConf->a2iCellFace[7][3] = 2; 
  pConf->a2iCellFace[8][0] = 3;
  pConf->a2iCellFace[8][1] = 11;
  pConf->a2iCellFace[8][2] = SOUTH_FACE + 5;
  pConf->a2iCellFace[8][3] = SOUTH_FACE + 6;
  pConf->a2iCellFace[9][0] = 4;
  pConf->a2iCellFace[9][1] = 12;
  pConf->a2iCellFace[9][2] = SOUTH_FACE + 2;
  pConf->a2iCellFace[9][3] = SOUTH_FACE + 3;

// Check to be sure that vertex index increases around each face
#ifndef NDEBUG
  for (int iOrig = 4; iOrig <=7; iOrig++)
    for (int iConf = 0; iConf < aCS[iOrig].iNCanon; iConf++)
      for (int iTri = 0; iTri < iOrig-2; iTri++) 
        assert((aCS[iOrig].aConf[iConf].a2iFaceVert[iTri][0] <
		aCS[iOrig].aConf[iConf].a2iFaceVert[iTri][1]) &&
	       (aCS[iOrig].aConf[iConf].a2iFaceVert[iTri][1] <
		aCS[iOrig].aConf[iConf].a2iFaceVert[iTri][2]));
#endif

  qCSInit = true;
}
