_maxgens := [];
_gps := [];

for i in [2 .. 7] do _maxgens[i] := []; _gps[i] := []; end for;

_maxgens[2][2] := [
    [],

    [[1,0,-1,-1],
    [0,1,-1,-1]]
];

_gps[2][2] := [
    \[2,2,1,3,0,2,1,0,1],
    \[2,2,2,6,0,2,2,1,0,0,1]
];

_maxgens[2][3] := [
    [[0,1,1,0],
    [2,0,0,1],
    [1,0,0,2]],

    [[1,0,-1,-1],
    [0,1,-2,-1]],

    [[1,2,0,2],
    [1,2,0,1],
    [0,-1,1,0],
    [1,1,1,-1],
    [2,0,0,2]]
];

_gps[2][3] := [
    \[2,3,1,4,1,2,1,0,2],
    \[2,3,2,8,1,1,3,1,0,0,0,1,0,0,0,1],
    \[2,3,3,8,0,2,2,1,1,0,2],
    \[2,3,4,8,0,2,1,0,1],
    \[2,3,5,16,0,2,2,1,0,0,1],
    \[2,3,6,24,0,3,3,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,3,7,48,0,3,4,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]
];

_maxgens[2][5] := [
    [[0,1,1,0],
    [2,0,0,1],
    [1,0,0,2]],

    [[1,0,-1,-1],
    [0,1,-2,-1]],

    [],

    [[1,4,4,4],
    [3,4,3,1],
    [0,2,2,0],
    [2,0,0,-2],
    [2,0,0,2]]
];

_gps[2][5] := [
    \[2,5,1,3,0,2,1,0,8],
    \[2,5,2,6,0,2,2,1,0,0,8],
    \[2,5,3,6,0,2,1,0,4],
    \[2,5,4,8,1,1,2,1,2,0,0,1,-1],
    \[2,5,5,8,1,1,2,1,0,0,0,1,-1],
    \[2,5,6,8,1,2,1,0,3],
    \[2,5,7,12,0,2,2,1,0,0,4],
    \[2,5,8,12,0,2,2,1,2,0,4],
    \[2,5,9,12,0,2,1,0,2],
    \[2,5,10,16,1,1,3,1,1,0,0,1,-1,0,1,1],
    \[2,5,11,16,1,1,3,1,0,0,0,1,-1,0,1,1],
    \[2,5,12,24,0,2,2,1,1,0,2],
    \[2,5,13,24,0,2,2,1,0,0,2],
    \[2,5,14,24,0,2,1,0,1],
    \[2,5,15,24,0,4,3,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,5,16,32,1,1,3,1,0,0,0,1,0,0,0,1],
    \[2,5,17,48,0,2,2,1,0,0,1],
    \[2,5,18,48,0,4,4,2,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,5,19,96,0,4,4,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]
];

_maxgens[2][7] := [
    [[0,1,1,0],
    [3,0,0,1],
    [1,0,0,3]],

    [[1,0,-1,-1],
    [0,1,-3,-1]],

    [[4,1,4,3],
    [6,2,3,0],
    [0,-1,1,0],
    [2,3,3,-2],
    [3,0,0,3]]
];

_gps[2][7] := [
    \[2,7,1,4,1,2,1,0,12],
    \[2,7,2,6,1,1,2,1,0,0,0,2,-2],
    \[2,7,3,8,1,1,3,1,0,0,0,3,0,0,0,3],
    \[2,7,4,8,0,2,2,1,3,0,12],
    \[2,7,5,8,0,2,1,0,6],
    \[2,7,6,12,1,1,3,1,3,0,0,3,3,0,2,-2],
    \[2,7,7,12,1,1,3,1,0,0,0,3,3,0,2,-2],
    \[2,7,8,12,1,2,1,0,4],
    \[2,7,9,16,0,2,2,1,0,0,6],
    \[2,7,10,16,0,2,1,0,3],
    \[2,7,11,16,0,2,2,1,3,0,6],
    \[2,7,12,18,1,1,3,1,0,0,0,2,-2,0,2,2],
    \[2,7,13,24,1,1,4,1,0,0,0,3,0,0,0,3,0,2,-2],
    \[2,7,14,24,1,1,4,1,0,0,0,3,0,0,0,3,0,2,2],
    \[2,7,15,24,0,2,1,0,2],
    \[2,7,16,24,0,2,2,1,3,0,4],
    \[2,7,17,24,0,3,3,0,1,0,0,2,0,0,1,0,0,0,0,0,1,0],
    \[2,7,18,24,0,3,3,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,7,19,32,0,2,2,1,0,0,3],
    \[2,7,20,36,1,1,4,1,3,0,0,3,3,0,2,-2,0,2,2],
    \[2,7,21,36,1,1,4,1,0,0,0,3,3,0,2,-2,0,2,2],
    \[2,7,22,48,0,2,2,1,3,0,2],
    \[2,7,23,48,0,2,1,0,1],
    \[2,7,24,48,0,2,2,1,0,0,2],
    \[2,7,25,48,0,3,4,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,7,26,72,1,1,5,1,0,0,0,3,0,0,0,3,0,2,-2,0,2,2 ],
    \[2,7,27,72,0,3,4,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,2],
    \[2,7,28,96,0,2,2,1,0,0,1],
    \[2,7,29,144,0,3,5,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,2]
];

_maxgens[3][2] := [
    [],

    [[1,0,0,0,0,1,1,1,1],
    [0,1,0,0,0,1,-1,0,-1]]
];

_gps[3][2] := [
    \[3,2,1,7,0,2,1,0,1],
    \[3,2,2,21,0,2,2,1,0,0,1]
];

_maxgens[3][3] := [
    [[0,1,0,1,0,0,0,0,1],
    [0,1,0,0,0,1,1,0,0],
    [2,0,0,0,1,0,0,0,1],
    [1,0,0,0,2,0,0,0,1],
    [1,0,0,0,1,0,0,0,2]],

    [[1,0,0,2,0,1,3,2,2],
    [0,1,0,0,0,1,-1,0,-2]]
];

_gps[3][3] := [
    \[3,3,1,12,1,1,3,0,1,0,0,0,0,0,1,0,1,0,0,0,1,1 ],
    \[3,3,2,13,0,2,1,0,2],
    \[3,3,3,24,1,1,4,1,0,1,1,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,1],
    \[3,3,4,24,1,1,4,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1],
    \[3,3,5,24,1,1,4,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,1,1],
    \[3,3,6,26,0,2,1,0,1],
    \[3,3,7,39,0,2,2,1,0,0,2],
    \[3,3,8,48,1,1,5,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1],
    \[3,3,9,78,0,2,2,1,0,0,1]
];

_maxgens[3][5] := [
    [[0,1,0,1,0,0,0,0,1],
    [0,1,0,0,0,1,1,0,0],
    [2,0,0,0,1,0,0,0,1],
    [1,0,0,0,2,0,0,0,1],
    [1,0,0,0,1,0,0,0,2]],

    [[1,0,0,3,2,2,6,4,2],
    [0,1,0,0,0,1,-2,0,-1]]
];

_gps[3][5] := [
    \[3,5,1,12,1,1,3,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2],
    \[3,5,2,24,1,1,4,1,0,0,0,0,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2],
    \[3,5,3,24,1,1,4,1,0,2,2,2,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2],
    \[3,5,4,24,1,1,4,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2,0,0,2,2,2],
    \[3,5,5,31,0,2,1,0,4],
    \[3,5,6,48,1,1,4,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2,0,0,1,1,1],
    \[3,5,7,48,1,1,4,1,0,3,3,3,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2],
    \[3,5,8,48,1,1,3,0,1,0,0,0,0,0,1,0,-1,0,0,0,1,-1],
    \[3,5,9,48,1,1,5,1,0,2,2,2,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2,0,0,2,2,2],
    \[3,5,10,62,0,2,1,0,2],
    \[3,5,11,93,0,2,2,1,0,0,4],
    \[3,5,12,96,1,1,5,1,0,2,2,2,0,1,0,0,0,0,0,2,0,-2,0,0,0,2,-2,0,0,1,1,1],
    \[3,5,13,96,1,1,4,0,1,0,0,0,0,0,1,0,-1,0,0,0,1,-1,0,0,2,2,2],
    \[3,5,14,96,1,1,4,1,0,2,2,2,0,1,0,0,0,0,0,1,0,-1,0,0,0,1,-1],
    \[3,5,15,96,1,1,4,1,0,0,0,0,0,1,0,0,0,0,0,1,0,-1,0,0,0,1,-1],
    \[3,5,16,124,0,2,1,0,1],
    \[3,5,17,186,0,2,2,1,0,0,2],
    \[3,5,18,192,1,1,4,1,0,3,3,3,0,1,0,0,0,0,0,1,0,-1,0,0,0,1,-1],
    \[3,5,19,192,1,1,4,0,1,0,0,0,0,0,1,0,-1,0,0,0,1,-1,0,0,1,1,1],
    \[3,5,20,192,1,1,5,1,0,2,2,2,0,1,0,0,0,0,0,1,0,-1,0,0,0,1,-1,0,0,2,2,2],
    \[3,5,21,372,0,2,2,1,0,0,1],
    \[3,5,22,384,1,1,5,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]
];

_maxgens[4][2] := [
    [],

    [[0,0,1,0,0,0,0,1,1,0,0,0,0,1,0,0],
    [1,0,0,0,-1,-1,0,0,0,0,1,0,0,0,0,1],
    [0,1,0,0,-1,-1,0,0,0,0,1,0,0,0,0,1],
    [1,0,0,0,0,1,0,0,0,0,1,0,0,0,-1,-1],
    [1,0,0,0,0,1,0,0,0,0,0,1,0,0,-1,-1]],

    [],

    [],

    [[1,0,0,0,0,0,1,0,1,0,0,1,1,1,1,1],
    [0,1,0,0,0,0,1,0,0,0,0,1,-1,0,0,-1]]
];

_gps[4][2] := [
    \[4,2,1,5,0,5,1,0,3],
    \[4,2,2,10,0,5,2,2,0,0,3],
    \[4,2,3,15,0,5,1,0,1],
    \[4,2,4,18,2,2,3,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1],
    \[4,2,5,20,0,5,2,1,0,0,3],
    \[4,2,6,30,0,5,2,2,0,0,1],
    \[4,2,7,36,2,2,4,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1],
    \[4,2,8,36,2,2,3,1,1,0,0,0,0,0,1,0,0,0,0,0,0,1],
    \[4,2,9,60,0,5,2,1,0,0,1],
    \[4,2,10,72,2,2,5,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]
];

_maxgens[4][3] := [
    [[0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1],
    [0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,1],
    [0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0],
    [0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0],
    [2,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
    [1,0,0,0,0,2,0,0,0,0,1,0,0,0,0,1],
    [1,0,0,0,0,1,0,0,0,0,2,0,0,0,0,1],
    [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,2]],

    [[0,0,1,0,0,0,0,1,1,0,0,0,0,1,0,0],
    [1,0,0,0,-1,-1,0,0,0,0,1,0,0,0,0,1],
    [0,1,0,0,-2,-1,0,0,0,0,1,0,0,0,0,1],
    [1,0,0,0,0,1,0,0,0,0,1,0,0,0,-1,-1],
    [1,0,0,0,0,1,0,0,0,0,0,1,0,0,-2,-1]],

    [[0,0,1,0,0,0,0,1,1,0,0,0,0,1,0,0],
    [1,2,0,0,0,2,0,0,0,0,1,0,0,0,0,1],
    [1,2,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
    [0,2,0,0,1,0,0,0,0,0,1,0,0,0,0,1],
    [1,1,0,0,1,2,0,0,0,0,1,0,0,0,0,1],
    [1,0,0,0,0,1,0,0,0,0,1,2,0,0,0,2],
    [1,0,0,0,0,1,0,0,0,0,1,2,0,0,0,1],
    [1,0,0,0,0,1,0,0,0,0,0,2,0,0,1,0],
    [1,0,0,0,0,1,0,0,0,0,1,1,0,0,1,2]],

    [],

    [[1,0,0,0,0,0,0,1,1,2,1,2,0,2,2,1],
    [0,1,0,0,0,0,1,0,0,0,0,1,-2,0,0,-1]],

    [[1,0,0,0,0,1,0,0,-1,0,-1,0,0,-1,0,-1],
    [0,0,1,0,0,0,0,1,-2,0,-1,0,0,-2,0,-1],
    [1,2,0,0,0,2,0,0,0,0,1,2,0,0,0,2],
    [1,2,0,0,0,1,0,0,0,0,1,2,0,0,0,1],
    [0,2,0,0,1,0,0,0,0,0,0,2,0,0,1,0],
    [1,1,0,0,1,2,0,0,0,0,1,1,0,0,1,2]],

    [[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1],
    [1,0,2,0,0,1,0,2,0,0,2,0,0,0,0,2],
    [1,0,2,0,0,1,0,2,0,0,1,0,0,0,0,1],
    [0,0,2,0,0,0,0,2,1,0,0,0,0,1,0,0],
    [1,0,1,0,0,1,0,1,1,0,2,0,0,1,0,2],
    [1,2,0,0,0,2,0,0,0,0,1,2,0,0,0,2],
    [1,2,0,0,0,1,0,0,0,0,1,2,0,0,0,1],
    [0,2,0,0,1,0,0,0,0,0,0,2,0,0,1,0],
    [1,1,0,0,1,2,0,0,0,0,1,1,0,0,1,2]],

    [[1,3,-3,1,1,1,-1,1,-1,-3,-3,1,-1,-1,-1,1],
    [2,0,2,0,0,1,0,1,2,2,1,1,1,2,2,1],
    [0,0,1,0,0,0,0,1,1,0,0,0,0,1,0,0],
    [1,0,0,0,0,1,0,0,0,0,-1,0,0,0,0,-1],
    [0,2,0,0,1,0,0,0,0,0,0,2,0,0,1,0],
    [1,1,0,0,1,2,0,0,0,0,1,1,0,0,1,2],
    [-1,0,0,0,0,-1,0,0,0,0,-1,0,0,0,0,-1]]
];

_gps[4][3] := [
    \[4,3,1,5,0,5,1,0,64],
    \[4,3,2,10,0,5,2,0,64,2,16],
    \[4,3,3,10,0,5,2,0,64,0,40],
    \[4,3,4,16,1,1,2,1,2,1,1,1,0,0,0,1,2,1,0,1,0,1,1],
    \[4,3,5,16,1,1,2,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,0],
    \[4,3,6,16,1,1,3,0,0,0,1,1,0,1,0,0,0,1,1,0,1,1,0,0,0,1,1,1,1,0,0],
    \[4,3,7,16,2,2,1,1,1,0,1,3],
    \[4,3,8,16,2,2,2,1,0,0,1,1,0,1,7,0,6],
    \[4,3,9,20,0,5,3,0,64,2,16,2,40],
    \[4,3,10,20,0,5,2,2,76,2,12],
    \[4,3,11,20,0,5,2,0,60,0,64],
    \[4,3,12,20,0,5,2,3,44,3,76],
    \[4,3,13,32,1,1,2,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,0],
    \[4,3,14,32,1,1,3,1,1,1,0,0,1,0,1,1,1,1,0,1,1,1,1,1,1,0,0,0,0,1,1],
    \[4,3,15,32,1,1,3,1,0,1,1,1,1,0,1,1,0,1,0,1,0,0,0,1,0,0,1,1,1,0,1],
    \[4,3,16,32,1,1,4,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,1,0],
    \[4,3,17,32,1,1,3,1,0,1,1,1,1,0,1,1,0,1,0,1,0,0,0,0,0,1,1,0,1,1,0],
    \[4,3,18,32,2,2,3,1,1,3,0,6,1,0,6,1,7,1,0,0,1,1],
    \[4,3,19,32,2,2,3,1,0,5,0,1,0,0,5,0,1,1,1,6,1,2],
    \[4,3,20,32,2,2,3,1,0,5,0,1,1,0,7,0,7,1,0,0,0,6],
    \[4,3,21,32,2,2,3,1,1,5,1,7,0,0,3,0,1,1,0,6,0,6],
    \[4,3,22,32,2,2,4,1,0,6,0,6,1,1,7,1,7,1,1,5,1,5,1,0,4,0,0],
    \[4,3,23,32,2,2,3,1,0,5,0,1,1,0,7,0,7,0,0,5,0,1],
    \[4,3,24,32,2,2,2,1,1,0,1,3,1,1,3,1,0],
    \[4,3,25,40,0,5,2,0,70,0,64],
    \[4,3,26,40,0,5,2,3,44,3,52],
    \[4,3,27,40,0,5,2,2,66,2,62],
    \[4,3,28,40,0,5,3,2,76,2,12,0,60],
    \[4,3,29,40,0,5,2,3,39,3,7],
    \[4,3,30,48,2,3,2,1,1,0,1,3,1,0,0,0,1,1,2,0,3,1,2,0,3],
    \[4,3,31,48,2,3,4,1,1,2,1,3,1,2,0,1,0,0,0,0,3,0,0,1,3,0,0,0,1,3,0,0,0,1,0,0,2,0,3,0,1,0,1],
    \[4,3,32,64,1,1,4,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,0,0,0,1,1],
    \[4,3,33,64,1,1,4,1,1,1,0,0,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,1,0,1,1,1],
    \[4,3,34,64,1,1,3,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,0,1,0,0,1,1,1,0,1],
    \[4,3,35,64,1,1,5,1,0,1,0,0,0,1,1,1,0,1,0,1,1,0,0,1,0,1,0,1,1,1,1,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,1],
    \[4,3,36,64,2,2,2,1,1,0,1,3,1,1,0,1,1],
    \[4,3,37,64,2,2,3,1,1,7,0,0,1,0,2,1,5,1,1,5,1,7],
    \[4,3,38,64,2,2,3,1,0,7,0,2,1,0,1,0,0,0,1,4,1,3],
    \[4,3,39,64,2,2,4,1,0,5,0,1,1,0,7,0,7,1,0,0,0,6,0,0,5,0,1],
    \[4,3,40,64,2,2,4,1,1,5,1,7,1,1,3,1,5,1,0,5,0,1,1,1,6,1,0],
    \[4,3,41,64,2,2,3,1,1,0,1,3,1,1,3,1,0,1,0,5,0,1],
    \[4,3,42,64,2,2,4,1,0,5,0,1,1,0,7,0,7,0,0,5,0,1,1,1,6,1,2],
    \[4,3,43,64,2,2,4,1,1,3,0,6,1,0,6,1,7,1,0,0,1,1,0,1,7,0,6],
    \[4,3,44,80,0,5,2,2,27,2,75],
    \[4,3,45,80,0,5,3,2,66,2,62,0,70],
    \[4,3,46,80,0,5,3,3,44,3,52,3,48],
    \[4,3,47,80,0,5,2,0,75,0,64],
    \[4,3,48,80,0,5,2,3,39,3,35],
    \[4,3,49,96,1,1,5,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1],
    \[4,3,50,96,2,3,3,1,0,1,0,3,0,2,1,3,1,0,2,0,1,0,1,0,0,0,1,2,1,3,1,2,1,1],
    \[4,3,51,96,2,3,3,1,1,0,1,0,1,0,1,0,1,1,0,0,3,1,0,0,1,1,1,2,0,3,1,2,0,3],
    \[4,3,52,96,2,3,5,1,1,1,1,3,1,1,1,0,1,1,1,0,3,1,1,0,1,1,1,1,1,2,1,1,1,1,1,1,1,0,2,1,1,0,0,0,0,2,1,2,0,1,0,1],
    \[4,3,53,96,2,3,3,1,0,1,1,0,0,2,1,2,1,0,2,0,3,0,1,0,0,0,1,0,1,0,1,1,1,2],
    \[4,3,54,96,0,6,4,0,3,0,0,1,1,0,3,0,0,0,1,0,3,0,0,1,2,0,0,0,2,1,2],
    \[4,3,55,96,0,6,5,0,0,0,0,1,1,0,0,0,0,1,2,1,3,0,0,0,0,1,1,0,0,0,0,0,0,0,2,1,2],
    \[4,3,56,96,0,6,3,1,3,1,1,1,2,1,1,1,1,1,2,1,3,1,2,0,1],
    \[4,3,57,96,0,6,3,0,3,1,1,0,3,0,3,1,2,1,0,0,3,1,1,0,2],
    \[4,3,58,128,1,1,5,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,0,1,1,0,1,0,1,0,0,1,1,1,0,0,1,0,1,1,1,0,0,0,0,1,1],
    \[4,3,59,128,2,2,5,1,1,5,1,7,1,1,3,1,5,1,0,5,0,1,1,1,6,1,0,1,0,0,0,6],
    \[4,3,60,128,2,2,3,0,0,5,0,1,0,0,7,0,1,1,1,6,0,4],
    \[4,3,61,128,2,2,4,1,1,7,0,0,1,0,2,1,5,1,1,3,0,6,1,0,7,1,2],
    \[4,3,62,128,2,2,2,1,0,7,0,2,1,1,0,1,3],
    \[4,3,63,128,2,2,4,1,0,7,1,2,1,1,0,0,3,1,0,1,1,6,1,1,5,1,7],
    \[4,3,64,128,2,2,4,1,1,6,1,0,1,1,2,1,0,1,0,0,0,6,0,1,1,0,5],
    \[4,3,65,128,2,2,3,1,1,0,1,3,1,1,0,1,1,1,0,5,0,1],
    \[4,3,66,128,2,2,4,1,1,7,0,0,1,0,2,1,5,1,1,3,0,6,1,1,5,1,7],
    \[4,3,67,128,2,2,3,1,1,0,1,3,1,1,0,1,1,1,1,5,1,7],
    \[4,3,68,160,0,5,4,2,66,2,62,0,70,3,50],
    \[4,3,69,160,0,5,3,3,39,3,35,3,21],
    \[4,3,70,160,0,5,3,2,27,2,75,0,75],
    \[4,3,71,160,0,8,5,0,0,0,0,1,0,1,0,0,0,1,1,0,0,0,0,1,0,1,1,1,0,0,0,0,1,1,0,0,4,0,0,0,1,0],
    \[4,3,72,192,1,1,4,0,0,0,1,0,1,1,1,0,0,1,1,0,1,1,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,0,1],
    \[4,3,73,192,1,1,3,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,0,1,2,1,1,1,0,0,0],
    \[4,3,74,192,1,1,3,1,1,1,0,0,1,0,1,1,1,1,0,1,1,1,1,1,2,1,1,1,1,1,1],
    \[4,3,75,192,2,3,4,1,0,2,1,1,0,1,0,1,1,0,2,1,1,0,1,0,3,1,0,1,1,0,0,2,1,2,0,1,0,1,0,1,1,1,0],
    \[4,3,76,192,0,6,4,1,2,1,1,1,2,1,0,1,1,1,0,1,2,1,2,0,1,0,3,1,1,0,3],
    \[4,3,77,192,0,6,4,1,3,1,1,1,2,1,1,1,1,1,2,1,3,1,2,0,1,0,3,1,1,0,3],
    \[4,3,78,192,0,6,4,1,3,1,1,1,2,1,1,1,1,1,2,1,3,1,2,0,1,1,2,1,1,1,2],
    \[4,3,79,192,0,6,5,0,3,0,0,1,1,0,3,0,0,0,1,0,3,0,0,1,2,1,2,0,0,1,1,0,0,0,2,1,2],
    \[4,3,80,192,0,6,4,0,3,1,1,0,3,0,3,1,2,1,0,0,3,1,1,0,2,0,2,1,1,1,2],
    \[4,3,81,192,0,6,4,1,3,1,1,1,2,1,1,1,1,1,2,1,3,1,2,0,1,0,2,1,1,1,2],
    \[4,3,82,256,2,2,5,1,1,7,0,0,1,0,2,1,5,1,1,3,0,6,1,0,7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0,54,0,42],
    \[6,2,5,27,2,3,2,0,2,0,0,0,0,0,1,0,2,0,0,0,1,0,0],
    \[6,2,6,27,2,3,3,0,2,0,2,1,2,1,1,0,2,0,1,1,1,1,2,0,2,0,2,1,0,1,2],
    \[6,2,7,42,3,6,3,0,0,6,0,2,0,1,1,1,1,1,2,5,1,4],
    \[6,2,8,42,0,8,3,0,54,0,42,3,14],
    \[6,2,9,54,2,3,4,0,2,0,2,1,2,1,1,0,2,0,1,1,1,1,2,0,2,0,2,1,0,1,2,1,2,0,0,1,2,1,2],
    \[6,2,10,54,2,3,4,0,2,0,2,1,2,1,1,0,2,0,1,1,1,1,2,0,2,0,2,1,0,1,2,1,1,0,2,1,1,0,1],
    \[6,2,11,54,2,3,3,0,1,1,1,0,0,1,0,0,1,1,0,0,0,1,2,1,1,0,1,1,1,0,2],
    \[6,2,12,63,0,8,2,0,56,0,54],
    \[6,2,13,63,0,8,3,0,54,4,30,4,27],
    \[6,2,14,63,0,8,2,4,38,4,11],
    \[6,2,15,81,2,3,3,0,1,1,1,0,0,1,0,0,1,1,0,0,0,1,2,0,2,0,1,1,1,1,1],
    \[6,2,16,98,3,6,3,0,0,6,0,2,0,0,5,0,1,1,2,5,1,4],
    \[6,2,17,108,2,3,5,0,2,0,2,1,2,1,1,0,2,0,1,1,1,1,2,0,2,0,2,1,0,1,2,1,1,0,1,1,1,0,2,0,0,1,1,1,1,1,2],
    \[6,2,18,108,0,11,2,0,0,1,3,1,0,2,0,0,1,3,2,1,0],
    \[6,2,19,126,0,8,4,0,54,4,30,4,27,3,14],
    \[6,2,20,126,0,8,3,0,56,0,54,3,14],
    \[6,2,21,162,2,3,4,0,1,1,1,0,0,1,0,0,1,1,0,0,0,1,2,0,2,0,1,1,1,1,1,1,2,0,0,1,2,1,2],
    \[6,2,22,162,2,3,4,0,1,1,1,0,0,1,0,0,1,1,0,0,0,1,2,0,2,0,1,1,1,1,1,0,0,1,1,1,1,1,1],
    \[6,2,23,162,2,3,3,0,2,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,1,1,2,1,1,1,2],
    \[6,2,24,189,0,8,3,4,38,4,11,4,19],
    \[6,2,25,216,0,11,3,0,0,1,3,1,0,2,0,0,1,3,2,1,0,0,0,1,2,0,2,1],
    \[6,2,26,216,0,11,2,1,0,0,3,1,2,2,1,0,1,0,1,0,0],
    \[6,2,27,216,0,11,3,0,0,1,2,0,2,1,0,0,1,0,1,1,2,1,2,0,2,1,2,0],
    \[6,2,28,294,3,6,4,0,0,6,0,2,0,0,5,0,1,0,1,1,1,1,1,2,5,1,4],
    \[6,2,29,294,3,6,4,0,0,6,0,2,0,0,5,0,1,0,2,3,1,1,1,2,5,1,4],
    \[6,2,30,324,2,3,5,0,1,1,1,0,0,1,0,0,1,1,0,0,0,1,2,0,2,0,1,1,1,1,1,1,1,0,2,1,1,0,1,0,0,1,1,1,1,1,1],
    \[6,2,31,324,2,3,2,0,1,1,1,0,0,1,0,0,1,0,1,1,0,1,0],
    \[6,2,32,378,0,8,2,1,0,0,1],
    \[6,2,33,432,0,11,3,1,2,0,1,1,0,0,1,2,0,1,1,2,0,0,0,1,3,1,0,2],
    \[6,2,34,648,2,3,3,0,1,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,0,1,1,1,1,1,1],
    \[6,2,35,648,2,3,3,0,1,1,1,0,0,1,0,0,1,0,1,1,0,1,0,1,1,1,1,0,0,0,0],
    \[6,2,36,648,2,3,3,0,1,1,1,0,0,1,0,0,1,0,1,1,0,1,0,1,0,0,0,1,1,1,1],
    \[6,2,37,648,0,11,2,0,2,1,2,1,1,0,0,1,1,1,2,0,1],
    \[6,2,38,882,3,6,5,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1],
    \[6,2,39,1296,2,3,8,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1],
    \[6,2,40,1296,0,11,7,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1]
];

_maxgens[7][2] := [
    [],

    [[1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1],
    [0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,-1,-1,0,0,0,0,0]]
];

_gps[7][2] := [
    \[7,2,1,127,0,2,1,0,1],
    \[7,2,2,889,0,2,2,1,0,0,1]
];

_maxgens[2][11] := [
    [[0,1,1,0],
     [2,0,0,1],
     [1,0,0,2]],

    [[1,0,-1,-1],
    [0,1,-7,-1]],

    [[4,5,8,7],
    [4,7,8,6],
    [0,-1,1,0],
    [1,3,3,-1],
    [2,0,0,2]]
];

_gps[2][11] := [
    \[2,11,1,3,0,2,1,0,40],
    \[2,11,2,4,1,2,1,0,30],
    \[2,11,3,6,0,2,1,0,20],
    \[2,11,4,6,0,2,2,1,0,0,40],
    \[2,11,5,8,1,1,3,1,0,0,0,5,0,0,0,5],
    \[2,11,6,8,0,2,1,0,15],
    \[2,11,7,8,0,2,2,1,5,0,30],
    \[2,11,8,10,1,1,2,1,0,0,0,2,-2],
    \[2,11,9,12,0,2,1,0,10],
    \[2,11,10,12,0,2,2,1,5,0,20],
    \[2,11,11,12,0,2,2,1,0,0,20],
    \[2,11,12,15,0,2,1,0,8],
    \[2,11,13,16,0,2,2,1,0,0,15],
    \[2,11,14,20,1,1,3,1,0,0,0,5,5,0,2,-2],
    \[2,11,15,20,1,1,3,1,5,0,0,5,5,0,2,-2],
    \[2,11,16,20,1,2,1,0,6],
    \[2,11,17,24,0,2,2,1,0,0,10],
    \[2,11,18,24,0,2,1,0,5],
    \[2,11,19,24,0,2,2,1,5,0,10],
    \[2,11,20,24,0,3,3,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0 ],
    \[2,11,21,30,0,2,1,0,4],
    \[2,11,22,30,0,2,2,1,0,0,8],
    \[2,11,23,40,1,1,4,1,0,0,0,5,0,0,0,5,0,2,2],
    \[2,11,24,40,1,1,4,1,0,0,0,5,0,0,0,5,0,2,-2],
    \[2,11,25,40,0,2,2,1,5,0,6],
    \[2,11,26,40,0,2,1,0,3],
    \[2,11,27,48,0,2,2,1,0,0,5],
    \[2,11,28,48,0,3,4,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,11,29,50,1,1,3,1,0,0,0,2,-2,0,2,2],
    \[2,11,30,60,0,2,2,1,0,0,4],
    \[2,11,31,60,0,2,2,1,5,0,4],
    \[2,11,32,60,0,2,1,0,2],
    \[2,11,33,80,0,2,2,1,0,0,3],
    \[2,11,34,100,1,1,4,1,0,0,0,5,5,0,2,-2,0,2,2],
    \[2,11,35,100,1,1,4,1,5,0,0,5,5,0,2,-2,0,2,2],
    \[2,11,36,120,0,2,2,1,0,0,2],
    \[2,11,37,120,0,2,1,0,1],
    \[2,11,38,120,0,2,2,1,5,0,2],
    \[2,11,39,120,0,3,4,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,2],
    \[2,11,40,200,1,1,5,1,0,0,0,5,0,0,0,5,0,2,-2,0,2,2 ],
    \[2,11,41,240,0,2,2,1,0,0,1],
    \[2,11,42,240,0,3,5,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,2]
];

_maxgens[2][13] := [
    [[0,1,1,0],
    [2,0,0,1],
    [1,0,0,2]],

    [[1,0,-1,-1],
    [0,1,-2,-1]],

    [],

    [[3,10,10,10],
    [2,3,2,10],
    [0,5,5,0],
    [5,0,0,-5],
    [2,0,0,2]]
];

_gps[2][13] := [
    \[2,13,1,6,1,1,2,1,0,0,0,4,-4],
    \[2,13,2,7,0,2,1,0,24],
    \[2,13,3,8,1,1,2,1,0,0,0,3,-3],
    \[2,13,4,8,1,1,2,1,6,0,0,3,-3],
    \[2,13,5,8,1,2,1,0,21],
    \[2,13,6,12,1,1,3,1,0,0,0,6,6,0,4,-4],
    \[2,13,7,12,1,1,3,1,6,0,0,6,6,0,4,-4],
    \[2,13,8,14,0,2,1,0,12],
    \[2,13,9,14,0,2,2,1,0,0,24],
    \[2,13,10,16,1,1,3,1,0,0,0,3,-3,0,3,3],
    \[2,13,11,16,1,1,3,1,3,0,0,3,-3,0,3,3],
    \[2,13,12,18,1,1,3,1,0,0,0,4,-4,0,4,4],
    \[2,13,13,21,0,2,1,0,8],
    \[2,13,14,24,1,1,3,1,6,0,0,3,-3,0,4,4],
    \[2,13,15,24,1,1,3,1,0,0,0,3,-3,0,4,-4],
    \[2,13,16,24,1,1,3,1,6,0,0,3,-3,0,4,-4],
    \[2,13,17,24,1,1,3,1,0,0,0,3,-3,0,4,4],
    \[2,13,18,24,1,1,3,1,0,0,0,3,3,0,4,-4],
    \[2,13,19,24,1,1,3,1,3,0,0,3,3,0,4,-4],
    \[2,13,20,24,1,2,1,0,7],
    \[2,13,21,24,0,4,3,0,1,0,0,4,0,0,1,0,0,0,0,0,1,0],
    \[2,13,22,24,0,4,3,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,13,23,28,0,2,1,0,6],
    \[2,13,24,28,0,2,2,1,6,0,12],
    \[2,13,25,28,0,2,2,1,0,0,12],
    \[2,13,26,32,1,1,3,1,0,0,0,3,0,0,0,3],
    \[2,13,27,36,1,1,4,1,0,0,0,6,6,0,4,-4,0,4,4],
    \[2,13,28,36,1,1,4,1,6,0,0,6,6,0,4,-4,0,4,4],
    \[2,13,29,42,0,2,1,0,4],
    \[2,13,30,42,0,2,2,1,0,0,8],
    \[2,13,31,48,1,1,4,1,0,0,0,3,-3,0,3,3,0,4,-4],
    \[2,13,32,48,1,1,4,1,3,0,0,3,-3,0,3,3,0,4,-4],
    \[2,13,33,48,1,1,4,1,3,0,0,3,-3,0,3,3,0,4,4],
    \[2,13,34,48,1,1,4,1,0,0,0,3,-3,0,3,3,0,4,4],
    \[2,13,35,48,0,4,4,2,0,0,0,0,0,1,0,0,4,0,0,1,0,0,0,0,0,1,0],
    \[2,13,36,48,0,4,4,2,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,13,37,56,0,2,1,0,3],
    \[2,13,38,56,0,2,2,1,0,0,6],
    \[2,13,39,56,0,2,2,1,3,0,6],
    \[2,13,40,72,1,1,4,1,0,0,0,3,3,0,4,-4,0,4,4],
    \[2,13,41,72,1,1,4,1,3,0,0,3,3,0,4,-4,0,4,4],
    \[2,13,42,72,1,1,4,1,6,0,0,3,-3,0,4,-4,0,4,4],
    \[2,13,43,72,1,1,4,1,0,0,0,3,-3,0,4,-4,0,4,4],
    \[2,13,44,72,0,4,4,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,4],
    \[2,13,45,84,0,2,2,1,6,0,4],
    \[2,13,46,84,0,2,2,1,0,0,4],
    \[2,13,47,84,0,2,1,0,2],
    \[2,13,48,96,1,1,4,1,0,0,0,3,0,0,0,3,0,4,-4],
    \[2,13,49,96,1,1,4,1,0,0,0,3,0,0,0,3,0,4,4],
    \[2,13,50,96,0,4,4,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],
    \[2,13,51,112,0,2,2,1,0,0,3],
    \[2,13,52,144,1,1,5,1,3,0,0,3,-3,0,3,3,0,4,-4,0,4,4],
    \[2,13,53,144,1,1,5,1,0,0,0,3,-3,0,3,3,0,4,-4,0,4,4],
    \[2,13,54,144,0,4,5,2,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,4],
    \[2,13,55,168,0,2,1,0,1],
    \[2,13,56,168,0,2,2,1,0,0,2],
    \[2,13,57,168,0,2,2,1,3,0,2],
    \[2,13,58,288,1,1,5,1,0,0,0,3,0,0,0,3,0,4,-4,0,4,4],
    \[2,13,59,288,0,4,5,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,4],
    \[2,13,60,336,0,2,2,1,0,0,1]
];

_maxdeg := #_gps;

_summary := &cat [
    [<i, j, #_gps[i][j]>: j in [1 .. #_gps[i]] | IsDefined(_gps[i], j)]:
    i in [1 .. #_gps] | IsDefined(_gps, i)
];

_check_degree := procedure(n)
    error if Type(n) ne RngIntElt, "Degree must be an integer";
    error if n lt 2, "Degree must be at least 2";
    error if n gt #_gps,
	"Degree must not exceed " cat IntegerToString(_maxdeg);
end procedure;

_check_field := procedure(p)
    error if Type(p) ne RngIntElt, "Field specifier must be an integer";
    error if p lt 2, "Field specifier must be prime";
    error if not IsPrime(p: Proof := false), "Field specifier must be prime";
end procedure;

_check_deg_field := procedure(n, p)
    _check_degree(n);
    _check_field(p);
    error if not IsDefined(_gps[n], p),
	"Field specifier must not exceed " cat IntegerToString(#_gps[n]) cat
	" when degree is " cat IntegerToString(n);
end procedure;

_check_args := procedure(n, p, i)
    _check_deg_field(n, p);
    error if Type(i) ne RngIntElt, "Label must be an integer";
    error if i lt 1 or i gt #_gps[n][p],
	"Group identifier must be in the range [1 .. " cat
	IntegerToString(#_gps[n][p]) cat "]";
end procedure;

_npi_to_com_check := function(n, p, i)
    _check_args(n, p, i);
    return _gps[n][p][i];
end function;

IsolDegree := function(n, p, i)
    _check_args(n, p, i);
    return n;
end function;

IsolCharacteristic := function(n, p, i)
    _check_args(n, p, i);
    return p;
end function;

IsolOrder := func<n, p, i | _npi_to_com_check(n, p, i)[4]>;
IsolIsPrimitive := func<n, p, i | _npi_to_com_check(n, p, i)[5] eq 0>;
IsolMinBlockSize := func<n, p, i | _npi_to_com_check(n, p, i)[5]>;
IsolMinBlockSize := func<n, p, i | _npi_to_com_check(n, p, i)[7]>;

IsolGuardian := function(n, p, i)
    com := _npi_to_com_check(n, p, i);
    return sub<GL(n, p) | _maxgens[n][p][com[6]]>;
end function;

IsolInfo := function(n, p, i)
    com := _npi_to_com_check(n, p, i);
    ord := com[4];
    blksiz := com[5];
    return "Order: " cat i2s(ord) cat (blksiz eq 0 select " Primitive" else
	(" Imprimitive.  Minimal block size: " cat i2s(blksiz)))
	where i2s is IntegerToString;
end function;

IsolNumberOfDegreeField := function(n, p)
    _check_deg_field(n, p);
    return #_gps[n][p];
end function;

IsolGroup := function(n, p, i);
    com := _npi_to_com_check(n, p, i);
    G := GL(n, p);
    gdgens := _maxgens[n][p][com[6]];
    len := #gdgens;
    mats := [G | x: x in gdgens];
    numgen := com[7];
    pos := 8;
    gens := [];
    for i := 1 to numgen do
	prod := Id(G);
	for j := 1 to len do
	    prod := prod * (mats[j]^com[pos + j - 1]);
	end for;
	gens[i] := prod;
	pos +:= len;
    end for;

    return sub<G | gens>;
end function;

Getvecs := function(G)
    V := RSpace(G);
    fd := CoefficientRing(V);
    error if Degree(fd) gt 1,
	"Bad input to Getvecs: underlying field must be a prime field";
    n := Dimension(V);
    np1 := n + 1;
    p := Characteristic(fd);
    deg := p^n;
    vecs := [];
    for i := 1 to deg - 1 do
	sq := [];
	num := i;
	for j := 1 to n do
	    ones := num mod p;
	    sq[np1 - j] := ones * fd!1;
	    num := (num - ones) div p;
	end for;
	vecs[i] := V!sq;
    end for;
    vecs[deg] := V!0;
    return vecs;
end function;

Semidir := function(G, vecs)
/*
Given:  An irreducible matrix group G, and
        A specially ordered sequence VECS of the vectors in RSpace(G).
Return: The image H of the natural permutation representation of the
	semidirect product of G with its natural submodule generated by
	the vector (0, ..., 0, 1).
Note:  	Since G is irreducible, H is the semidirect product of G with
        its underlying vector space.
*/
    error if not IsIrreducible(G),
	"Bad input to Semidir: group must be irreducible";
    V := RSpace(G);
    p := Characteristic(CoefficientRing(V));
    deg := p^Dimension(V);
    len := Ngens(G);
    S := Sym(deg);

    // The first LEN generators of H are (G.i, vec(0)), i = 1,...,LEN.
    degm1 := deg - 1;
    hgens := [
	[Position(vecs, vecs[j] * G.i): j in [1..degm1]] cat [deg]:
	i in [1 .. len]
    ];
    soc := [i + 1: i in [1 .. degm1]];
    Append(~soc, 1);
    soc[p - 1] := deg;
    for i := 2 to deg div p do
	ip := i * p;
	soc[ip - 1] := ip - p;
    end for;
    hgens[len + 1] := soc;
    return PermutationGroup<deg | hgens>;
end function;

// search stuff

_split_pred := function(f)
    if Type(f) eq Tup then
	case #f:
	when 1:
	    return f[1], func<G | true>;
	when 2:
	    return f[1], f[2];
	else
	    error "Tuple of predicates must have length 1 or 2";
	end case;
    else
	return func<n, p, i | true>, f;
    end if;
end function;

IsolGroupSatisfying := function(f)
    fast, slow := _split_pred(f);
    if exists(G){
	g:  i in [x: x in [1 .. #_gps[n][p]] | fast(n, p, x)],
	    p in [x: x in [1 .. #_gps[n]] | IsDefined(_gps[n], x)],
	    n in [x: x in [1 .. _maxdeg] | IsDefined(_gps, x)] |
	slow(g) where g is IsolGroup(n, p, i)
    } then
	return G;
    end if;
    error "No stored irreducible soluble subgroups of GL(n,p) satisfy the required predicate";
end function;

IsolGroupsSatisfying := function(f)
    fast, slow := _split_pred(f);
    return [
	g:  i in [x: x in [1 .. #_gps[n][p]] | fast(n, p, x)],
	    p in [x: x in [1 .. #_gps[n]] | IsDefined(_gps[n], x)],
	    n in [x: x in [1 .. _maxdeg] | IsDefined(_gps, x)] |
	slow(g) where g is IsolGroup(n, p, i)
    ];
end function;

IsolGroupOfDegreeSatisfying := function(n, f)
    _check_degree(n);
    fast, slow := _split_pred(f);
    if exists(G){
	g:  i in [x: x in [1 .. #_gps[n][p]] | fast(n, p, x)],
	    p in [x: x in [1 .. #_gps[n]] | IsDefined(_gps[n], x)] |
	slow(g) where g is IsolGroup(n, p, i)
    } then
	return G;
    end if;
    error "No stored irreducible soluble subgroups of GL(" cat
	IntegerToString(n) cat ",p) satisfy the required predicate";
end function;

IsolGroupsOfDegreeSatisfying := function(n, f)
    _check_degree(n);
    fast, slow := _split_pred(f);
    return [
	g:  i in [x: x in [1 .. #_gps[n][p]] | fast(n, p, x)],
	    p in [x: x in [1 .. #_gps[n]] | IsDefined(_gps[n], x)] |
	slow(g) where g is IsolGroup(n, p, i)
    ];
end function;

IsolGroupOfDegreeFieldSatisfying := function(n, p, f)
    _check_deg_field(n, p);
    fast, slow := _split_pred(f);
    if exists(G){
	g:  i in [x: x in [1 .. #_gps[n][p]] | fast(n, p, x)] |
	slow(g) where g is IsolGroup(n, p, i)
    } then
	return G;
    end if;
    error "No stored irreducible soluble subgroups of GL(" cat i(n) cat
	"," cat i(p) cat ") satisfy the required predicate"
	where i is IntegerToString;
end function;

IsolGroupsOfDegreeFieldSatisfying := function(n, p, f)
    fast, slow := _split_pred(f);
    return [
	g:  i in [x: x in [1 .. #_gps[n][p]] | fast(n, p, x)] |
	slow(g) where g is IsolGroup(n, p, i)
    ];
end function;

// process stuff

IsolProcess := function()
    return <1, 1, [1 .. #_summary]>;
end function;

IsolProcessOfDegree := function(n)
    case Type(n):
    when RngIntElt:
	_check_degree(n);
	list := [i: i in [1 .. #_summary] | _summary[i][1] eq n];
	assert #list ne 0;
	return <1, 1, list>;
    when Tup:
	error if #n ne 2, "A range of degrees must be specified as <lo, hi>";
	lo := n[1]; hi := n[2];
	_check_degree(lo);
	_check_degree(hi);
	list := [
	    i: i in [1 .. #_summary] |
	    lo le deg and deg le hi where deg is _summary[i][1]
	];
	return #list eq 0 select <0, 0, []> else <1, 1, list>;
    else
	error "Degree specifier must be either an integer or a 2-tuple";
    end case;
end function;

IsolProcessOfField := function(p)
    case Type(p):
    when RngIntElt:
	_check_field(p);
	list := [i: i in [1 .. #_summary] | _summary[i][2] eq p];
	return #list eq 0 select <0, 0, []> else <1, 1, list>;
    when Tup:
	error if #p ne 2,
	    "A range of field specifiers must be specified as <lo, hi>";
	lo := p[1]; hi := p[2];
	_check_field(lo);
	_check_field(hi);
	list := [
	    i: i in [1 .. #_summary] |
	    lo le ch and ch le hi where ch is _summary[i][2]
	];
	return #list eq 0 select <0, 0, []> else <1, 1, list>;
    else
	error "Field specifier must be either an integer or a 2-tuple";
    end case;
end function;

IsolProcessOfDegreeField := function(n, p)
    case Type(n):
    when RngIntElt:
	_check_degree(n);
	lod := n; hid := n;
    when Tup:
	error if #n ne 2, "A range of degrees must be specified as <lo, hi>";
	lod := n[1]; hid := n[2];
	_check_degree(lod);
	_check_degree(hid);
    else
	error "Degree specifier must be either an integer or a 2-tuple";
    end case;
    case Type(p):
    when RngIntElt:
	_check_field(p);
	lop := p; hip := p;
    when Tup:
	error if #p ne 2,
	    "A range of field specifiers must be specified as <lo, hi>";
	lop := p[1]; hip := p[2];
	_check_field(lop);
	_check_field(hip);
    else
	error "Field specifier must be either an integer or a 2-tuple";
    end case;

    list := [
	i: i in [1 .. #_summary] |
	lod le deg and deg le hid and lop le ch and ch le hip
	where deg is si[1] where ch is si[2] where si is _summary[i]
    ];
    return #list eq 0 select <0, 0, []> else <1, 1, list>;
end function;

IsolProcessIsEmpty := func<p | p[1] eq 0>;

IsolProcessGroup := function(p)
    error if IsolProcessIsEmpty(p),
	"Attempt to extract group from empty process";
    return IsolGroup(s[1], s[2], p[1]) where s is _summary[p[3][p[2]]];
end function;

IsolProcessLabel := function(p)
    error if IsolProcessIsEmpty(p),
	"Attempt to extract label from empty process";
    s := _summary[p[2]];
    return s[1], s[2], p[1];
end function;

IsolProcessInfo := function(p)
    error if IsolProcessIsEmpty(p),
	"Attempt to extract label from empty process";
    return IsolInfo(s[1], s[2], p[1]) where s is _summary[p[2]];
end function;

IsolProcessNext := procedure(~p)
    error if IsolProcessIsEmpty(p),
	"Attempt to traverse empty process";
    s := _summary[p[2]];
    if p[1] lt s[3] then
	p[1] +:= 1;
	return;
    end if;
    if p[2] lt #p[3] then
	p[2] +:= 1;
	p[1] := 1;
	return;
    end if;
    p[1] := 0;
end procedure;

delete _check_args, _check_deg_field, _check_degree, _check_field;
delete _gps, _maxdeg, _maxgens, _npi_to_com_check, _split_pred, _summary;
