/* Here we let H denote a copy of SL(2,8) and L denote a copy of 2^3.7, the normalizer of a torus.
   This is unique up to conjugacy in G. First we set up L and H. L requires two matrices, and one
   more for H. We give them as elements of GL(27,5^6). Unfortunately, L is very far away from the
   the Magma version of E6. This means that the trilinear form is awful, and will hinder us with our
   calculations. We offer code to confirm that the trilinear form is as suggested, using the function
   CheckE6Form().

   We then construct the centralizer of L in GL(27,F). We can then launch into working out the
   coefficients necessary for the conjugate of h1 (the matrix for H) to lie in our copy of E6, i.e.,
   for the trilinear form to be h1-invariant. After a number of computations we arrive at exactly one
   solution.

   We provide the reader with j1, which normalizes L and H, the unique subgroup in E6, and therefore
   all N_GL(L)-conjugates are C_GL(L)-conjugates. We then prove that, in the algebraic group, the
   centralizers C_GL(H) and C_E6(L) together generate the collection of all matrices in C_GL(L) that
   conjugate h1 into E6.
*/

F<w1>:=GF(5^6);

l1:=GL(27,F)![[w1^2232,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,w1^13392,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^11160,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,w1^4464,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^6696,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^8928,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0]];

l2:=GL(27,F)![[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]];


h1:=GL(27,F)![[0,w1^14481,w1^6384,w1^8616,w1^3036,w1^5268,w1^15312,w1^9732,w1^4152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^5049,0,w1^12642,w1^10410,w1^366,w1^13758,w1^3714,w1^9294,w1^14874,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^5334,w1^14700,w1^7308,w1^10836,4,w1^12600,w1^8316,w1^13104,w1^10332,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^3102,w1^1308,w1^10836,1,w1^12600,w1^504,w1^5292,w1^2520,w1^7308,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^870,w1^3540,1,w1^4788,w1^504,w1^13104,w1^10332,w1^15120,w1^10836,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^14262,w1^5772,w1^4788,w1^8316,w1^13104,w1^2520,w1^7308,w1^3024,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^12030,w1^8004,w1^8316,w1^5292,w1^2520,w1^15120,w1^10836,4,w1^4788,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^9798,w1^10236,w1^5292,w1^10332,w1^15120,w1^3024,1,w1^12600,w1^8316,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^7566,w1^12468,w1^10332,w1^7308,w1^3024,4,w1^4788,w1^504,w1^5292,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,w1^1721,w1^10980,w1^6516,w1^9864,w1^5400,w1^8748,w1^12096,w1^15444,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^2185,0,w1^3586,w1^8050,w1^4702,w1^9166,w1^5818,w1^2470,w1^14746,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^738,w1^8132,w1^5292,w1^7308,4,w1^504,w1^10332,w1^3024,w1^4788,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^5202,w1^3668,w1^7308,1,w1^504,w1^2520,w1^10836,w1^12600,w1^5292,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^9666,w1^14828,1,w1^8316,w1^2520,w1^3024,w1^4788,w1^13104,w1^7308,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^14130,w1^10364,w1^8316,w1^10332,w1^3024,w1^12600,w1^5292,w1^15120,1,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^2970,w1^5900,w1^10332,w1^10836,w1^12600,w1^13104,w1^7308,4,w1^8316,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^7434,w1^1436,w1^10836,w1^4788,w1^13104,w1^15120,1,w1^504,w1^10332,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^11898,w1^12596,w1^4788,w1^5292,w1^15120,4,w1^8316,w1^2520,w1^10836,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^7755,w1^5245,w1^11941,w1^10825,w1^1897,w1^781,w1^15289,w1^14173],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^11775,0,w1^14137,w1^7441,w1^8557,w1^1861,w1^2977,w1^4093,w1^5209],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^6473,w1^13205,w1^10836,w1^5292,4,w1^2520,w1^4788,w1^15120,w1^8316],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^15401,w1^4277,w1^5292,1,w1^2520,w1^12600,w1^7308,w1^504,w1^10836],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^8705,w1^10973,1,w1^10332,w1^12600,w1^15120,w1^8316,w1^3024,w1^5292],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^2009,w1^2045,w1^10332,w1^4788,w1^15120,w1^504,w1^10836,w1^13104,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^10937,w1^8741,w1^4788,w1^7308,w1^504,w1^3024,w1^5292,4,w1^10332],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^4241,w1^15437,w1^7308,w1^8316,w1^3024,w1^13104,1,w1^2520,w1^4788],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^13169,w1^6509,w1^8316,w1^10836,w1^13104,4,w1^10332,w1^12600,w1^7308]];

L:=sub<GL(27,F)|l1,l2>;

j1:=GL(27,F)![[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^4048,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,w1^9068,0,0,0,0,0,0,0,0],
[0,0,0,0,w1^9559,0,0,0,0,0,0,0,0,w1^15384,0,0,0,0,0,0,0,0,w1^14225,0,0,0,0],
[0,0,0,0,0,0,w1^1747,0,0,0,0,0,0,0,0,w1^7572,0,0,0,0,0,0,0,0,w1^6413,0,0],
[0,0,0,0,0,0,0,0,w1^1747,0,0,0,0,0,0,0,0,w1^7572,0,0,0,0,0,0,0,0,w1^6413],
[0,0,0,w1^1747,0,0,0,0,0,0,0,0,w1^7572,0,0,0,0,0,0,0,0,w1^6413,0,0,0,0,0],
[0,0,0,0,0,w1^9559,0,0,0,0,0,0,0,0,w1^15384,0,0,0,0,0,0,0,0,w1^14225,0,0,0],
[0,0,0,0,0,0,0,w1^9559,0,0,0,0,0,0,0,0,w1^15384,0,0,0,0,0,0,0,0,w1^14225,0],
[0,0,w1^1747,0,0,0,0,0,0,0,0,w1^7572,0,0,0,0,0,0,0,0,w1^6413,0,0,0,0,0,0],
[0,w1^14679,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[w1^151,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,w1^3528,0,0,0,0,0,0,0,0,w1^8054,0,0,0,0,0,0,0,0,w1^1550,0,0,0,0],
[0,0,0,0,0,0,w1^11340,0,0,0,0,0,0,0,0,w1^242,0,0,0,0,0,0,0,0,w1^9362,0,0],
[0,0,0,0,0,0,0,0,w1^11340,0,0,0,0,0,0,0,0,w1^242,0,0,0,0,0,0,0,0,w1^9362],
[0,0,0,w1^11340,0,0,0,0,0,0,0,0,w1^242,0,0,0,0,0,0,0,0,w1^9362,0,0,0,0,0],
[0,0,0,0,0,w1^3528,0,0,0,0,0,0,0,0,w1^8054,0,0,0,0,0,0,0,0,w1^1550,0,0,0],
[0,0,0,0,0,0,0,w1^3528,0,0,0,0,0,0,0,0,w1^8054,0,0,0,0,0,0,0,0,w1^1550,0],
[0,0,w1^11340,0,0,0,0,0,0,0,0,w1^242,0,0,0,0,0,0,0,0,w1^9362,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,w1^7501,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,w1^11425,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,w1^12072,0,0,0,0,0,0,0,0,w1^10435,0,0,0,0,0,0,0,0,w1^12192,0,0,0,0],
[0,0,0,0,0,0,w1^4260,0,0,0,0,0,0,0,0,w1^2623,0,0,0,0,0,0,0,0,w1^4380,0,0],
[0,0,0,0,0,0,0,0,w1^4260,0,0,0,0,0,0,0,0,w1^2623,0,0,0,0,0,0,0,0,w1^4380],
[0,0,0,w1^4260,0,0,0,0,0,0,0,0,w1^2623,0,0,0,0,0,0,0,0,w1^4380,0,0,0,0,0],
[0,0,0,0,0,w1^12072,0,0,0,0,0,0,0,0,w1^10435,0,0,0,0,0,0,0,0,w1^12192,0,0,0],
[0,0,0,0,0,0,0,w1^12072,0,0,0,0,0,0,0,0,w1^10435,0,0,0,0,0,0,0,0,w1^12192,0],
[0,0,w1^4260,0,0,0,0,0,0,0,0,w1^2623,0,0,0,0,0,0,0,0,w1^4380,0,0,0,0,0,0]];

x:=GL(27,F)![[w1^5445,1,w1^13725,w1^8036,w1^4378,w1^7778,w1^15105,w1^11106,w1^15063,w1^1108,w1^3161,w1^4215,w1^8692,w1^10839,w1^5279,w1^11420,w1^14587,w1^1834,w1^5336,w1^5058,w1^14814,w1^7679,w1^693,w1^3420,w1^15101,w1^12294,w1^576],
[w1^10417,w1^14440,w1^4945,w1^12956,w1^145,w1^14294,w1^9750,w1^9529,w1^1219,w1^6960,w1^5525,w1^7,w1^14710,w1^13087,w1^6121,w1^12692,w1^2418,w1^2778,w1^12476,w1^456,w1^13637,w1^3761,w1^1120,w1^10708,w1^6617,w1^8206,w1^12112],
[w1^4171,w1^11002,w1^7987,w1^5150,w1^12979,w1^7352,w1^3120,w1^13219,w1^8581,w1^11490,w1^6863,w1^9529,w1^2128,w1^8425,w1^6139,w1^14174,w1^7308,w1^684,w1^8774,w1^5130,w1^6551,w1^9635,w1^6106,w1^11446,w1^2915,w1^11392,w1^15298],
[w1^6855,w1^11346,w1^10743,w1^9134,w1^11428,w1^2684,w1^13995,w1^7764,w1^12945,w1^7798,w1^12251,w1^7353,w1^9910,w1^1089,w1^2705,w1^15614,w1^1045,w1^10324,w1^4130,w1^12804,w1^6720,w1^209,w1^13047,w1^3102,w1^13895,w1^6216,w1^10122],
[w1^3796,w1^6703,w1^7252,w1^13899,w1^8753,w1^8889,w1^10432,w1^10897,w1^15430,w1^11747,w1^13704,w1^622,w1^2051,w1^262,w1^9414,w1^4035,w1^14786,w1^12401,w1^13791,w1^11905,w1^421,w1^9510,w1^2356,w1^3715,w1^7932,w1^3445,w1^7351],
[w1^754,w1^15289,w1^2410,w1^9605,w1^2218,w1^2159,w1^5727,w1^8218,w1^1636,w1^11865,w1^5558,w1^9712,w1^12175,w1^13360,w1^3082,w1^845,w1^1059,w1^7323,w1^6461,w1^9105,w1^13382,w1^12362,w1^2257,w1^10765,w1^602,w1^9415,w1^13321],
[w1^6258,w1^819,w1^6122,w1^5206,w1^969,w1^12262,w1^5897,w1^164,w1^11170,w1^277,w1^9182,w1^2021,w1^15201,w1^865,w1^5736,w1^5669,w1^10771,w1^14097,w1^11995,w1^12392,w1^5141,w1^2946,w1^7155,w1^8182,w1^370,w1^4276,0],
[w1^3861,w1^3440,w1^2216,w1^6440,w1^3402,w1^8174,w1^6285,w1^10191,w1^5206,w1^12190,w1^2326,w1^7241,w1^5044,w1^13486,w1^9958,w1^506,w1^13226,w1^12325,w1^13669,w1^14040,w1^15281,w1^5855,w1^4416,0,w1^13468,w1^14390,w1^2672],
[w1^15579,w1^11023,w1^2521,w1^13840,w1^1049,w1^6566,w1^1837,w1^2514,w1^13840,w1^6466,w1^1698,w1^14128,w1^13683,w1^12880,w1^12270,w1^12149,w1^8830,w1^14788,w1^1701,w1^5637,w1^15264,w1^7751,w1^1836,w1^10237,w1^2425,w1^6331,0],
[w1^928,w1^15579,w1^10333,w1^4956,w1^7302,w1^6478,w1^4113,w1^14184,w1^6432,w1^8929,w1^5515,w1^5710,w1^473,w1^8614,w1^2483,w1^3802,w1^15113,w1^11365,w1^12437,w1^1420,w1^9029,w1^14142,w1^15251,w1^12975,w1^5163,w1^9069,0],
[w1^2352,w1^5276,w1^11640,w1^13390,w1^5319,w1^6178,w1^13618,w1^10641,w1^12937,w1^6679,w1^2150,w1^12880,w1^10479,w1^9454,w1^10464,w1^11646,w1^9310,w1^10871,w1^3210,w1^11332,w1^3743,w1^7217,w1^11557,w1^6578,w1^14390,w1^2672,0],
[w1^6880,w1^13969,0,w1^5440,w1^13955,w1^8247,w1^4908,w1^3519,w1^1672,w1^4143,w1^14222,w1^3685,w1^8526,w1^15621,w1^2568,w1^9199,w1^15201,w1^1232,w1^10135,w1^6293,w1^6487,w1^12867,w1^5731,w1^13948,w1^4276,w1^12088,w1^370],
[w1^10414,w1^8566,w1^2216,w1^3691,w1^6282,w1^11370,w1^8125,w1^14933,w1^12632,w1^13263,w1^11421,w1^7281,w1^4342,w1^10943,w1^4510,w1^8248,w1^8248,w1^2379,w1^8284,w1^3996,w1^11239,w1^472,w1^3727,0,w1^10237,w1^2425,w1^6331],
[w1^11839,w1^13181,w1^5946,w1^12387,w1^5872,w1^2051,w1^4658,w1^10242,w1^3647,w1^3931,w1^6323,w1^14786,w1^11019,w1^14811,w1^3547,w1^5364,w1^6363,w1^3236,w1^25,w1^9990,w1^14988,w1^15043,w1^1795,w1^398,w1^8210,w1^12116,0],
[w1^7381,w1^1781,w1^2040,w1^6967,w1^11340,w1^5710,w1^11048,w1^14954,w1^12387,w1^9912,w1^8934,w1^15174,w1^9020,w1^13993,w1^5370,w1^10247,w1^3114,w1^5048,w1^5226,w1^9025,w1^8893,w1^5348,w1^10593,0,w1^10196,w1^11531,w1^15437],
[w1^3475,w1^3746,w1^1504,w1^12636,w1^1240,w1^7155,w1^10071,w1^1561,w1^12636,w1^14813,w1^5417,w1^1046,w1^4593,w1^4918,w1^10481,w1^15496,w1^13756,w1^15295,w1^7282,w1^13155,w1^6128,w1^9838,w1^9803,w1^7959,w1^147,w1^4053,0],
[w1^4582,w1^3475,w1^9316,w1^10537,w1^11642,w1^14074,w1^9111,w1^4090,w1^938,w1^9436,w1^1193,w1^14762,w1^12804,w1^9657,w1^7927,w1^13700,w1^15173,w1^7128,w1^9578,w1^7776,w1^866,w1^5978,w1^539,w1^871,w1^8683,w1^12589,0],
[w1^7933,w1^2417,w1^6146,w1^5606,w1^9024,w1^4833,w1^10457,w1^7573,w1^11920,w1^5475,w1^9788,w1^4918,w1^11208,w1^10004,w1^15299,w1^9091,w1^10799,w1^7097,w1^6730,w1^5274,w1^11935,w1^7806,w1^4199,w1^3719,w1^11531,w1^15437,0],
[w1^14720,w1^9732,0,w1^2164,w1^8994,w1^15569,w1^7754,w1^418,w1^9512,w1^14576,w1^2416,w1^10779,w1^9255,w1^2738,w1^1455,w1^13368,w1^11019,w1^1759,w1^2351,w1^11319,w1^11153,w1^6776,w1^7780,w1^1978,w1^12116,w1^4304,w1^8210],
[w1^1971,w1^1043,w1^2040,w1^7644,w1^7257,w1^11442,w1^15319,w1^9258,w1^12456,w1^8426,w1^10954,w1^13186,w1^8295,w1^2449,w1^13791,w1^12201,w1^12201,w1^7142,w1^6006,w1^2182,w1^6909,w1^13818,w1^1449,0,w1^7959,w1^147,w1^4053],
[w1^5863,w1^13181,w1^8327,w1^12318,w1^4247,w1^240,w1^8525,w1^12031,w1^14002,w1^2565,w1^9025,w1^1864,w1^704,w1^10590,w1^10733,w1^8743,w1^3196,w1^189,w1^14283,w1^7003,w1^12066,w1^8767,w1^2198,w1^9565,w1^1753,w1^5659,0],
[w1^2779,w1^4338,w1^4421,w1^5170,w1^9630,w1^4388,w1^8001,w1^11907,w1^12318,w1^11951,w1^2906,w1^12819,w1^1442,w1^9111,w1^1985,w1^15238,w1^6042,w1^14336,w1^5157,w1^9415,w1^7139,w1^3738,w1^4683,0,w1^8686,w1^14233,w1^2515],
[w1^14497,w1^13034,w1^7407,w1^4967,w1^7231,w1^12287,w1^14767,w1^12016,w1^4967,w1^8477,w1^10337,w1^7360,w1^2535,w1^13415,w1^10108,w1^13235,w1^6065,w1^10413,w1^1306,w1^364,w1^11688,w1^2692,w1^5147,w1^9998,w1^2186,w1^6092,0],
[w1^3216,w1^14497,w1^15219,w1^4561,w1^12198,w1^10800,w1^12110,w1^8491,w1^8432,w1^4554,w1^6569,w1^580,w1^5615,w1^4368,w1^6517,w1^10396,w1^2939,w1^10085,w1^12280,w1^14601,w1^7264,w1^12240,w1^4894,w1^11893,w1^4081,w1^7987,0],
[w1^1957,w1^5119,w1^13640,w1^14773,w1^7868,w1^4744,w1^7419,w1^6776,w1^2199,w1^13430,w1^9081,w1^13415,w1^3413,w1^2703,w1^4531,w1^5486,w1^1492,w1^3272,w1^2128,w1^13522,w1^10145,w1^12938,w1^8532,w1^6421,w1^14233,w1^2515,0],
[w1^8263,w1^12689,0,w1^5293,w1^2437,w1^12484,w1^1816,w1^10739,w1^3055,w1^11878,w1^5158,w1^10804,w1^1460,w1^10508,w1^10021,w1^4042,w1^704,w1^15586,w1^11518,w1^4605,w1^8119,w1^8083,w1^7547,w1^612,w1^5659,w1^13471,w1^1753],
[w1^1902,w1^11398,w1^4421,w1^15434,w1^3805,w1^5726,w1^3865,w1^1561,w1^14837,w1^12680,w1^9729,w1^15472,w1^461,w1^5705,w1^9456,w1^4367,w1^4367,w1^4095,w1^8045,w1^8577,w1^12587,w1^233,w1^3488,0,w1^9998,w1^2186,w1^6092]];

xd:=GL(27,F)!PermutationMatrix(F,\[19,1,20,10,2,11,3,4,5,6,7,8,9,12,13,14,15,16,17,18,21,22,23,24,25,26,27]);
x:=xd^-1*x;


seqs:=[[i,j,k]:i,j,k in [1..NumberOfRows(l1)]|i le j and j le k];

ents:=[54,63,72,79,88, 97, 103, 112, 121, 126, 135, 144, 148, 157, 166, 169, 178, 187, 189, 198, 207, 235, 243, 252, 259, 268, 274, 283, 288, 297, 301, 310,
313, 322, 324, 333, 334, 351, 358, 364, 369, 373, 376, 378, 388, 405, 414, 423, 430, 439, 448, 454, 463, 472, 477, 486, 495, 499, 508, 517, 520, 529, 538,
540, 549, 558, 568, 594, 603, 610, 619, 625, 634, 639, 648, 652, 661, 664, 673, 675, 684, 702, 709, 715, 720, 724, 727, 729, 737, 738, 746, 747, 757, 766,
775, 783, 792, 801, 809, 818, 825, 834, 843, 853, 862, 870, 879, 886, 895, 903, 912, 926, 927, 937, 946, 954, 963, 971, 978, 987, 997, 1005, 1012, 1020,
1036, 1044, 1050, 1061, 1062, 1070, 1071, 1081, 1090, 1099, 1108, 1117, 1131, 1140, 1146, 1155, 1164, 1173, 1182, 1187, 1196, 1204, 1213, 1222, 1231, 1241,
1242, 1252, 1261, 1270, 1284, 1290, 1299, 1308, 1313, 1321, 1330, 1342, 1353, 1360, 1361, 1369, 1370, 1380, 1389, 1398, 1406, 1415, 1428, 1437, 1444, 1453,
1464, 1473, 1481, 1490, 1501, 1510, 1514, 1523, 1531, 1532, 1542, 1551, 1559, 1572, 1579, 1590, 1598, 1609, 1613, 1623, 1635, 1636, 1644, 1645, 1655, 1664,
1673, 1680, 1689, 1701, 1710, 1718, 1727, 1735, 1744, 1749, 1758, 1772, 1782, 1791, 1797, 1798, 1808, 1817, 1824, 1836, 1844, 1852, 1857, 1872, 1880, 1887,
1888, 1896, 1897, 1909, 1918, 1931, 1940, 1950, 1959, 1967, 1976, 1984, 1993, 1996, 2005, 2018, 2027, 2036, 2040, 2041, 2053, 2066, 2076, 2084, 2092, 2095,
2108, 2117, 2118, 2126, 2127, 2139, 2148, 2161, 2170, 2178, 2187, 2193, 2202, 2210, 2219, 2221, 2230, 2242, 2252, 2261, 2262, 2274, 2287, 2295, 2301, 2309,
2311, 2326, 2327, 2335, 2336, 2352, 2361, 2369, 2378, 2381, 2390, 2399, 2408, 2417, 2425, 2434, 2445, 2454, 2461, 2462, 2478, 2486, 2489, 2498, 2506, 2525,
2550, 2559, 2566, 2575, 2581, 2590, 2595, 2604, 2608, 2617, 2620, 2629, 2631, 2640, 2658, 2665, 2671, 2676, 2680, 2683, 2685, 2703, 2712, 2719, 2728, 2734,
2743, 2748, 2757, 2761, 2770, 2773, 2782, 2784, 2793, 2811, 2818, 2824, 2829, 2833, 2836, 2838, 2846, 2847, 2857, 2866, 2874, 2883, 2891, 2898, 2907, 2917,
2925, 2932, 2940, 2956, 2964, 2970, 2981, 2982, 2992, 3001, 3010, 3024, 3030, 3039, 3048, 3053, 3061, 3070, 3082, 3093, 3100, 3101, 3111, 3120, 3128, 3141,
3148, 3159, 3167, 3178, 3182, 3192, 3204, 3205, 3215, 3224, 3231, 3243, 3251, 3259, 3264, 3279, 3287, 3294, 3295, 3307, 3320, 3330, 3338, 3346, 3349, 3362,
3371, 3372, 3384, 3397, 3405, 3411, 3419, 3421, 3436, 3437, 3453, 3461, 3464, 3473, 3481, 3507, 3514, 3520, 3525, 3529, 3532, 3534, 3543, 3550, 3556, 3561,
3565, 3568, 3570, 3580, 3588, 3594, 3607, 3618, 3627, 3641 ];

vals:=[1,w1^2537,w1^12273, w1^13392, w1^305, w1^10041, w1^11160, w1^13697, w1^7809, w1^8928, w1^11465, w1^5577, w1^6696, w1^9233, w1^3345, w1^4464, w1^7001,
w1^1113, w1^2232, w1^4769, w1^14505, w1^13413, w1^5074, w1^14810, w1^2842, w1^12578, w1^610, w1^10346, w1^14002, w1^8114, w1^11770, w1^5882, w1^9538,
w1^3650, w1^7306, w1^1418, w1^8962, w1^8922, w1^6690, w1^4458, w1^2226, w1^15618, w1^13386, w1^11154, w1^11625, w1^13444, w1^15200, w1^2869, w1^52, w1^1808,
w1^5101, w1^2284, w1^4040, w1^7333, w1^4516, w1^6272, w1^9565, w1^6748, w1^8504, w1^11797, w1^8980, w1^10736, w1^14029, w1^11212, w1^12968, w1^637, w1^8308,
w1^2652, w1^8008, w1^4884, w1^10240, w1^7116, w1^12472, w1^9348, w1^14704, w1^11580, w1^1312, w1^13812, w1^3544, w1^420, w1^5776, w1^8566, w1^10798,
w1^13030, w1^15262, w1^1870, w1^4102, w1^6334, w1^14657, w1^9849, w1^1413, w1^1334, w1^9952, w1^12383, w1^11432, w1^9952, w1^14006, w1^4114, w1^11573,
w1^14781, w1^9952, w1^11573, w1^14781, w1^14006, w1^4114, w1^12383, w1^11432, w1^3748, w1^10422, w1^625, w1^10059, w1^5794, w1^3629, w1^4510, w1^5951,
w1^13559, w1^12833, w1^3919, w1^2486, w1^290, w1^8811, w1^13214, w1^4866, w1^15431, w1^3752, w1^14423, w1^14356, w1^3497, w1^5385, w1^10341, w1^8030,
w1^9952, w1^12383, w1^11432, w1^14006, w1^4114, w1^11573, w1^14781, w1^9952, w1^11573, w1^14781, w1^14006, w1^4114, w1^8212, w1^14886, w1^11785, w1^5595,
w1^13559, w1^13214, w1^14722, w1^10325, w1^4510, w1^5951, w1^12833, w1^3919, w1^2486, w1^290, w1^8811, w1^13794, w1^6503, w1^14423, w1^3752, w1^14356,
w1^7961, w1^921, w1^3645, w1^14726, w1^9952, w1^12383, w1^11432, w1^14006, w1^4114, w1^11573, w1^14781, w1^11573, w1^14781, w1^12676, w1^3726, w1^7321,
w1^1131, w1^2486,w1^8811, w1^13559, w1^13214, w1^8026, w1^1397, w1^4510, w1^5951, w1^12833, w1^3919, w1^290, w1^7098, w1^13199, w1^14356, w1^14423, w1^3752,
w1^12425, w1^12081, w1^12573, w1^5798, w1^9952, w1^12383, w1^11432, w1^14006, w1^4114, w1^11573, w1^14781, w1^1516, w1^8190, w1^2857, w1^12291, w1^2486,
w1^290, w1^8811, w1^13559, w1^13214, w1^1330, w1^8093, w1^4510, w1^5951, w1^12833, w1^3919, w1^402, w1^4271, w1^14356, w1^14423, w1^3752, w1^1265, w1^7617,
w1^5877, w1^12494, w1^12383, w1^11432, w1^14006, w1^4114, w1^5980, w1^12654, w1^14017, w1^7827, w1^4510, w1^3919, w1^2486, w1^290, w1^8811, w1^13559,
w1^13214, w1^10258, w1^14789, w1^5951, w1^12833, w1^9330, w1^10967, w1^3752, w1^14356, w1^14423, w1^5729, w1^3153, w1^14805, w1^3566, w1^12383, w1^11432,
w1^10444, w1^1494, w1^9553, w1^3363, w1^13559, w1^12833, w1^4510, w1^3919, w1^2486, w1^290, w1^8811, w1^13214, w1^3562, w1^5861, w1^5951, w1^2634, w1^2039,
w1^14423, w1^3752, w1^14356, w1^10193, w1^14313, w1^8109, w1^10262, w1^14908, w1^5958, w1^5089, w1^14523, w1^4510, w1^5951, w1^13559, w1^12833, w1^3919,
w1^2486, w1^290, w1^8811, w1^13214, w1^12490, w1^12557, w1^11562, w1^8735, w1^3752, w1^14423, w1^14356, w1^5536, w1^7970, w1^8213, w1^12434, w1^12677,
w1^1274,w1^1517, w1^5738, w1^5981, w1^10202, w1^10445, w1^14666, w1^14909, w1^3506, w1^3749, w1^11516, w1^356, w1^4820, w1^9284, w1^13748, w1^2588, w1^7052,
w1^7025, w1^835, w1^2561, w1^11995, w1^13721, w1^7531, w1^9257, w1^3067, w1^4793, w1^14227, w1^329, w1^9763, w1^11489, w1^5299, w1^10269, w1^5805, w1^1341,
w1^12501, w1^8037, w1^3573, w1^14733, w1^10108, w1^5924, w1^5560, w1^5081, w1^5560, w1^4839, w1^9515, w1^5560, w1^9515, w1^4839, w1^5081, w1^1543, w1^2102,
w1^1995, w1^13309, w1^642, w1^3412, w1^12620, w1^5560, w1^5081, w1^4839, w1^9515, w1^5560, w1^9515, w1^4839, w1^10471, w1^8798, w1^13309, w1^1995, w1^642,
w1^12340, w1^3692, w1^5560, w1^5081, w1^4839, w1^9515, w1^9515, w1^3775, w1^15494, w1^642, w1^13309, w1^1995, w1^5644, w1^10388, w1^5560, w1^5081, w1^4839,
w1^9515, w1^12703, w1^6566, w1^642, w1^13309, w1^1995, w1^14572, w1^1460, w1^5081, w1^4839, w1^6007, w1^13262, w1^1995, w1^642, w1^13309, w1^7876, w1^8156,
w1^5081, w1^14935, w1^4334, w1^13309, w1^1995, w1^642, w1^1180, w1^14852, w1^8239, w1^11030, w1^1995, w1^13309, w1^642, w1^96, w1^9024, w1^2328, w1^11256,
w1^4560, w1^13488, w1^6792, w1^13904, w1^4976, w1^11672, w1^2744, w1^9440, w1^512, w1^7208, w1^5284, w1^5284, w1^5284, w1^5284, w1^5284, w1^5284, w1^5284 ];

f27:=[F!0:i in [1..#seqs]];
for i in [1..#ents] do f27[ents[i]]:=vals[i]; end for;

R<a,b,c,d,e,f,m1,m2,m3,m4,m5,m6,m7,m8,m9>:=PolynomialRing(F,15);
mats:=MatrixRing(R,NumberOfRows(l1));

scal:=mats!1;
scal[1,1]:=a;
scal[2,2]:=b;
scal[10,10]:=c;
scal[11,11]:=d;
scal[19,19]:=e;
scal[20,20]:=f;
for i in [3..9] do scal[i,i]:=m1; scal[i+9,i+9]:=m5; scal[i+18,i+18]:=m9; scal[i,i+9]:=m2; scal[i,i+18]:=m3; scal[i+9,i]:=m4; scal[i+9,i+18]:=m6; scal[i+18,i]:=m7; scal[i+18,i+9]:=m8; end for;

scal*mats!l1 eq mats!l1*scal and scal*mats!l2 eq mats!l2*scal;


function Matricise(v)
return Matrix(1,NumberOfColumns(v),[R!v[i]:i in [1..NumberOfColumns(v)]]);
end function;

// We now show that g, which is the second generator of H (the first lies in L, so is fine) satisfies the equations mentioned
V:=GModule(L);
g:=mats!h1;


intseqs1:=[seqs[i]:i in ents];
intseqs:=&join{{[i[1],i[2],i[3]],[i[1],i[3],i[2]],[i[2],i[1],i[3]],[i[2],i[3],i[1]],[i[3],i[1],i[2]],[i[3],i[2],i[1]]}:i in intseqs1};

function ProdRel(seq)

u:=V.seq[1]; v:=V.seq[2]; w:=V.seq[3];
u1:=Matricise(u)*scal; v1:=Matricise(v)*scal; w1:=Matricise(w)*scal;
u2:=Matricise(u)*g*scal; v2:=Matricise(v)*g*scal; w2:=Matricise(w)*g*scal;
e1:=&+[u1[1,i[1]]*v1[1,i[2]]*w1[1,i[3]]*f27[Position(seqs,Sort([i[1],i[2],i[3]]))]:i in intseqs];
e2:=&+[u2[1,i[1]]*v2[1,i[2]]*w2[1,i[3]]*f27[Position(seqs,Sort([i[1],i[2],i[3]]))]:i in intseqs];

return e1-e2;
end function;

function CheckRel(seq,gg)
u:=V.seq[1]; v:=V.seq[2]; w:=V.seq[3];
u1:=Matricise(u); v1:=Matricise(v); w1:=Matricise(w);
u2:=Matricise(u)*mats!gg; v2:=Matricise(v)*mats!gg; w2:=Matricise(w)*mats!gg;
e1:=&+[u1[1,i[1]]*v1[1,i[2]]*w1[1,i[3]]*f27[Position(seqs,Sort([i[1],i[2],i[3]]))]:i in intseqs];
e2:=&+[u2[1,i[1]]*v2[1,i[2]]*w2[1,i[3]]*f27[Position(seqs,Sort([i[1],i[2],i[3]]))]:i in intseqs];
return e1-e2;
end function;

function CheckRelScal(seq)
u:=V.seq[1]; v:=V.seq[2]; w:=V.seq[3];
u1:=Matricise(u); v1:=Matricise(v); w1:=Matricise(w);
u2:=Matricise(u)*scal; v2:=Matricise(v)*scal; w2:=Matricise(w)*scal;
e1:=&+[u1[1,i[1]]*v1[1,i[2]]*w1[1,i[3]]*f27[Position(seqs,Sort([i[1],i[2],i[3]]))]:i in intseqs];
e2:=&+[u2[1,i[1]]*v2[1,i[2]]*w2[1,i[3]]*f27[Position(seqs,Sort([i[1],i[2],i[3]]))]:i in intseqs];
return e1-e2;
end function;

coeffs0:=[a,b,c,d,e,f,m1,m2,m3,m4,m5,m6,m7,m8,m9];

function ChangeCoefficient(coeffs,coeff,target)
coeffs2:=coeffs;
nn:=Position(coeffs0,coeff);
coeffs2[nn]:=target;
return [Evaluate(i,coeffs2):i in coeffs];
end function;

function ChangeCoefficients(coeffs,coeff,target)
coeffs2:=coeffs;
for i in [1..#coeff] do
  nn:=Position(coeffs0,coeff[i]);
  coeffs2[nn]:=target[i];
end for;
return [Evaluate(i,coeffs2):i in coeffs];
end function;


function CheckDetermination()

ProdRel([1,1,3]) eq w1^271*(m1+w1^2295*m2+w1^14097*m3)*(m1 + w1^2537*m2 + w1^12273*m3)*(b + w1^4686*m1 + w1^11086*m2 + w1^4896*m3);
// Thus m1 is one of three options. Two of these yield contradictions quickly.
badcoeffs1a:=ChangeCoefficient(coeffs0,m1,-(w1^2537*m2 + w1^12273*m3));
badcoeffs1b:=ChangeCoefficient(coeffs0,m1,-(w1^2295*m2 + w1^14097*m3));
Evaluate(ProdRel([2,2,11]),badcoeffs1a) eq w1^11625*b^2*d;
Evaluate(ProdRel([1,2,3]),badcoeffs1b) eq w1^1089*a*(m2+w1^3710*m3)^2;
badcoeffs2b:=ChangeCoefficient(badcoeffs1b,m2,-w1^3710*m3);
Evaluate(ProdRel([2,2,11]),badcoeffs2b) eq w1^11625*b^2*d;
// This kills off those two branches, and so we must have that m1=-(w1^3126*b+w1^14212*m2+w1^8022*m3).

// We now, without comment, do the same thing for m4:
ProdRel([11,11,12]) eq w1^10942*(m4 + w1^2537*m5 + w1^12273*m6)*(m4 + w1^6400*m5 + w1^210*m6)*(c + w1^12971*m4 + w1^15266*m5 + w1^11444*m6);
badcoeffs1c:=ChangeCoefficient(coeffs0,m4,-(w1^6400*m5 + w1^210*m6));
badcoeffs1d:=ChangeCoefficient(coeffs0,m4,-(w1^2537*m5 + w1^12273*m6));
Evaluate(ProdRel([10,10,20]),badcoeffs1c) eq w1^5536*c^2*f;
Evaluate(ProdRel([10,10,12]),badcoeffs1d) eq w1^2712*d*(m5+w1^12486*m6)^2;
badcoeffs2d:=ChangeCoefficient(badcoeffs1d,m5,-w1^12486*m6);
Evaluate(ProdRel([10,10,20]),badcoeffs2d) eq w1^5536*c^2*f;

// and for m7:
ProdRel([20,20,21]) eq w1^4447*(m7 + w1^2295*m8 + w1^14097*m9)*(m7 + w1^6400*m8 + w1^210*m9)*(e + w1^11552*m7 + w1^14089*m8 + w1^8201*m9);
badcoeffs1e:=ChangeCoefficient(coeffs0,m7,-(w1^2295*m8 + w1^14097*m9));
badcoeffs1f:=ChangeCoefficient(coeffs0,m7,-(w1^6400*m8 + w1^210*m9));
Evaluate(ProdRel([1,19,19]),badcoeffs1e) eq w1^8962*a*e^2;
Evaluate(ProdRel([19,19,21]),badcoeffs1f) eq w1^262*f*(m8+w1^5406*m9)^2;
badcoeffs2f:=ChangeCoefficient(badcoeffs1f,m8,-w1^5406*m9);
Evaluate(ProdRel([1,19,19]),badcoeffs2f) eq w1^8962*a*e^2;

coeffs1:=ChangeCoefficients(coeffs0,[m1,m4,m7],[-(b+w1^11086*m2+w1^4896*m3)/w1^4686,-(c+w1^15266*m5+w1^11444*m6)/w1^12971,-(e+w1^14089*m8+w1^8201*m9)/w1^11552]);

eq1:=a*e+w1^5698*b*e+w1^9319*b*m8+w1^9741*b*m9+w1^15345*e*m2+w1^5127*e*m3+w1^517*m2*m8+w1^13003*m2*m9+w1^5923*m3*m8+w1^2785*m3*m9;
Evaluate(ProdRel([2,20,21]),coeffs1) eq w1^1011*e*eq1;
eq2:=a*e+w1^8302*b*e+w1^1114*b*m8+w1^4537*b*m9+w1^8184*e*m2+w1^13590*e*m3+w1^8980*m2*m8+w1^5842*m2*m9+w1^14386*m3*m8+w1^11248*m3*m9;
Evaluate(ProdRel([2,2,21]),coeffs1) eq w1^9451*(b+w1^1742*m2+w1^14228*m3)*eq2;
// Assume that m3=w1^9208*b+w1^10950*m2, so the term in brackets.

badcoeffs2:=ChangeCoefficient(coeffs1,m3,w1^9208*b+w1^10950*m2);
Evaluate(ProdRel([1,3,12]),badcoeffs2) eq w1^2066*b^2*d;
// Thus eq1 and eq2 hold.

w1^8950*eq1-w1^487*eq2 eq w1^6997*a*e + w1^5534*b*e + w1^4102*b*m8-b*m9;
// WLOG we set b to be 1, and therefore obtain an equation for m9.

coeffs2:=ChangeCoefficients(coeffs1,[b,m9],[1,w1^6997*a*e+w1^5534*e+w1^4102*m8]);

Evaluate(ProdRel([12,19,20]),coeffs2) eq w1^251*c*e*(w1^8730*a*e+w1^7727*a*f+w1^11998*e-m8);
coeffs3:=ChangeCoefficient(coeffs2,m8,w1^8730*a*e+w1^7727*a*f+w1^11998*e);

Evaluate(ProdRel([2,20,21]),coeffs3) eq w1^9790*a*e*(w1^7496*e+w1^2406*f*m2+w1^4477*f-f*m3);
// WLOG we set f=1 now w1^7496*e+w1^2406*m2+w1^4477-m3

coeffs4:=ChangeCoefficients(coeffs3,[f,m3],[1,w1^7496*e+w1^2406*m2+w1^4477]);

Evaluate(w1^1953*ProdRel([12,19,25])+w1^15019*ProdRel([10,19,21])+w1^454*ProdRel([12,25,26]),coeffs4) eq a*(c*e-w1^14422*a*d);
// WLOG also set c=1. Now we have quotiented out by the centralizer in GL(26,k) of H.
coeffs5:=ChangeCoefficients(coeffs4,[c,e],[1,w1^14422*a*d]);

Evaluate(ProdRel([1,2,21]),coeffs5)/w1^14189 eq a^2*d*(w1^326*a*d+w1^13359*d+w1^3129-m2);
coeffs6:=ChangeCoefficient(coeffs5,m2,w1^326*a*d+w1^13359*d+w1^3129);

eq1:=a*m5+w1^3710*a*m6+w1^7825*a+w1^13523;
eq2:=d*m5+w1^5406*d*m6+w1^1598*d+w1^1231*m5+w1^4941*m6+w1^9056;

Evaluate(ProdRel([1,3,10]),coeffs6)/w1^14031 eq d*eq1;
Evaluate(ProdRel([3,10,11]),coeffs6)/w1^11525 eq eq2;

// So both eq1 and eq2 are zero.

// Eliminating m5 using
// m5=-(w1^3710*m6+w1^7825+w1^13523/a)
// yields w1^2652*a*d*m6 + w1^3826*a*d + w1^5711*d + w1^6942, so
// m6=(w1^8986*a*d + w1^10871*d + w1^12102)/a*d=w1^8986+w1^10871/a+w1^12102/a/d.
// m5=w1^13660+w1^8465/a+w1^8000/a/d.

// One can evaluate all relations with these values for m5 and m6, and we obtain 0 for all co-ordinates. Thus h1^s is in 
// E6 for any s from Evaluate(scal,coeffs6). We choose one to demonstrate this:

coeffs7:=ChangeCoefficients(coeffs6,[a,d,m5,m6],[1,1,-w1^1465,-w1^12311]);

sca1:=Evaluate(scal,coeffs7);
h11:=h1^GL(27,F)!sca1;
{CheckRel(i,h11):i in seqs} eq {0};

sca6:=Evaluate(scal,coeffs6);
scasub:=sca1^-1*sca6;

// scasub is now the matrices sca10 transported so they map h11 to the other possible options for h11.

// Need that scasub*C_GL(H)=C_E6(L)*C_GL(H).
// Alternatively that (any element of scasub)*(some element of C_E6(L)) lies in C_GL(H) and vice versa.

// We now compute the centralizer of L in E6.

CheckRel([20,21,21],scal)/w1^13904-CheckRel([10,10,20],scal)/w1^5536 eq f*(c+w1^1527*m7+w1^3822*m8+m9)*(c+w1^9339*m7+w1^11634*m8-m9);
// Since f ne 0, we obtain an answer for m9.
c1a:=[a,b,c,d,e,f,m1,m2,m3,m4,m5,m6,m7,m8,-(c + w1^1527*m7 + w1^3822*m8)];
c1b:=[a,b,c,d,e,f,m1,m2,m3,m4,m5,m6,m7,m8,c+w1^9339*m7+w1^11634*m8];

Evaluate(CheckRel([3,20,21],scal),c1a)/w1^15431-CheckRel([10,10,20],scal)/w1^5536 eq c*f*(c+m1+w1^2295*m2+w1^14097*m3);
Evaluate(CheckRel([3,20,21],scal),c1b)/w1^15431+CheckRel([10,10,20],scal)/-w1^5536 eq c*f*(c+4*m1+w1^10107*m2+w1^6285*m3);

c2a:=ChangeCoefficient(c1a,m1,-(c+w1^2295*m2+w1^14097*m3));
c2b:=ChangeCoefficient(c1b,m1,c+w1^10107*m2+w1^6285*m3);

// Now we can kill off branch a:
Evaluate(CheckRel([3,3,10],scal)-w1^12517*CheckRel([3,4,6],scal),c2a) eq w1^2939;

Evaluate(CheckRel([2,3,3],scal),c2b)/-w1^13444-CheckRel([2,10,19],scal)/w1^496 eq w1^10452*b*c*(w1^5172*c+w1^12984*e+w1^11522*m3 - m2);
Evaluate(CheckRel([3,12,20],scal),c2b)/w1^3629-CheckRel([10,10,20],scal)/w1^5536 eq w1^11802*f*c*(w1^3822*c + w1^9339*m4 + w1^11634*m5 - m6);
Evaluate(CheckRel([2,21,21],scal),c2b)/-w1^8566-CheckRel([2,10,19],scal)/w1^496 eq w1^15045*b*c*(w1^579*c + w1^8391*e + w1^3995*m7 - m8);

c3:=ChangeCoefficients(c2b,[m2,m6,m8],[w1^5172*c+w1^12984*e+w1^11522*m3,w1^3822*c+w1^9339*m4+w1^11634*m5,w1^579*c+w1^8391*e+w1^3995*m7]);

Evaluate(CheckRel([3,3,10],scal)/w1^14657+CheckRel([2,10,19],scal)/w1^496,c3) eq w1^11519*c*e*(w1^4105*b+w1^14145*c+w1^2520*e-m3);
Evaluate(CheckRel([12,12,19],scal)/w1^10108+CheckRel([2,10,19],scal)/w1^496,c3) eq w1^19*c*e*(w1^15605*b+w1^5425*c+w1^9381*m4-m5);
Evaluate(CheckRel([10,21,21],scal)/w1^11516+CheckRel([2,10,19],scal)/w1^496,c3) eq w1^3782*c*e*(w1^11842*b+w1^13834*c+w1^3006*e-m7);

c4:=ChangeCoefficients(c3,[m3,m5,m7],[w1^4105*b+w1^14145*c+w1^2520*e,w1^15605*b+w1^5425*c+w1^9381*m4,w1^11842*b+w1^13834*c+w1^3006*e]);

Evaluate(CheckRel([1,3,12],scal)/w1^2537+CheckRel([1,19,19],scal)/w1^1150,c4) eq w1^6730*a*e*(w1^2408*b+w1^2032*c+w1^8894*e-m4);

c5:=ChangeCoefficient(c4,m4,w1^2408*b+w1^2032*c+w1^8894*e);

// All equations now collapse to ae^2=c^2f=b^2d=adf=bce=1. Just as in the case p=3 that was done in the previous paper.

// Now we show that any element of scasub can be producted with some element of C_E6(L) to lie in C_GL(H) and
// vice versa, to make the bijection referred to at the start of this function.
// First, we label our elements of scasub with a, b, c and d, and C_E6(L) with m1, m2 and m3, to distinguish them.
// Then we force the product of them to commute with h11 and find the relations.
ctest1:=ChangeCoefficients(coeffs6,[a,d,m5,m6],[a,b,c,d]);
ctest2:=ChangeCoefficients(c5,[a,b,c,d,e,f],[m1,m2,m3,m4,m5,m6]);

// The equations from above that are satisfied are
// c=w1^13660+w1^8465/a+w1^8000/a/b.
// d=w1^8986+w1^10871/a+w1^12102/a/b.
// m1*m5^2=m3^2*m6=m2^2*m4=m1*m4*m6=m2*m3*m5=1

// This is all elements X of C_GL(L) that map h11 into E6, modulo C_GL(H)
scat1:=mats!sca1^-1*Evaluate(scal,ctest1);

// This is all elements of C_E6(L), modulo C_GL(H).
scat2:=Evaluate(scal,ctest2);

scat12:=scat1*scat2;

scadiff:=scat12*mats!h11-mats!h11*scat12;
scaents:=Sort([scadiff[i,j]:i,j in [1..27]]);

// Here is a solution for m1 and m2 in terms of n1,n2,n3.
// Claim that a=m2/m1=m2*m5^2, b=m3/m4=m2/m5 is the solution

// First, evaluate the coefficients other than a,b,m2,m5.

s2:=[Evaluate(i,[a,b,w1^13660+w1^8465/a+w1^8000/a/b,w1^8986+w1^10871/a+w1^12102/a/b,0,0,1/m5^2,m2,1/m2/m5,1/m2^2,m5,m2^2*m5^2,0,0,0]):i in scaents];

// Then impose the relation and check that everything is zero.
{Evaluate(i,[m2*m5^2,m2/m5,0,0,0,0,0,m2,0,0,m5,0,0,0,0]):i in s2} eq {0};

// Now note that the map (n1,n2) -> (n1*n2^2,n1/n2) is a homomorphism on F_q^x x F_q^x, with kernel (z,z) for z a cube root of 1.
// (This assumes that z lies in F_q. If it does not, then the map is bijective.)

// Thus the image is exactly one third of F_q^x x F_q^x, of course a subgroup.

// If x,y in F_q^x, let d and e be cube roots of them. Note that

// (d*e^2,d*e^-1) -> (d*e^2*d^2*e^-2=d^3=x,d*e^2/d/e^-1=e^3=y),

// so as long as x,y have cube roots in F_q, they lie in the image. In particular, this map is surjective on the algebraic closure.
// (One also sees that because the kernel is finite.)

// Therefore X=C_E6(L) mod C_GL(H), as needed.

// The element j11 lies in E6 and normalizes L, proving that we only need to worry about C_G(L)-conjugacy rather than N_G(L)-conjugacy.

return "";
end function;

// As we constructed L inside G2, we use this group to find the trilinear form for E6 below.

function CheckE6Form()

qq:=25;
FF<ww>:=GF(qq);
e:=ww^9;
a1:=FF!1;
a2:=(-1+e)*a1/2;
tt:=FF!1;
GG:=GroupOfLieType("E6",qq);
a1:=FF!1; a2:=ww^13; tt:=FF!1;
y1:=elt<GG|<1,tt>>*elt<GG|<3,tt>>*elt<GG|<7,-tt^2/2>>*elt<GG|<2,tt>>*elt<GG|<5,tt>>
 *elt<GG|<6,tt>>*elt<GG|<11,-tt^2/2>>;
y2:=elt<GG|<1+36,2*tt>>*elt<GG|<3+36,2*tt>>*elt<GG|<7+36,2*tt^2>>*elt<GG|<2+36,tt>>
 *elt<GG|<5+36,2*tt>>*elt<GG|<6+36,2*tt>>*elt<GG|<11+36,2*tt>>;
y3:=elt<GG|<9,a1*tt>>*elt<GG|<8,a2*tt>>*elt<GG|<10,(a1+a2/2)*tt>>;
y4:=elt<GG|<9+36,tt/a1>>*elt<GG|<8+36,tt/a2>>*elt<GG|<10+36,tt/(1+a2/2)>>;

Over:=GL(27,qq);
rho:=StandardRepresentation(GG);
HH:=sub<Over|[rho(i):i in [y1,y2,y3,y4]]>;
// There's a single class of 8.7s in G2(5), from Kleidman. Might as well confirm it.
#Subgroups(HH:OrderEqual:=56) eq 1;

Over!(l1^x) in HH and Over!(l2^x) in HH;

mat:=[];
for h in [l1,l2] do
  for nn in [1..#seqs] do aa:=seqs[nn,1]; bb:=seqs[nn,2]; cc:=seqs[nn,3];
    val:=[F!0:i in [1..#seqs]];
    for i in [1..NumberOfRows(h)] do if(h[aa,i] ne 0) then for j in [1..NumberOfRows(h)] do if(h[bb,j] ne 0) then for k in [1..NumberOfRows(h)] do
      val[Position(seqs,Sort([i,j,k]))]+:=h[aa,i]*h[bb,j]*h[cc,k];
    end for; end if; end for; end if; end for;
    val[nn]-:=1; Append(~mat,val); delete val;
  end for;
end for;

repeat
  g:=Random(GG); h:=x*GL(27,F)!rho(g)*x^-1;
  for iter in [1..36] do
    nn:=Random([1..#seqs]); aa:=seqs[nn,1]; bb:=seqs[nn,2]; cc:=seqs[nn,3];
      val:=[F!0:i in [1..#seqs]];
      for i in [1..NumberOfRows(h)] do if(h[aa,i] ne 0) then for j in [1..NumberOfRows(h)] do if(h[bb,j] ne 0) then for k in [1..NumberOfRows(h)] do
        val[Position(seqs,Sort([i,j,k]))]+:=h[aa,i]*h[bb,j]*h[cc,k];
      end for; end if; end for; end if; end for;
    val[nn]-:=1; Append(~mat,val); delete val;
    Nu:=Nullspace(Transpose(Matrix(F,mat)));
  end for;
until Dimension(Nu) eq 1;
ftest:=Nu.1;
return &and[ftest[i] eq f27[i]:i in [1..#seqs]];
end function;

"The function CheckE6Form() checks that the trilinear form f27 from E6 is correct";
"The function CheckDetermination() checks that the determination of the possible conjugates into E6 is correct.";