"Verbosity 0 just checks that, in each of the three cases, there are elements of order 1640 that power to a given element of order 328 with the correct eigenvalues on L(G), and possessing the same number of eigenvalues on L(G)";
printf("\n");
"Verbosity 1 in addition checks that the element of order 41 has the correct eigenvalues on L(G), that the preimages of orders 82, 164 and 328 have the correct eigenvalues on L(G), and that they each square to the correct element";
printf("\n");
"Verbosity 2 in addition checks that the elements of orders 328, 164 and 82 that have the correct eigenvalues on L(G) are all conjugate, up to taking powers.";
printf("\n");
"Verbosity 3 checks, in addition, that the eigenvalues stated here are correct for the modules of PSU(4,9).";
printf("\n");
"Verbosity 4 finds elements of order 1640 powering to an element of order 328 with the correct eigenvalues, rather than checking that the given elements are correct.";
printf("\n");
"Default is verbosity 4";

Verbosity:=4;

load "Subgroups/functions.txt";

function FindOrb(Orbs,i)
for Orb in Orbs do if(i in Orb) then return Orb; end if; end for;
return {};
end function;

q:=3^8;
F<w>:=GF(q);
G:=GroupOfLieType("E8",q);
V:=VectorSpace(GF(q),8);
rho1:=StandardRepresentation(G);
Over1:=GL(248,q);
g1:=elt<G|V![w,1,1,1,1,1,1,1]>;
g2:=elt<G|V![1,w,1,1,1,1,1,1]>;
g3:=elt<G|V![1,1,w,1,1,1,1,1]>;
g4:=elt<G|V![1,1,1,w,1,1,1,1]>;
g5:=elt<G|V![1,1,1,1,w,1,1,1]>;
g6:=elt<G|V![1,1,1,1,1,w,1,1]>;
g7:=elt<G|V![1,1,1,1,1,1,w,1]>;
g8:=elt<G|V![1,1,1,1,1,1,1,w]>;
W:=Reflections(G);
Mats1:=[rho1(i):i in [g1,g2,g3,g4,g5,g6,g7,g8]];
MatsE:=[rho1(i):i in W];
NGT:=sub<Over1|Mats1 cat MatsE>;
T:=sub<NGT|Mats1>;
E:=sub<NGT|MatsE>;

T41:=sub<T|[T.i^160:i in [1..8]]>;
T328:=sub<T|[T.i^20:i in [1..8]]>;
T1640:=sub<T|[T.i^4:i in [1..8]]>;

R:=ResidueClassRing(328);
X:=[[R!((Log((T328.j)[i,i])*328) div 6560):i in [1..248]]:j in [1..8]];


Eigs1:=[
    { <w^80, 16>, <w^180, 2>, <w^5920, 8>, <w^1620, 2>, <w^5740, 16>, <w^4920, 1>, <w^5660, 8>, <w^640, 8>, <w^900,
    8>, <w^820, 16>, <w^5840, 16>, <w^4940, 2>, <w^1460, 2>, <w^5820, 8>, <w^20, 2>, <w^1640, 1>, <w^5760, 8>,
    <w^6540, 2>, <w^100, 8>, <w^800, 8>, <w^5120, 1>, <w^740, 8>, <w^720, 16>, <w^5100, 2>, <w^6400, 1>, <w^6380,
    2>, <w^5020, 8>, <w^6480, 16>, <1, 34>, <w^1540, 8>, <w^160, 1>, <w^6460, 8>, <w^1440, 1> },
    { <w^2340, 2>, <w^360, 2>, <w^6200, 2>, <w^1920, 1>, <w^1700, 2>, <w^1640, 1>, <w^120, 2>, <w^4340, 1>,
    <w^2540, 1>, <w^800, 1>, <w^4180, 1>, <w^5980, 1>, <w^4940, 2>, <w^6520, 2>, <w^6280, 2>, <w^2460, 4>, <w^5220,
    1>, <w^2440, 2>, <w^4280, 2>, <w^3580, 1>, <w^300, 1>, <w^6480, 4>, <w^40, 2>, <w^6440, 2>, <w^4400, 4>,
    <w^4860, 2>, <w^1740, 1>, <w^4820, 1>, <w^4320, 1>, <w^5020, 1>, <w^2240, 1>, <w^4160, 1>, <w^1940, 1>,
    <w^2080, 1>, <w^6460, 1>, <w^3560, 2>, <w^5100, 2>, <w^4020, 1>, <w^580, 1>, <w^6260, 1>, <w^280, 2>, <w^260,
    2>, <w^2880, 1>, <w^6100, 2>, <w^2380, 1>, <w^240, 4>, <w^780, 2>, <w^6300, 2>, <w^3860, 1>, <w^5120, 1>,
    <w^2100, 2>, <w^2160, 4>, <w^4100, 4>, <w^4380, 2>, <w^720, 4>, <w^5820, 1>, <w^160, 1>, <w^960, 1>, <w^3380,
    1>, <w^840, 2>, <w^5920, 1>, <w^700, 2>, <w^4220, 2>, <w^540, 2>, <w^3160, 2>, <w^4040, 2>, <w^6080, 1>,
    <w^4360, 2>, <w^5840, 4>, <w^460, 2>, <w^5720, 2>, <w^480, 1>, <w^2980, 1>, <w^3640, 2>, <w^60, 2>, <w^180, 2>,
    <1, 12>, <w^5860, 2>, <w^2920, 2>, <w^1540, 1>, <w^6380, 2>, <w^1060, 1>, <w^3000, 2>, <w^5480, 2>, <w^1000,
    2>, <w^1080, 2>, <w^760, 2>, <w^320, 1>, <w^2280, 2>, <w^80, 4>, <2, 2>, <w^1380, 2>, <w^1460, 2>, <w^6320, 4>,
    <w^900, 1>, <w^6240, 1>, <w^6400, 1>, <w^4120, 2>, <w^100, 1>, <w^6020, 2>, <w^6500, 2>, <w^1440, 1>, <w^5740,
    4>, <w^1340, 1>, <w^4920, 1>, <w^4620, 1>, <w^2200, 2>, <w^3240, 2>, <w^3400, 2>, <w^3180, 1>, <w^4460, 2>,
    <w^4640, 1>, <w^3320, 2>, <w^2420, 2>, <w^740, 1>, <w^2700, 1>, <w^5560, 2>, <w^5800, 2>, <w^2520, 2>, <w^2180,
    2>, <w^5780, 2>, <w^820, 4>, <w^1620, 2>, <w^6540, 2>, <w^2400, 1>, <w^5600, 1>, <w^2220, 1>, <w^4480, 1>,
    <w^640, 1>, <w^5180, 2>, <w^5660, 1>, <w^5760, 1>, <w^20, 2>, <w^3680, 1>, <w^4140, 2>, <w^5500, 1> },
    { <w^1520, 2>, <w^5000, 2>, <w^6540, 4>, <w^5740, 8>, <w^60, 1>, <w^4120, 1>, <w^5180, 1>, <w^6380, 4>,
    <w^1380, 1>, <w^160, 2>, <w^180, 4>, <w^1460, 4>, <w^4200, 2>, <w^980, 2>, <w^660, 2>, <w^100, 6>, <w^5560, 1>,
    <w^5940, 2>, <w^820, 8>, <w^540, 1>, <w^640, 6>, <w^5920, 6>, <w^5720, 1>, <w^740, 6>, <w^2360, 2>, <w^5020,
    6>, <w^80, 8>, <w^260, 1>, <w^4840, 2>, <w^5760, 6>, <w^5100, 4>, <w^2340, 1>, <w^5840, 8>, <w^2440, 1>,
    <w^6460, 6>, <w^1640, 2>, <w^4300, 2>, <w^720, 8>, <w^4280, 1>, <w^1620, 4>, <w^4920, 2>, <w^4940, 4>, <w^920,
    2>, <w^5860, 1>, <w^1540, 6>, <w^1720, 2>, <w^5120, 2>, <1, 12>, <w^6020, 1>, <w^620, 2>, <w^880, 2>, <w^560,
    2>, <w^5680, 2>, <w^5660, 6>, <w^5640, 2>, <w^4380, 1>, <w^6500, 1>, <w^5820, 6>, <w^5040, 2>, <w^6400, 2>,
    <w^6300, 1>, <w^4220, 1>, <w^800, 6>, <w^840, 1>, <w^2180, 1>, <w^1560, 2>, <w^5580, 2>, <w^2280, 1>, <w^2260,
    2>, <w^4860, 1>, <w^900, 6>, <w^5200, 2>, <w^700, 1>, <w^20, 4>, <w^1360, 2>, <w^6480, 8>, <w^1000, 1>,
    <w^6000, 2>, <w^1440, 2>, <w^5900, 2>, <w^1700, 1> }
];
Eigs2:=
[
    { <w^3240, 2>, <w^6240, 1>, <w^6360, 8>, <w^1480, 8>, <w^1800, 8>, <w^4920, 16>, <w^4760, 8>, <w^3080, 8>,
    <w^1600, 8>, <w^40, 2>, <w^3320, 2>, <w^2880, 1>, <w^1280, 8>, <w^1440, 16>, <w^3680, 1>, <w^3480, 8>, <2, 2>,
    <w^1640, 16>, <w^160, 16>, <w^5120, 16>, <w^4960, 8>, <w^320, 1>, <w^2920, 2>, <w^6200, 2>, <w^6520, 2>, <1,
    34>, <w^200, 8>, <w^5080, 8>, <w^6400, 16>, <w^360, 2>, <w^5280, 8>, <w^3640, 2> },
    { <w^1520, 4>, <w^600, 2>, <w^240, 4>, <w^800, 1>, <w^1400, 2>, <w^520, 2>, <1, 14>, <w^5000, 2>, <w^4800, 1>,
    <w^920, 2>, <w^1160, 2>, <w^3840, 1>, <w^4440, 2>, <w^2000, 4>, <w^5160, 2>, <w^3400, 2>, <w^6200, 2>, <w^2160,
    4>, <w^3680, 1>, <w^6520, 2>, <w^4200, 2>, <w^2400, 1>, <w^40, 2>, <w^2920, 2>, <w^2720, 1>, <w^3640, 2>,
    <w^2080, 1>, <w^160, 4>, <w^2360, 2>, <w^5760, 1>, <w^5840, 4>, <w^5600, 1>, <w^2240, 4>, <w^6080, 4>, <w^5640,
    2>, <w^4480, 1>, <w^4760, 2>, <w^480, 4>, <w^6400, 4>, <w^4560, 4>, <w^3800, 2>, <w^4360, 2>, <w^3480, 2>,
    <w^720, 4>, <w^1080, 2>, <w^120, 2>, <w^1640, 8>, <w^5280, 1>, <w^4920, 8>, <w^1560, 2>, <w^6480, 4>, <w^4400,
    4>, <w^3320, 2>, <w^1720, 2>, <w^5120, 4>, <w^4640, 1>, <w^5400, 2>, <w^5040, 4>, <w^6440, 2>, <w^2760, 2>,
    <w^6320, 4>, <w^4960, 1>, <w^1480, 2>, <w^4160, 1>, <w^4880, 4>, <w^2880, 1>, <w^6000, 4>, <w^6240, 1>, <w^200,
    2>, <w^3080, 2>, <w^1800, 2>, <w^3160, 2>, <w^4320, 4>, <w^960, 1>, <w^5960, 2>, <w^5080, 2>, <w^1920, 1>,
    <w^1280, 1>, <w^2120, 2>, <w^1760, 1>, <w^1600, 1>, <w^640, 1>, <w^560, 4>, <w^6040, 2>, <w^3240, 2>, <w^80,
    4>, <2, 2>, <w^4680, 2>, <w^5480, 2>, <w^360, 2>, <w^5920, 1>, <w^1440, 4>, <w^4840, 2>, <w^1680, 4>, <w^2200,
    2>, <w^1880, 2>, <w^320, 1>, <w^2680, 2>, <w^3880, 2>, <w^6360, 2> },
    { <w^4800, 2>, <w^3840, 2>, <w^5440, 2>, <w^3320, 4>, <w^6040, 1>, <w^1080, 1>, <w^3800, 1>, <w^4960, 6>,
    <w^3680, 2>, <w^3480, 6>, <w^5480, 1>, <w^200, 6>, <w^6200, 4>, <w^2000, 2>, <w^1800, 6>, <w^5120, 8>, <w^320,
    2>, <w^4760, 6>, <w^3120, 4>, <w^4880, 2>, <w^1120, 2>, <w^5160, 1>, <w^5080, 6>, <w^1680, 2>, <w^2920, 4>,
    <w^40, 4>, <w^6400, 8>, <w^2200, 1>, <w^1840, 4>, <w^3160, 1>, <w^2040, 2>, <w^6240, 2>, <w^4560, 2>, <w^2760,
    1>, <w^6520, 4>, <w^1240, 2>, <w^6440, 1>, <w^3040, 2>, <w^520, 1>, <w^1760, 2>, <w^3400, 1>, <1, 12>, <w^4920,
    8>, <w^5280, 6>, <w^3240, 4>, <w^4600, 2>, <w^1480, 6>, <w^1280, 6>, <w^3640, 4>, <w^1880, 1>, <w^3440, 4>,
    <w^120, 1>, <w^360, 4>, <w^2720, 2>, <w^160, 8>, <w^1400, 1>, <w^3080, 6>, <w^4360, 1>, <w^1960, 2>, <w^6360,
    6>, <w^4720, 4>, <w^4680, 1>, <w^1440, 8>, <w^2880, 2>, <2, 4>, <w^5320, 2>, <w^4520, 2>, <w^5240, 2>, <w^3520,
    2>, <w^1640, 8>, <w^1320, 2>, <w^1600, 6> }
];
Eigs3:=[
    { <w^6480, 4>, <w^400, 16>, <w^4000, 8>, <w^2960, 16>, <1, 36>, <w^3600, 16>, <w^3680, 16>, <2, 32>, <w^2560,
    8>, <w^5920, 1>, <w^5760, 1>, <w^720, 4>, <w^2880, 16>, <w^3360, 8>, <w^640, 1>, <w^800, 1>, <w^5840, 4>,
    <w^3200, 8>, <w^320, 16>, <w^6160, 16>, <w^6240, 16>, <w^80, 4> },
    { <w^2240, 4>, <w^5120, 4>, <w^800, 1>, <w^4240, 4>, <w^400, 4>, <w^6480, 4>, <w^4960, 1>, <w^4640, 1>,
    <w^4000, 5>, <w^3120, 4>, <w^6400, 4>, <w^1760, 1>, <w^5440, 5>, <w^3760, 4>, <w^2320, 4>, <w^3440, 4>,
    <w^1440, 4>, <w^5600, 4>, <w^640, 1>, <w^2160, 4>, <w^160, 4>, <w^3600, 4>, <1, 16>, <w^2720, 1>, <w^4400, 4>,
    <w^1200, 4>, <w^3840, 1>, <w^3200, 5>, <w^2800, 4>, <w^4480, 4>, <w^5760, 1>, <w^2080, 4>, <w^4160, 1>,
    <w^3040, 5>, <w^4800, 1>, <w^3680, 4>, <w^2960, 4>, <w^1600, 1>, <w^2400, 1>, <w^5840, 4>, <w^6080, 4>,
    <w^1280, 1>, <w^240, 4>, <2, 16>, <w^5520, 4>, <w^5280, 1>, <w^320, 4>, <w^960, 4>, <w^5360, 4>, <w^1120, 5>,
    <w^480, 4>, <w^4320, 4>, <w^4720, 4>, <w^1920, 1>, <w^3520, 5>, <w^1040, 4>, <w^5920, 1>, <w^6160, 4>, <w^6320,
    4>, <w^720, 4>, <w^1840, 4>, <w^80, 4>, <w^3360, 5>, <w^2880, 4>, <w^6240, 4>, <w^2560, 5> },
    { <w^2800, 2>, <w^720, 8>, <w^6240, 12>, <w^6080, 2>, <w^6480, 8>, <w^4000, 8>, <w^4080, 4>, <w^3600, 12>,
    <w^2560, 8>, <w^4400, 2>, <1, 16>, <w^80, 8>, <w^2240, 2>, <w^4320, 2>, <w^5760, 2>, <w^2960, 12>, <w^480, 2>,
    <w^5840, 8>, <w^400, 12>, <w^3680, 12>, <w^1120, 2>, <w^3040, 2>, <w^320, 12>, <w^1040, 2>, <w^640, 2>,
    <w^3920, 4>, <w^3200, 8>, <w^3520, 2>, <w^2480, 4>, <w^5920, 2>, <w^2640, 4>, <w^2880, 12>, <w^800, 2>,
    <w^5440, 2>, <w^3760, 2>, <w^6320, 2>, <w^5520, 2>, <w^3360, 8>, <2, 16>, <w^6160, 12>, <w^240, 2>, <w^2160, 2>
    }
];
Eigs4:=[
    { <w^5280, 1>, <w^640, 32>, <w^6400, 12>, <w^800, 32>, <w^1600, 1>, <w^5120, 12>, <w^5760, 32>, <w^4960, 1>,
    <w^160, 12>, <w^1280, 1>, <1, 68>, <w^5920, 32>, <w^1440, 12> },
    { <w^160, 9>, <w^2240, 9>, <w^480, 9>, <w^2080, 8>, <w^4640, 8>, <w^5920, 8>, <w^4160, 8>, <w^4000, 1>,
    <w^1920, 8>, <w^5280, 1>, <w^2720, 1>, <w^5440, 1>, <w^2560, 1>, <w^960, 8>, <w^3200, 1>, <w^640, 8>, <w^4480,
    8>, <w^1760, 1>, <w^3680, 8>, <w^4960, 1>, <w^5120, 9>, <w^3040, 1>, <w^3360, 1>, <w^2400, 8>, <w^1120, 1>,
    <w^1440, 9>, <w^3520, 1>, <w^2880, 8>, <w^5760, 8>, <w^6080, 9>, <w^1600, 1>, <w^800, 8>, <w^3840, 1>, <w^1280,
    1>, <w^4320, 9>, <w^6240, 8>, <w^6400, 9>, <w^5600, 8>, <w^4800, 1>, <w^320, 8>, <1, 32> },
    { <w^4960, 6>, <w^5600, 4>, <w^800, 24>, <w^160, 16>, <w^1280, 6>, <w^5920, 24>, <w^6080, 4>, <w^960, 4>,
    <w^6400, 16>, <w^5280, 6>, <w^1600, 6>, <w^640, 24>, <w^480, 4>, <1, 32>, <w^4320, 4>, <w^1440, 16>, <w^5120,
    16>, <w^2240, 4>, <w^2080, 4>, <w^4480, 4>, <w^5760, 24> }
];


if(Verbosity ge 3) then
  G2:=SU(4,9);
  CC:=ConjugacyClasses(G2);
  S41:=GModule(G2);
  S61:=ExteriorSquare(S41);
  S42:=Socle(SymmetricPower(S41,3));
  S62:=ExteriorSquare(S42);
  S101:=SymmetricSquare(S41);
  S151:=ExteriorSquare(S61);
  S152:=ExteriorSquare(S62);
  S161:=TensorProduct(S41,S42);
  S162:=TensorProduct(S41,Dual(S42));
  S191:=SocleFactors(SymmetricSquare(S61))[2];
  S36:=TensorProduct(S61,S62);
  S441:=SocleFactors(SymmetricPower(S61,3))[2];
  S451:=ExteriorSquare(S101);

  for i in [694..773] do
    if(w^10 in {j[1]:j in EigenvaluesOfElement(ChangeRing(S41,F),CC[i,3])}) then x:=CC[i,3]; end if;
  end for;

  M1:=DirectSum(&cat[[TrivialModule(G2,GF(81)):i in [1..12]],[S61:i in [1..12]],
  [S151:i in [1..7]],[S101,S101,Dual(S101),Dual(S101),S191]]);
  M2:=DirectSum([TrivialModule(G2,GF(81)):i in [1..6]] cat [S61,S61,S61,S61,S62,S62,S62,S62,S151,
  S152,S161,S161,S162,S162,Dual(S161),Dual(S162),Dual(S161),Dual(S162),S36]);
  M3:=DirectSum([S151,S151,S101,S101,Dual(S101),Dual(S101),S441,S441,S451,Dual(S451)]);
  "Checking that the eigenvalues for L(G) are correct.";
  Eigs1 eq [EigenvaluesOfElement(ChangeRing(j,F),x):j in [M1,M2,M3]];
  Eigs2 eq [EigenvaluesOfElement(ChangeRing(j,F),x^2):j in [M1,M2,M3]];
  Eigs3 eq [EigenvaluesOfElement(ChangeRing(j,F),x^4):j in [M1,M2,M3]];
  Eigs4 eq [EigenvaluesOfElement(ChangeRing(j,F),x^8):j in [M1,M2,M3]];
end if;



El1:=[
[ 5, 1, 40, 0, 0, 0, 0, 0 ],
[ 9, 4, 3, 23, 20, 36, 0, 28 ],
[ 35, 37, 0, 5, 32, 13, 37, 4 ]
];

El2:=[
[ 20, 4, 324, 0, 164, 0, 0, 0 ],
[ 200, 180, 12, 256, 80, 144, 0, 112 ],
[ 140, 148, 0, 20, 292, 52, 148, 16 ]
];

El3:=[
[ 10, 166, 326, 0, 82, 0, 0, 0 ],
[ 100, 254, 6, 292, 40, 72, 0, 220 ],
[ 234, 238, 164, 10, 146, 190, 74, 8 ]
];

El4:=[
[ 5, 247, 327, 0, 41, 0, 0, 0 ],
[ 50, 127, 3, 310, 184, 36, 0, 110 ],
[ 117, 283, 246, 5, 73, 259, 37, 4 ]
];

El5:=[
[ 5, 1231, 327, 0, 41, 0, 0, 0 ],
[ 1034, 127, 3, 966, 184, 36, 0, 110 ],
[ 1101, 1595, 1558, 333, 1385, 259, 37, 4 ]
];


"Testing that the elements all power up correctly";
h1:=ProduceGroupElements(T41,El1);
h2:=ProduceGroupElements(T328,El2);
h3:=ProduceGroupElements(T328,El3);
h4:=ProduceGroupElements(T328,El4);
h5:=ProduceGroupElements(T1640,El5);

&and[h2[i]^2 eq h1[i]:i in [1..3]];
&and[h3[i]^2 eq h2[i]:i in [1..3]];
&and[h4[i]^2 eq h3[i]:i in [1..3]];
&and[h5[i]^5 eq h4[i]:i in [1..3]];

"Testing that 1640 and 328 have same number of eigenvalues";

&and[#Eigenvalues(h5[i]) eq #Eigenvalues(h4[i]):i in [1..3]];

if(Verbosity eq 1) then 
  [Eigenvalues(i):i in h4] eq Eigs1;
  [Eigenvalues(i):i in h3] eq Eigs2;
  [Eigenvalues(i):i in h2] eq Eigs3;
  [Eigenvalues(i):i in h1] eq Eigs4;
end if;

if(Verbosity ge 2) then for OneToCheck in [1..3] do

  Els1:=ConstructPreimages([8*i:i in El1[OneToCheck]],328,2);
  gg1:=ProduceGroupElements(T328,Els1);
  NextEls1:=[Els1[i]:i in [1..#Els1]|Eigenvalues(gg1[i]) eq Eigs3[OneToCheck]];
  "Showing that the",#NextEls1,"elements of order 82 that square to our element are conjugate.";
  gga:=ProduceGroupElements(T328,NextEls1);
  Orbs:={{i}:i in [1..#NextEls1]};
  for e in E do if(gga[1]^2*e eq e*gga[1]^2) then
    for i in [1..#NextEls1] do
      j:=Position(gga,gga[i]^e);
      Orb1:=FindOrb(Orbs,i);
      if(j ne 0 and not(j in Orb1)) then
        Orb2:=FindOrb(Orbs,j);
        Exclude(~Orbs,Orb1);
        Exclude(~Orbs,Orb2);
        Include(~Orbs,Orb1 join Orb2); //printf "Merged %o and %o.\n",Orb1,Orb2;
        delete Orb1; delete Orb2; if(#Orbs eq 1) then "All merged"; break e; end if;
      end if;
    end for;
    "So far we have merged elements into",#Orbs,"orbits"; end if;
  end for;
  delete gga;
  "Check that my element of order 82 is correct";
  El2[OneToCheck] eq NextEls1[1];

  Els2:=ConstructPreimages(El2[OneToCheck],328,2);
  gg2:=ProduceGroupElements(T328,Els2);
  NextEls2:=[Els2[i]:i in [1..#Els2]|Eigenvalues(gg2[i]) eq Eigs2[OneToCheck]];
  gga:=ProduceGroupElements(T328,NextEls2);

  if(OneToCheck eq 2) then "Only need to check that the two elements are conjugate because there are",#NextEls2,"preimages of order 164";
    for i in E do if(gga[1]^i eq gga[2]) then "Elements of order 164 are conjugate"; break i; end if; end for;
  end if;
  if(OneToCheck eq 1) then "Only have",#NextEls2,"preimages of order 164, one is the 83rd power of the other";
    gga[1]^83 eq gga[2];
  end if;
  if(OneToCheck eq 3) then
    Orbs:={{i}:i in [1..#NextEls2]};
    for e in E do if(gga[1]^2*e eq e*gga[1]^2) then
      for i in [1..#NextEls2] do
        j:=Position(gga,gga[i]^e);
        Orb1:=FindOrb(Orbs,i);
        if(j ne 0 and not(j in Orb1)) then
          Orb2:=FindOrb(Orbs,j);
          Exclude(~Orbs,Orb1);
          Exclude(~Orbs,Orb2);
          Include(~Orbs,Orb1 join Orb2); //printf "Merged %o and %o.\n",Orb1,Orb2;
          delete Orb1; delete Orb2; if(#Orbs eq 2) then "All merged into two orbits"; break e; end if;
        end if;
      end for;
      "So far we have merged elements into",#Orbs,"orbits"; end if;
    end for;
    "Checking that second orbit is power of first";
    {Position(gga,gga[i]^j):i in [1,3],j in [1,83]} eq {1..4};
    delete gga;
  end if;
  "Check that my element of order 164 is correct";
  El3[OneToCheck] eq NextEls2[1];

  Els3:=ConstructPreimages(El3[OneToCheck],328,2);
  gg3:=ProduceGroupElements(T328,Els3);
  NextEls3:=[Els3[i]:i in [1..#Els3]|Eigenvalues(gg3[i]) eq Eigs1[OneToCheck]];
  if(OneToCheck ne 2) then "There is only",#NextEls3,"element of order 328 above the element of order 164"; end if;

  gga:=ProduceGroupElements(T328,NextEls3);

  if(OneToCheck eq 2) then "Only need to check that the two elements are conjugate because there are",#NextEls2,"preimages of order 328";
    for i in E do if(gga[1]^i eq gga[2]) then "Elements of order 328 are conjugate"; break i; end if; end for;
  end if;

end for; end if;

if(Verbosity ge 4) then for OneToCheck in [1..3] do

Els4:=ConstructPreimages([5*i:i in El4[OneToCheck]],1640,5);
  for i in Els4 do 
    gg:=ProduceGroupElements(T1640,[i])[1];
    if #Eigenvalues(gg) eq #Eigs1[OneToCheck] and Order(gg) eq 1640 then "Case",OneToCheck,"is a blueprint"; i; break i; end if;
    delete gg;
  end for;

end for; end if;
