#
# cls 66: A_2
#
handle66char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[66];
    info:=infos[66];

    rep:=Representative(o);
    #pr[19]=[0,0,1,1,1,0,0,0]
    #pr[17]=[0,1,1,1,0,0,0,0]
    #pr[37]=[1,1,1,2,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[19,17,37]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1]]);
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[19,17,37]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1]]);
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 64: A_2A_1
#
handle64char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[64];
    info:=infos[64];

    rep:=Representative(o);
    #pr[53]=[1,1,1,2,1,1,1,0]
    #pr[52]=[1,1,1,2,2,1,0,0]
    #pr[93]=[1,2,3,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[53,52,93]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[53,52,93]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 60: A_2^2
#
handle60char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[60];
    info:=infos[60];

    rep:=Representative(o);
    #pr[43]=[0,0,1,1,1,1,1,1]
    #pr[41]=[0,1,1,1,1,1,1,0]
    #pr[79]=[1,1,1,2,2,2,2,1]
    tmp1:=ApplyRootsReflections(rep,[43,41,79]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[43,41,79]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 57: D_4(a_1)
#
handle57char5:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[57];
    info:=infos[57];

    rep:=Representative(o);
    #pr[4] =[0,0,0,1,0,0,0,0]
    #pr[51]=[1,1,2,2,1,1,0,0]
    #pr[52]=[1,1,1,2,2,1,0,0]
    tmp1:=ApplyRootsReflections(rep,[4,51,52]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[5,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,1,2,6],[-1,-1,-1,-1]);

    #pr[26]=[0,1,0,1,1,1,0,0]
    #pr[27]=[0,0,1,1,1,1,0,0]
    tmp3:=ApplyRootsReflections(rep,[26,27]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1],[4,1],[5,-1],[11,1],[12,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[4,51,52]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[5,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,1,2,6],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[26,27]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1],[4,1],[5,-1],[11,1],[12,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 53: D_4(a_1)A_1 Ross' rep
#
handle53char5:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[53];
    info:=infos[53];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    tmp1:=ConjNegUa(tmp1,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2],[-1,-1,-1,-1]);

    #pr[65]=[1,1,2,2,1,1,1,1]
    #pr[67]=[1,1,1,2,2,1,1,1]
    tmp3:=ApplyRootsReflections(rep,[65,67,4]);
    uu:=Unipotent(chevalleyAdj(rep),[[12,-1],[11,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[1,2,4,6,8],[-1,-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    tmp2:=ConjNegUa(tmp2,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[65,67,4]);
    uu:=Unipotent(chevalleyAdj(cent),[[12,-1],[11,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[1,2,4,6,8],[-1,-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 52: A_3A_2 [3,4,2,6,7]
#
handle52char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[52];
    info:=infos[52];

    rep:=Representative(o);

    #pr[26]=[0,1,0,1,1,1,0,0]
    #pr[27]=[0,0,1,1,1,1,0,0]
    #pr[55]=[0,1,1,2,2,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[26,27,55]);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1],[3,1],[6,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,6],[-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[26,27,55]);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1],[3,1],[6,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,6],[-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 51: A_4 [1,2,3,4]
#
handle51char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[51];
    info:=infos[51];

    rep:=Representative(o);

    #pr[33]=[0,1,1,1,1,1,0,0]
    #pr[31]=[1,0,1,1,1,1,0,0]
    #pr[64]=[1,1,2,2,2,1,1,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1],[4,3],[2,2],[10,2],[11,-1],[17,2]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1],[4,3],[2,2],[10,2],[11,-1],[17,2]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[2]:=vals[1]+2*One(APR);
#vals[3]:=-(vals[1]-One(APR));
#vals[4]:=-(-vals[2]-One(APR));
#vals[10]:=vals[1]^2+2*vals[1]+vals[9]+3*One(APR);
#vals[11]:=-(-vals[1]-vals[9]+One(APR));
#vals[17]:=-(-vals[1]^2+3*vals[1]+vals[16]+3*One(APR));
# nu am terminat dar am gasit elementul

#
# cls 48: D_4(a_1)A_2
#
handle48char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[48];
    info:=infos[48];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]  asta merge si cu rep=[2,3,10,12,7,8] urmat de ConjNegUa(tmp1,4,1)
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    tmp1:=ConjNegUa(tmp1,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    tmp2:=ConjNegUa(tmp2,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 47: A_4A_1
#
handle47char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[47];
    info:=infos[47];

    rep:=Representative(o);

    #pr[41]=[0,1,1,1,1,1,1,0]
    #pr[39]=[1,0,1,1,1,1,1,0]
    #pr[57]=[1,1,2,2,2,1,0,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[41,39,57,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[4,2],[2,2],[10,3],[11,-1],[17,2]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[41,39,57,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[4,2],[2,2],[10,3],[11,-1],[17,2]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[2]:=vals[1]+2*One(APR);
#vals[3]:=-(-vals[1]+One(APR));
#vals[4]:=-(vals[2]+One(APR));
#vals[10]:=-(vals[1]^2+2*vals[1]-vals[9]+3*One(APR));
#vals[11]:=-(-vals[1]+vals[9]+One(APR));
#vals[17]:=-(-vals[1]^2+3*vals[1]+vals[16]+3*One(APR));
#
# nu e gata dar am gasit elementul

#
# cls 45: D_5(a_1)
#
handle45char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[45];
    info:=infos[45];

    rep:=Representative(o);

    #pr[82]=[1,1,2,3,3,2,1,0]
    #pr[80]=[1,2,2,3,2,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[82,80]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[82,80]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 44: A_4A_1^2
#
handle44char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[44];
    info:=infos[44];

    rep:=Representative(o);

    #pr[71]=[1,1,2,2,2,2,1,0]
    #pr[72]=[1,1,2,2,2,1,1,1]
    #pr[112]=[1,3,3,5,4,3,2,1]
    #pr[111]=[2,2,3,5,4,3,2,1]
    tmp1:=ApplyRootsReflections(rep,[71,72,112,111]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1],[4,3],[2,3],[10,3],[11,-1],[17,3]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,7],[-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[71,72,112,111]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1],[4,3],[2,3],[10,3],[11,-1],[17,3]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,7],[-1,-1]);

    return [tmp1,tmp2];
end;
#vals[2]:=-(-vals[1]+2*One(APR));
#vals[3]:=vals[1]+One(APR);
#vals[4]:=-vals[2]+One(APR);
#vals[10]:=-vals[1]^2+2*vals[1]+vals[9]+2*One(APR);
#vals[11]:=-vals[1]-vals[9]-One(APR);
#vals[17]:=-vals[1]^2+2*vals[1]-vals[16]+3*One(APR);
#
# nu e gata dar am gasit elementul

#
# cls 39: D_4A_2
#
handle39char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[39];
    info:=infos[39];

    rep:=Representative(o);

    #pr[34]=[0,1,0,1,1,1,1,0]
    #pr[35]=[0,0,1,1,1,1,1,0]
    #pr[68]=[0,1,1,2,2,2,1,1]
    tmp1:=ApplyRootsReflections(rep,[34,35,68]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,2],[4,-1],[5,-1],[8,-1],[11,-1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,6,7,8],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[34,35,68]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,2],[4,-1],[5,-1],[8,-1],[11,-1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,6,7,8],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[3]:=-(-vals[2]+3*One(APR));
#vals[4]:=-(vals[2]+One(APR));
#vals[5]:=vals[4];
#vals[8]:=-vals[7]-One(APR);
#vals[11]:=-(vals[2]*vals[3]+vals[10]+One(APR));
#vals[12]:=-(-vals[2]+vals[10]-One(APR));
#
# nu e gata dar am gasit elementul

#
# cls 38: E_6(a_3) [1,4,6,17,18,19] this doesn't work in char2
#
handle38char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[38];
    info:=infos[38];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 33: D_6(a_2)
#
handle33char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[33];
    info:=infos[33];

    rep:=Representative(o);

    #pr[42]=[0,1,0,1,1,1,1,0]
    #pr[43]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[42,43]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[6,1],[10,1],[13,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,5,8],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[42,43]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[6,1],[10,1],[13,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,5,8],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 32: E_6(a_3)A_1 [1,4,6,8,17,18,19] this doesn't work in char2
#
handle32char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[32];
    info:=infos[32];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 31: E_7(a_5)
#
handle31char5:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[31];
    info:=infos[31];

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[2,3,5]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3,4],[-1,-1]);

    tmp3:=ConjugateByTori(rep,[2,3,5],[bbb,bbb,bbb]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[2,3,5]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3,4],[-1,-1]);

    tmp4:=0;
    tmp4:=ConjugateByTori(cent,[2,3,5],[bbb,bbb,bbb]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 29: E_8(a_7)                           # NOT FINISHED IN CHARACTERISTIC 5
#
handle29char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[29];
    #info:=infos[29];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    #cent:=FromPositiveBorel(o,info[2]);
    #tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 27: D_6(a_1)
#
handle27char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[27];
    info:=infos[27];

    rep:=Representative(o);

    #pr[42]=[0,1,0,1,1,1,1,0]
    #pr[43]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[42,43]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[11,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[42,43]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[11,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 25: E_7(a_4) [1,4,7,14,17,18,19,26] this doesn't work in char2
#
handle25char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[25];
    info:=infos[25];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 24: E_6(a_1)
#
handle24char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[24];
    info:=infos[24];

    #pr[58]=[1,1,2,2,1,1,1,0]
    #pr[59]=[1,1,1,2,2,1,1,0]
    #pr[61]=[0,1,1,2,2,2,1,0]

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[58,59,61]);
    tmp1:=ConjNegUa(tmp1,4,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1],[11,-1],[12,3],[10,-1],[5,2],[6,3],[13,3],[18,-1],[19,-1],[20,2],[26,2],[27,2],[32,1],[40,3],[48,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2],[-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[58,59,61]);
    tmp2:=ConjNegUa(tmp2,4,-1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,1],[11,-1],[12,3],[10,-1],[5,2],[6,3],[13,3],[18,-1],[19,-1],[20,2],[26,2],[27,2],[32,1],[40,3],[48,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2],[-1,-1]);

    return [tmp1,tmp2,uu];
end;
#vals[2]:=vals[1]+One(APR);
#vals[4]:=0;
#vals[3]:=0;
#vals[5]:=-(-vals[1]+3*One(APR));
#vals[6]:=vals[5]+One(APR);
#vals[10]:=-(-vals[1]+vals[5]-One(APR));
#vals[11]:=-vals[1]-One(APR);
#vals[12]:=-vals[2]+vals[10];
#vals[13]:=-(2*vals[1]^2+2*vals[9]+2*One(APR));
#vals[16]:=-(2*One(APR))^-1*(vals[1]^2+vals[1]-vals[9]);
#vals[17]:=-vals[1]^2-vals[1]-vals[16];
#vals[18]:=-(3*vals[1]^2+3*vals[1]+2*vals[9]-One(APR));
#vals[19]:=vals[1]-vals[16]+One(APR);
#vals[20]:=vals[1]^2+3*vals[1]+vals[18]+2*One(APR);
#
#vals[24]:=-(3*One(APR))^-1*(vals[1]^3+3*vals[1]*vals[9]-vals[1]+vals[23]);
#vals[25]:=vals[1]^3-vals[1]*vals[9]-vals[1]+2*vals[9]+vals[23]-vals[24];
#vals[26]:=-(2*vals[1]^2-vals[1]-vals[9]+vals[23]-One(APR));
#vals[27]:=-vals[1]^3+vals[1]*vals[9]+2*vals[1]+2*vals[9]+vals[24]+One(APR);
#
#vals[30]:=-vals[1]^4+3*vals[1]^3+2*vals[1]^2*vals[9]-vals[1]^2+2*vals[1]*vals[9]-vals[9]^2-vals[23];
#vals[32]:=vals[1]^3+2*vals[1]^2+vals[9]+vals[23]-One(APR);
#vals[33]:=2*vals[1]^4+vals[1]^3-vals[1]^2*vals[9]+2*vals[1]*vals[9]+2*vals[1]-vals[23]+vals[24]+vals[25]-vals[27]+vals[30]-vals[31]+One(APR);
#vals[37]:=-(vals[1]^4+3*vals[1]^3+2*vals[1]^2*vals[9]+vals[1]^2-vals[1]*vals[9]+vals[9]^2-vals[1]-vals[9]+2*vals[23]+vals[31]);
#
#vals[40]:=2*vals[1]^4-vals[1]^3+3*vals[1]^2*vals[9]+3*vals[1]*vals[9]+2*vals[1]-vals[9]+vals[37]-One(APR);
#vals[44]:=-(vals[1]^4+3*vals[1]^3*vals[9]+2*vals[1]^3+2*vals[1]^2*vals[9]+2*vals[1]*vals[9]^2+vals[1]^2-vals[1]*vals[9]+vals[23]-vals[38]);
#vals[48]:=3*vals[1]^5+3*vals[1]^3*vals[9]+3*vals[1]^3+vals[1]^2*vals[9]+vals[1]*vals[9]+vals[9]^2+2*vals[1]+2*vals[9]+vals[23]+vals[37]-vals[38]+vals[45]+3*One(APR);
#
#vals[51]:=-(3*vals[1]^3*vals[9]+2*vals[1]^3*vals[23]-vals[1]^2*vals[9]^2+3*vals[1]^2*vals[9]-vals[1]*vals[23]-vals[9]^2+2*vals[9]*vals[23]-vals[23]^2+vals[38]);
#
# nu e gata dar am gasit elementul

#
# cls 23: D_5A_2
#
handle23char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[23];
    info:=infos[23];

    rep:=Representative(o);

    #pr[87]=[1,1,2,3,3,2,1,1]
    #pr[86]=[1,2,2,3,2,2,1,1]
    #pr[119]=[2,3,4,6,5,4,3,1]
    tmp1:=ApplyRootsReflections(rep,[87,86,119]);
    uu:=Unipotent(chevalleyAdj(rep),[[8,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,4,7],[-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[87,86,119]);
    uu:=Unipotent(chevalleyAdj(cent),[[8,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,4,7],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 20: D_7(a_2)
#
handle20char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[20];
    info:=infos[20];

    rep:=Representative(o);

    #pr[113]=[2,3,3,5,4,3,2,1]
    #pr[114]=[2,2,4,5,4,3,2,1]
    tmp1:=ApplyRootsReflections(rep,[113,114]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[6,1],[11,-1],[13,-1],[20,-1],[27,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[5,6],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[113,114]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[6,1],[11,-1],[13,-1],[20,-1],[27,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[5,6],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 18: E_6(a_1)A_1
#
handle18char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[18];
    info:=infos[18];

    #pr[106]=[1,2,2,4,4,3,2,1]
    #pr[105]=[1,2,3,4,3,3,2,1]
    #pr[104]=[2,2,3,4,3,2,2,1]

    # this is for E_6(a_1)A_1
    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[106,105,104]);
    tmp1:=ConjNegUa(tmp1,4,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1],[11,1],[12,2],[5,3],[10,-1],[6,2],[13,3],[18,-1],[19,-1],[20,2],[26,1],[27,3],[32,1],[40,2]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2,3,5,6],[-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[106,105,104]);
    tmp2:=ConjNegUa(tmp2,4,-1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,1],[11,1],[12,2],[5,3],[10,-1],[6,2],[13,3],[18,-1],[19,-1],[20,2],[26,1],[27,3],[32,1],[40,2]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2,3,5,6],[-1,-1,-1,-1,-1]);

    return [tmp1,tmp2,uu];
end;
#vals[2]:=-(vals[1]-One(APR));
#vals[4]:=0;
#vals[3]:=0;
#vals[5]:=vals[1]+3*One(APR);
#vals[6]:=-(-vals[5]+One(APR));
#vals[10]:=-(vals[1]-vals[5]-One(APR));
#vals[11]:=-(vals[1]-One(APR));
#vals[12]:=vals[2]-vals[10];
#vals[13]:=-(2*One(APR))^-1*(-vals[1]^2-vals[9]-One(APR));
#
#vals[16]:=3*vals[1]+vals[9]-vals[13]+3*One(APR);
#vals[17]:=-(-vals[1]^2+vals[1]-vals[16]);
#vals[18]:=-vals[16]-One(APR);
#vals[19]:=-(-vals[1]^2+2*vals[1]+vals[9]-vals[16]-One(APR));
#vals[20]:=vals[1]^2+2*vals[1]-vals[18]+2*One(APR);
#vals[23]:=-(3*One(APR))^-1*(vals[1]^3+2*vals[1]^2+3*vals[1]*vals[9]-vals[1]+2*vals[9]+vals[13]+2*One(APR));
#vals[24]:=-(3*One(APR))^-1*(3*vals[1]^3-vals[1]*vals[9]+2*vals[1]);
#vals[25]:=-(vals[1]^3+vals[1]^2-vals[1]*vals[9]-vals[1]+vals[9]-vals[16]+vals[17]+vals[19]-vals[23]-vals[24]-One(APR));
#vals[26]:=-vals[1]+3*vals[9]+vals[13]-vals[23]+3*One(APR);
#vals[27]:=-(vals[1]^3-vals[1]*vals[9]+3*vals[1]+2*vals[9]-vals[24]+One(APR));
#
#vals[30]:=-(2*vals[1]^3-vals[1]^2*vals[9]+vals[1]^2*vals[13]+vals[1]^2+3*vals[1]*vals[9]+vals[9]*vals[13]-vals[13]^2+2*vals[9]+vals[13]-vals[23]+One(APR));
#vals[32]:=-(vals[1]^3+3*vals[1]^2-vals[9]-vals[23]+One(APR));
#vals[33]:=-(-vals[1]^4+vals[1]^3+vals[1]^2*vals[9]+vals[1]^2*vals[13]+2*vals[1]^2+2*vals[1]*vals[9]-vals[1]*vals[13]+2*vals[1]+2*vals[9]+vals[27]-vals[30]-vals[31]+One(APR));
#vals[37]:=vals[1]^4+3*vals[1]^3+2*vals[1]^2*vals[9]+vals[1]^2-vals[1]*vals[9]+vals[9]^2-vals[9]-vals[23]+vals[31];
#
#vals[40]:=-(2*vals[1]^3+vals[1]^2*vals[9]-vals[1]^2*vals[13]-vals[1]^2+3*vals[1]*vals[9]+3*vals[1]*vals[13]-vals[1]+3*vals[13]-vals[37]);
#
#vals[44]:=-vals[1]^4+3*vals[1]^3*vals[9]-vals[1]^3+3*vals[1]^2*vals[9]+2*vals[1]*vals[9]^2-vals[1]^2+3*vals[1]+3*vals[23]+vals[38];
#
#vals[48]:=-(3*vals[1]^5+3*vals[1]^3*vals[9]-vals[1]^2*vals[9]+2*vals[1]*vals[9]-vals[9]^2+3*vals[9]+3*vals[23]+vals[37]+vals[38]-vals[45]+2*One(APR));
#
#vals[51]:=-vals[1]^6+2*vals[1]^4*vals[9]-vals[1]^4+3*vals[1]^3*vals[9]+2*vals[1]^3*vals[23]+3*vals[1]^3*vals[24]-vals[1]^2*vals[9]^2+2*vals[1]^2*vals[9]+3*vals[1]*vals[9]^2+3*vals[1]*vals[9]*vals[23]-vals[1]*vals[9]*vals[24]+2*vals[1]^2-vals[1]*vals[9]+vals[1]*vals[23]+2*vals[1]*vals[24]-vals[9]^2-vals[9]*vals[23]+3*vals[23]*vals[24]-vals[24]^2+vals[38];
#
# nu e gata dar am gasit elementul

#
# cls 17: E_7(a_3) ([1,4,6,7,15,16,17] in E_7) [1,4,6,7,17,18,19] in E_8 this doesn't work in char2
#
handle17char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[17];
    info:=infos[17];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 16: E_8(b_6)
#
handle16char5:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[16];
    info:=infos[16];

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[1,2,5]);
    uu:=Unipotent(chevalleyAdj(rep),[[23,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,3,4,8],[-1,-1,-1,-1]);

    tmp3:=ConjugateByTori(rep,[1,2,5],[bbb,bbb,bbb^2]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[1,2,5]);
    uu:=Unipotent(chevalleyAdj(cent),[[23,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,3,4,8],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ConjugateByTori(cent,[1,2,5],[bbb,bbb,bbb^2]);

    return [tmp1,tmp3,tmp2,tmp2];
end;

#
# cls 15: D_7(a_1)
#
handle15char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[15];
    info:=infos[15];

    rep:=Representative(o);

    #pr[113]=[2,3,3,5,4,3,2,1]
    #pr[114]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[113,114]);
    #uu:=Unipotent(chevalleyAdj(rep),[[4,1],[10,-1]],Ordering(rep)); si asta merge
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[11,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,3,4],[3*One(APR),3*One(APR),-1]);
    #tmp1:=ConjugateByTori(tmp1,[2,3,4],[ccc,ccc,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[113,114]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[11,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,3,4],[3*One(APR),3*One(APR),-1]);
    #tmp2:=ConjugateByTori(tmp2,[2,3,4],[ccc,ccc,-1]);

    return [tmp1,tmp2];
end;

#
# cls 12: E_8(a_6)
#
handle12char5:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu,vars;
    o:=Classes(orbs)[12];
    info:=infos[12];

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[2,3,8,13]);
    uu:=Unipotent(chevalleyAdj(rep),[[18,-1],[29,-1],[31,1],[33,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,3,4,5,7,8],[-1,-1,-1,-1,-1,-1]);

    #tmp3:=ConjugateByTori(rep,[2,3,5,6,8],[aaa,aaa,aaa,aaa,aaa^2]);
    tmp3:=ConjugateByTori(rep,[2,3,5,6,8],[bbb,bbb,bbb,bbb,bbb^2]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[2,3,8,13]);
    uu:=Unipotent(chevalleyAdj(cent),[[18,-1],[29,-1],[31,1],[33,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,3,4,5,7,8],[-1,-1,-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ConjugateByTori(cent,[2,3,5,6,8],[bbb,bbb,bbb,bbb,bbb^2]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 10: E_8(b_5)
#
handle10char5:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[10];
    info:=infos[10];

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[1,2,5]);
    uu:=Unipotent(chevalleyAdj(rep),[[19,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,3,4],[-1,-1,-1]);

    tmp3:=ConjugateByTori(rep,[1,2,5],[bbb,bbb,bbb^2]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[1,2,5]);
    uu:=Unipotent(chevalleyAdj(cent),[[19,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,3,4],[-1,-1,-1]);

    tmp4:=0;
    tmp4:=ConjugateByTori(cent,[1,2,5],[bbb,bbb,bbb^2]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

# For representative deduced from Seitz' E_8(a_6) used in proof
#
# cls 8: E_8(a_5)
#
handle8char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[8];
    info:=infos[8];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[4,6,7],[-1,-1,-1,-1]);# should be Z(D_8)

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[4,6,7],[-1,-1,-1,-1]);# should be Z(D_8)

    return [tmp1,tmp2];
end;

#
# cls 7: E_8(b_4) [1,4,7,8,14,17,19,26]  this doesn't work in char2
#
handle7char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[7];
    info:=infos[7];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 5: E_8(a_4) [1,4,6,8,17,18,19,21]  this doesn't work in char2
#
handle5char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[5];
    info:=infos[5];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[4,8],[-1,-1]);# h_4, h_8

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[4,8],[-1,-1]); # h_4, h_8

    return [tmp1,tmp2];
end;

#
# cls 4: E_8(a_3) [1,4,6,7,8,17,18,19]  this doesn't work in char2
#
handle4char5:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[4];
    info:=infos[4];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;


# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

FunctionEquality:=(a,b)-> (a=b) or (a.n=b.n and a.N=b.N and let(func1:=a.lambda(), func2:=b.lambda(),
	ForAll([1..a.N],e->func1.at(e).ev()=func2.at(e).ev())));

#######################################################
########  Redesigning the ruleset
#######################################################

Class(OLScatFuseRules, RuleSet);
RewriteRules(OLScatFuseRules, rec(
        Scat_ScatAcc := ARule(Compose,[@(1,[Scat, ScatAcc]),@(2,ScatAcc)],
            e->[ScatAcc(fCompose(@(1).val.func,@(2).val.func))]),

        ScatAcc_Scat := ARule(Compose,[@(1,ScatAcc),@(2,[Scat, ScatAcc])],
            e->[ScatAcc(fCompose(@(1).val.func,@(2).val.func))]),

        ICScatAcc_Scat := ARule(Compose,[@(1,ICScatAcc),@(2,[Scat, ICScatAcc])],
            e->[ICScatAcc(fCompose(@(1).val.func,@(2).val.func))]),

        Prm_ScatQuestionMark  := ARule(Compose, [ @(1, Prm), @(2, ScatQuestionMark) ],
            e -> [ ScatQuestionMark(fCompose(@(1).val.inverse, @(2).val.func)) ]),

        Prm_ICScatAcc := ARule(Compose, [ @(1, Prm), @(2, ICScatAcc) ],
            e -> [ ICScatAcc(fCompose(@(1).val.inverse, @(2).val.func)) ]),

        ScatQuestionMark_ScatQuestionMark :=
        ARule(Compose, [ @(1, ScatQuestionMark), @(2, ScatQuestionMark) ],
            e -> [ ScatQuestionMark(fCompose(@(1).val.func, @(2).val.func)) ]),

        Kill_NoPullId :=
        ARule(Compose,[[NoPull,[Prm,@,fId,fId]]],e->[]),

        Kill_ComposeIdL :=
        ARule(Compose,[@(1),[Prm,@,fId,fId]],e->[@(1).val]),

        Kill_ComposeIdR :=
        ARule(Compose,[[Prm,@,fId,fId],@(1).val],e->[@(1).val]),

#        Rule([@(1,Compose,e->Length(e.rChildren())>1),...,[Prm,@,fId,fId],...],e->Error("kill id")),

));

Class(OLVectorScatFuseRules, RuleSet);
RewriteRules(OLVectorScatFuseRules, rec(
        VScat_VConstruct :=
        ARule(Compose, [ @(1, VScat), @(2, [VScatAcc,VScatQuestionMark], e->@(1).val.v=e.v) ],
            e -> [ ObjId(@(2).val)(fCompose(@(1).val.func, @(2).val.func), @(1).val.v) ]),

        VScatQuestionMark_VConstruct :=
        ARule(Compose, [ @(1, VScatQuestionMark), @(2, [VScat,VScatAcc,VScatQuestionMark], e->@(1).val.v=e.v) ],
            e -> [ ObjId(@(1).val)(fCompose(@(1).val.func, @(2).val.func), @(1).val.v) ]),

        VScatAcc_VConstruct :=
        ARule(Compose, [ @(1, VScatAcc), @(2, [VScat,VScatAcc], e->@(1).val.v=e.v) ],
            e -> [ VScatAcc(fCompose(@(1).val.func, @(2).val.func), @(1).val.v) ]),

        ##The following rules are copies of the ones in the subvector system
        ScatQuestionMark_VConstruct := ARule(Compose, [ @(1, ScatQuestionMark), @(2, [VScat,VScatQuestionMark]) ],
            e -> [ VScat_svQuestionMark(@(1).val.func, getV(@(2).val), 1), @(2).val ]),

        ScatAcc_VConstruct := ARule(Compose, [ @(1, ScatAcc), @(2, [VScat,VScatAcc, VScatQuestionMark]) ],
            e -> [ VScat_svAcc(@(1).val.func, getV(@(2).val), 1), @(2).val ]),

    VScat_svQuestionMark__VScat := ARule(Compose, [@(1,[VScat_svQuestionMark,VScat_svAcc]), @(2,VScat)],
    e -> let(func := @(1).val.func,  vfunc := @(2).val.func,
             v    := getV(@(1).val), sv    := @(1).val.sv,
        [ ObjId(@(1).val)(fCompose(func, fTensor(vfunc, fId(v/sv))), v, sv) ])),

    GathScat_svQuestionMark_fTensor := Rule([@(1, [VGath_sv, VScat_svQuestionMark,VScat_svAcc]),
                            [@(2,fTensor), ..., [fId, @(3).cond(e -> Gcd(@(1).val.v/
@(1).val.sv, e) = @(1).val.v)]]],
     e -> let(v := @(1).val.v, sv := @(1).val.sv,
          n := @(3).val,   gcd := Gcd(v / sv, n),
          ObjId(@(1).val)(fTensor(DropLast(@(2).val.children(), 1), fId(n/gcd)), v, sv*gcd))),

    GathScat_sv_H := Rule([@(1, [VGath_sv, VScat_sv, VScat_svAcc]), [H, @(2),@(3).cond(e -> Gcd(@(1).val.v/
@(1).val.sv, e) = @(1).val.v),@(4),@(5)]],
            e->let(v := @(1).val.v, sv := @(1).val.sv,
          n := @(3).val,   gcd := Gcd(v / sv, n),
          mydiv:=When(IsSymbolic(@(4).val),idiv(@(4).val,gcd),@(4).val/gcd),
          ObjId(@(1).val)(H(@(2).val/gcd,n/gcd,mydiv,@(5).val), v, sv*gcd))),

        VScat_svQuestionMark__VScatQuestionMark := ARule(Compose, [@(1,[VScat_svQuestionMark,VScat_svAcc]), @(2,VScatQuestionMark)],
            e -> let(func := @(1).val.func,  vfunc := @(2).val.func,
                v    := getV(@(1).val), sv    := @(1).val.sv,
                [ ObjId(@(1).val)(fCompose(func, fTensor(vfunc, fId(v/sv))), v, sv) ])),

        VScat_svAcc__VScatAcc := ARule(Compose, [@(1,[VScat_svQuestionMark,VScat_svAcc]), @(2,VScatAcc)],
            e -> let(func := @(1).val.func,  vfunc := @(2).val.func,
                v    := getV(@(1).val), sv    := @(1).val.sv,
                [ VScat_svAcc(fCompose(func, fTensor(vfunc, fId(v/sv))), v, sv) ])),

        VScat_svQuestionMark_to_VScatQuestionMark :=
        Rule(@(1,VScat_svQuestionMark,e->getV(e)=e.sv), e->VScatQuestionMark(@(1).val.func, @(1).val.v)),

        VScat_svAcc_to_VScatAcc :=
        Rule(@(1,VScat_svAcc,e->getV(e)=e.sv), e->VScatAcc(@(1).val.func, @(1).val.v)),

));

Class(OLVectorPropagateRules, RuleSet);
RewriteRules(OLVectorPropagateRules, rec(
        VTensorOL_ScatAcc :=
        Rule([@(1,VTensor_OL),[@(2,Compose),@(3,ScatAcc),...]],
            e->VScatAcc(@(3).val.func,@(1).val.vlen)*
            VTensor_OL(Compose(Drop(@(2).val._children,1)),@(1).val.vlen)),

        VTensorOL_ScatQuestionMark :=
        Rule([@(1,VTensor_OL),[@(2,Compose),@(3,ScatQuestionMark),...]],
            e->VScatQuestionMark(@(3).val.func,@(1).val.vlen)*
            VTensor_OL(Compose(Drop(@(2).val._children,1)),@(1).val.vlen)),

        VTensorOL_Cross :=
        Rule([@(1,VTensor_OL),[@(2,Compose),...,@(3,Cross)]],
            e->VTensor_OL(Compose(DropLast(@2.val._children,1)),@(1).val.vlen)*
            Cross(List(@(3).val._children,t->VTensor(t,@(1).val.vlen)))),

        VTensorOL_ISum := Rule([@(1, VTensor_OL), @(2, [ISum])],
            e -> let(s := @(2).val, CopyFields(s,
                    rec(_children := List(s.children(), c->VTensor_OL(c, @(1).val.vlen)))))),

        VTensor_I :=
        Rule([@(1,VTensor),@(2,I)],
            e->VTensor(Prm(fId(@(2).val.dimensions[1])),@(1).val.vlen)),

));

OLVectorPropagateRuleset := MergedRuleSet(OLVectorPropagateRules, StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec, RulesPropagate);

Class(OLPushScatQuestionMarkInRules, RuleSet);
RewriteRules(OLPushScatQuestionMarkInRules, rec(
        ScatQuestionMark_NoPullRight := ARule(Compose, [@(1, [ScatQuestionMark,VScatQuestionMark]),@(2,NoPullRight)],
            e -> [ NoPullRight(@(1).val * @(2).val.rChildren()[1])]),

        ScatQuestionMark_Isum := ARule(Compose, [@(1, [ScatQuestionMark,VScatQuestionMark]), @(2,ISum)],
            e-> [ ISum(@(2).val.var,@(2).val.domain,Compose(@(1).val,@(2).val._children))]),
));

OLPushScatQuestionMarkInRuleset := MergedRuleSet(OLPushScatQuestionMarkInRules, StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec, RulesPropagate);

Class(OLAlreadyInitializedScatQuestionMarkRules, RuleSet);
RewriteRules(OLAlreadyInitializedScatQuestionMarkRules, rec(
        AlreadyInitializedScatQuestionMark := Rule(@(1, [ScatQuestionMark]),
            e-> ScatAcc(@(1).val.func)),

        AlreadyInitializedVScatQuestionMark := Rule(@(1, [VScatQuestionMark]),
            e-> VScatAcc(@(1).val.func,@(1).val.v)),
));

Class(OLScatQuestionMarkToScat, RuleSet);
RewriteRules(OLScatQuestionMarkToScat, rec(
        ScatQuestionMarkToScat := Rule(@(1, [ScatQuestionMark]),
            e-> Scat(@(1).val.func)),

        VScatQuestionMarkToScat := Rule(@(1, [VScatQuestionMark]),
            e-> VScat(@(1).val.func,@(1).val.v)),
));

Class(OLQuickAndDirtyHackForCodelet, RuleSet);
RewriteRules(OLQuickAndDirtyHackForCodelet, rec(
        ScatAcc_NoPullRight := ARule(Compose, [@(1, [ScatAcc,VScatAcc]),@(2,NoPullRight)],
            e -> [ NoPullRight(@(1).val * @(2).val.rChildren()[1])]),

        ScatAcc_Isum := ARule(Compose, [@(1, [ScatAcc, VScatAcc]), @(2,ISum)
],
            e-> [ ISum(@(2).val.var,@(2).val.domain,Compose(@(1).val,@(2).val._children))]),
));

OLAlreadyInitializedScatQuestionMarkRuleset := MergedRuleSet(OLAlreadyInitializedScatQuestionMarkRules,
    StandardSumsRules, OLScatFuseRules, OLVectorScatFuseRules, RulesVec, RulesPropagate);

Class(OLSplitScatQuestionMarkRules, RuleSet);
RewriteRules(OLSplitScatQuestionMarkRules, rec(

        SplitScatQuestionMark := Rule(@(1, [ScatQuestionMark]),
            e-> ScatInit(@(1).val.func , [],ScatAcc(@(1).val.func))),

        PullScatInitOutOfCompose := Rule([@(1,Compose),@(2,ScatInit),...],
            e-> ScatInit(@(2).val.func,@(2).val.cond,
                Compose(@(2).val._children,Drop(@(1).val._children,1)))),

        PullScatInitOutOfISum := Rule([@(1,ISum),@(2,ScatInit)],
            e->When(@(1).val.var in @(2).val.func.free(),
                ScatInitProbe(@(2).val.func,@(2).val.cond,
                    ISum(@(1).val.var,@(1).val.domain,
                        ScatInitFixed(@(2).val.func,@(2).val.cond,@(2).val._children))),
                ScatInit(@(2).val.func,@(2).val.cond,
                    ISum(@(1).val.var,@(1).val.domain,@(2).val._children)))),

        PullScatInitProbeOutOfCompose := Rule([@(1,Compose),@(2,ScatInitProbe),...],
            e-> ScatInitProbe(@(2).val.func,@(2).val.cond,
                Compose(@(2).val._children,Drop(@(1).val._children,1)))),

        PullScatInitProbeOutOfISum := Rule([@(1,ISum),@(2,ScatInitProbe)],
            e->When(@(1).val.var in @(2).val.func.free(),
                ScatInitProbe(@(2).val.func,@(2).val.cond,
                    ISum(@(1).val.var,@(1).val.domain,@(2).val._children)),
                ScatInitProbe(@(2).val.func,Concatenation([@(1).val.var],@(2).val.cond),
                    ISum(@(1).val.var,@(1).val.domain,@(2).val._children)))),

));
OLSplitScatQuestionMarkRuleset := MergedRuleSet(OLSplitScatQuestionMarkRules, StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec, RulesPropagate);

Class(OLScatProbeMergeRules, RuleSet);
RewriteRules(OLScatProbeMergeRules, rec(

        PushScatInitProbeInsideSum := Rule([@(1,ScatInitProbe),@(2,ISum),@],
            e->ISum(@(2).val.var,@(2).val.domain,
                ScatInitProbe(@(1).val.func,@(1).val.cond,Compose(@(2).val._children)))),

        PushScatInitProbeInsideCompose := Rule([@(1,ScatInitProbe),@(2,Compose),@],
            e-> Compose([ScatInitProbe(@(1).val.func,@(1).val.cond,@(2).val._children[1]),
                    Drop(@(2).val._children,1)])),

        ScatInit_Cross := ARule(Compose, [@(1,[ScatInit]), @(2, [Cross])],
            e-> [ ScatInit(@(1).val.func,@(1).val.cond,Compose(@(1).val._children,@(2).val))]),

        ScatInitProbe_ScatInitFixed := Rule([@(1,ScatInitProbe),@(2,ScatInitFixed),@],
            e->When(@(1).val.func=@(2).val.func,
                ScatInit(@(1).val.func,@(1).val.cond,@(2).val._children),
                Error("ScatInitProbe doesn t remerge with ScatInitFixed, how did that happen?"))),

        PushScatInitInsideCompose := Rule([@(1,ScatInit),@(2,Compose),@],
            e-> Compose([ScatInit(@(1).val.func,@(1).val.cond,@(2).val._children[1]),
                    Drop(@(2).val._children,1)])),

        ScatInit_ScatAcc :=
        Rule([@(1,ScatInit,e->ObjId(e._children)=ScatAcc and e.func=e._children.func and e.cond=[]),@(2,ScatAcc),@],
            e-> Scat(@(1).val.func)),
));

OLScatProbeMergeRuleset := MergedRuleSet(OLScatProbeMergeRules, StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec, RulesPropagate);

Class(OLScatAccPeelRules, RuleSet);
RewriteRules(OLScatAccPeelRules, rec(
    ScatInitPeel := Rule(
        [@(1,ScatInit, e->e.cond=[]),
            [@(2,ISum), [@(3,Compose),
                    @(4,ScatAcc,e->FunctionEquality(e.func,@(1).val.func)), ... ]],@],

	e-> let(v := @(2).val.var, newv := Ind(v.range-1),
#x            Buf(Scat(fId(@(1).val.dims()[1]))) *
            SUM(SubstVars(
                    Scat(@(4).val.func) * Compose(Drop(Copy(@(3).val.children()),1)),
                    rec((v.id) := V(0))),
                Cond(@(2).val.domain=2,
                    SubstVars(@(2).val.child(1),rec((v.id) := V(1))),
                    SubstVars(
                        ISum(newv, @(2).val.domain-1, @(2).val.child(1)),
                        rec((v.id) := newv+1)))
            )))
));

OLScatAccPeelRuleset := MergedRuleSet(OLScatAccPeelRules,StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec, RulesPropagate);

Class(OLCrossPullInRules, RuleSet);
RewriteRules(OLCrossPullInRules, rec(
        PullInSMPSumRight := ARule( Compose, [ @(1, [Prm, Scat]), @(2, [SMPSum]) ],
            e -> [ CopyFields(@(2).val, rec(
             _children :=  List(@(2).val._children, c -> @(1).val * c),
             dimensions := [Rows(@(1).val), Cols(@(2).val)] )) ]),

        SMPSum_Cross  := ARule(Compose, [ @(1, [SMPSum]), @(2, [Cross]) ],
            e -> [ ObjId(@(1).val)(@(1).val.p,@(1).val.var, @(1).val.domain, @(1).val.child(1) * @(2).val) ]),

        ISum_Cross  := ARule(Compose, [ @(1, [ISum, ISumAcc]), @(2, [Cross]) ],
            e -> [ ObjId(@(1).val)(@(1).val.var, @(1).val.domain, @(1).val.child(1) * @(2).val) ]),

        SUM_Cross  := ARule(Compose, [ @(1, [SUM]), @(2, [Cross]) ],
            e -> [ ObjId(@(1).val)(List(@(1).val._children,x->x*@(2).val)) ]),

        ScatAcc_RecursStep := ARule(Compose, [ @(1, [ScatAcc]), @(2, [RecursStep]) ],
            e -> [ RecursStep(@2.val.yofs, @2.val.xofs,
                     @(1).val* @2.val.child(1)).attrs(@(1).val) ]),

        RecursStep_Cross := ARule(Compose, [ @(1, [RecursStep]), @(2, [Cross]) ],
            e -> [ RecursStep(@1.val.yofs, @1.val.xofs,
                    @1.val.child(1) * @(2).val).attrs(@(1).val) ]),

        Cross_Cross := ARule(Compose, [ @(1, [Cross, CrossBlockTop]), @(2, [Cross]) ],
            e -> [ ObjId(@(1).val)(@(1).val.child(1) * @(2).val.child(1),
                    @(1).val.child(2) * @(2).val.child(2)).attrs(@(1).val) ]),

        CrossBlockTopPass := Rule(@(1,CrossBlockTop,e->not((ObjId(e.rChildren()[2])=Prm) and
                ObjId(e.rChildren()[2].rChildren()[2])=fId and
                ObjId(e.rChildren()[2].rChildren()[3])=fId)),
        e->Cross(Prm(fId(@(1).val.rChildren()[1].dims()[1])),@(1).val.rChildren()[2])*
            CrossBlockTop(@(1).val.rChildren()[1],
                Prm(fId(@(1).val.rChildren()[2].dims()[2])))
        )
));

OLCrossPullInRuleset := MergedRuleSet(OLCrossPullInRules, StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec, RulesPropagate);

Class(OLAfterCrossPullInRuleset, RuleSet);
RewriteRules(OLAfterCrossPullInRuleset, rec(
        Cross_CompatibleISum  := Rule([Cross, @(1, ISum), @(2, ISum,e->e.domain=@(1).val.domain) ],
            function(e)
              local varmap, var;
              varmap:=tab();
              var:=@(2).val.var;
              varmap.(var.id):=@(1).val.var;
              return ISum(@(1).val.var, @(1).val.domain,
                  Cross(@(1).val.rChildren()[1],SubstVars(@(2).val.rChildren()[1],varmap)));
            end)
));

Class(OLTearCrossRules, RuleSet);
RewriteRules(OLTearCrossRules, rec(
#        FullTearVGath_dup:=ARule(Cross,[@(1,VGath_dup)],e->[VGath(@(1).val.func,@(1).val.v)*VGath_dup(fId(@(1).val.func.range()),@(1).val.v)]),

#HACK, of course
        HalfTearVGath_dup:=Rule([@(1,VGath_dup),[@(2,fTensor),@(3,fBase),fBase,...]],e->
            let(func:=fTensor(Drop(Copy(@(2).val.rChildren()),1)),
            VGath(func,@(1).val.v)*
            VGath_dup(fTensor(@(3).val,fId(func.range())),@(1).val.v))),

        TearCross:=ARule(Compose,[@(1,Cross,e->e.hasRightScat() and e.hasLeftGath())],
            e->[Copy(@(1).val.splitCross()[1]),Copy(@(1).val.splitCross()[2])]),

        PushCrossOutOfIsum :=
        Rule([@(1,ISum), @(2,Compose,e->ObjId(Last(e.rChildren()))=Cross and
                    Last(e.rChildren()).hasRightScat() and not Last(e.rChildren()).hasLeftGath())],
            e->Compose(ISum(@(1).val.var, @(1).val.domain,
                    Compose(DropLast(@(2).val.rChildren(),1))),Last(@(2).val.rChildren()))),

#        PushCrossOutOfSMPSum :=
#        Rule([@(1,SMPSum), @(2), @(3,Compose,e->ObjId(Last(e.rChildren()))=Cross and
#                    Last(e.rChildren()).hasRightScat() and not Last(e.rChildren()).hasLeftGath())],
#
#            e->Compose(SMPSum(@(2).val,@(1).val.var, @(1).val.domain,
#                    Compose(DropLast(@(3).val.rChildren(),1))),Last(@(3).val.rChildren()))),

        CrossConditionalMerge :=
        ARule(Compose, [ @(1, Cross), @(2, Cross, e->e.hasRightScat() and
                    @(1).val.hasRightScat() and not(@(1).val.hasLeftGath()) and not(e.hasLeftGath())) ],
            e -> [ ObjId(@(1).val)(@(1).val.child(1) * @(2).val.child(1),@(1).val.child(2) *
                    @(2).val.child(2)).attrs(@(1).val) ]),
));

OLTearCrossRuleset := MergedRuleSet(OLTearCrossRules, StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec);

Class(OLSingleComposeRuleset, RuleSet);
RewriteRules(OLSingleComposeRuleset, rec(
        SingleCompose := Rule([@(1,Compose),@(2)],e->@(2).val),
));

Class(OLDropVGath_dupRuleset, RuleSet);
RewriteRules(OLDropVGath_dupRuleset, rec(
        DropVGath_dup := Rule(@(1,VGath_dup),e->VGath(@(1).val.func,@(1).val.v))
));

Class(OLDropSMPSumRuleset, RuleSet);
RewriteRules(OLDropSMPSumRuleset, rec(
        DropSMPSum := Rule(@(1,SMPSum),e->ISum(@(1).val.var,@(1).val.domain,@1.val.rChildren()[2]))
));

#########  HACCCK !!!
Class(OLMagicVUnrollDupRuleset, RuleSet);
RewriteRules(OLMagicVUnrollDupRuleset, rec(
#        MagicVGath_dup := Rule(@(1,VGath_dup,e->e.func.domain()>128 and e.func.domain() mod (32*4)=0),
#            e->let(itid:=Ind(4),idx:=Ind(@(1).val.func.domain()/(32*4)),
#                SMPSum(4,itid,4,
#                    ISum(idx,@(1).val.func.domain()/(32*4),
#                        VScat(fTensor(fBase(itid),fBase(idx),fId(32)), 2)*
#                        VGath_dup(fTensor(fBase(itid),fBase(idx),fId(32)), 2))),

        MagicVGath_dup := Rule(@(1,VGath_dup,e->e.func.domain()>32),
            e->@(1).val.toloop(32))
));

#Class(OLLiftBarrierRuleset, RuleSet);
#RewriteRules(OLLiftBarrierRuleset, rec(
#        EliminateBarrier := ARule(Compose, [@(1,RewriteBarrier),@(2)],
#            e->[@(2).val]),
#));

OLDefaultStrategy := [TerminateSymSPL,RulesTerm];

#################################################################
Class(OLRulesCode, RuleSet);
RewriteRules(OLRulesCode, rec(

        #Cross must not be BBized without neighbours if it has some identities
        CrossBB_in := Rule([BB,[@(1,Cross),...,[Prm,@,fId,fId],...]],
            e->Cross(List(@(1).val.rChildren(),x->BB(x)))
        ),

        DoubleBB := Rule([BB,@(1,BB)],e->@(1).val),

        #BB should go out if the inner are not Ids (simplified to perms in this case)
        Cross_BB_out := Rule([Cross, @(1, BB,e->not(ObjId(e.rChildren()[1])=Prm)), @(2, BB,e->not(ObjId(e.rChildren()[1])=Prm)) ],
            e -> BB(Cross(@(1).val.child(1),@(2).val.child(1)))),

        Drop_NoPull := Rule(@(1,NoPull),e->@(1).val.rChildren()[1]),

));

Class(OLRulesBufferFinalize, RuleSet);
RewriteRules(OLRulesBufferFinalize, rec(
    FinalizeNoPull := Rule(@(1, [NoPull, NoPullLeft, NoPullRight]), i->@1.val.child(1)),
    DropCrossBlockTop := Rule(@(1,CrossBlockTop), e->Cross(@1.val.rChildren()))
));

#RewriteRules(RulesStrengthReduce, rec(
# vdupmultsR:= Rule([mul, @(1), @(2).cond(e->ObjId(e.t)=TVect and ObjId(@(1).val.t)<>TVect)], e->mul(vdup(@(1).val, @(2).val.t.size), @(2).val)),
#
#vdupmultsL:= Rule([mul, @(1), @(2).cond(e->ObjId(@(1).val.t)=TVect and ObjId(e.t)<>TVect)], e->mul(@(1).val,vdup(@(2).val, @(1).val.t.size))),
#
#));

Class(OLPushScatAccRules,RuleSet);

#ScatAcc that are pushed inside sums MUST merge or else things get added twice or more...
RewriteRules(OLPushScatAccRules, rec(
        PushScatAccInsideISum := ARule(Compose, [@(1, ScatAcc), @(2,ISum)],
            e-> [ ISum(@(2).val.var,@(2).val.domain,Compose(@(1).val,@(2).val._children))]),

        PushScatAccInsideSUM := ARule(Compose, [@(1, ScatAcc), @(2,SUM)],
            e-> let(childs:=List(@(2).val._children,e->@(1).val*e), [ SUM(childs)])),

        PushICScatAccInsideISum := ARule(Compose, [@(1, ICScatAcc), @(2,ISum)],
            e-> [ ISum(@(2).val.var,@(2).val.domain,Compose(@(1).val,@(2).val._children))]),

        PushICScatAccInsideSUM := ARule(Compose, [@(1, ICScatAcc), @(2,SUM)],
            e-> let(childs:=List(@(2).val._children,e->@(1).val*e), [ SUM(childs)])),

));
OLPushScatAccRuleset := MergedRuleSet(OLPushScatAccRules, StandardSumsRules, OLScatFuseRules,
    OLVectorScatFuseRules, RulesVec, RulesPropagate);


InstallGlobalFunction(MitM_ATPToRec,
function(atp)
    local i, res;

    res := rec();

    for i in [1,3..Length(MitM_Content(atp))-1] do
        res.( MitM_Name(MitM_Content(atp)[i]) ) :=
            EvalString(MitM_OMRecToGAPNC(MitM_Content(atp)[i+1]).result);
    od;
    return res;
end);

InstallGlobalFunction(MitM_RecToATP,
function(r)
    return Objectify(MitM_OMRecType,
                     rec( name := "OMATP"
                        , content := Concatenation(
                                List( NamesOfComponents(r)
                                    , n -> [ OMS("scscp1", n)
                                           , MitM_GAPToOMRec(r.(n)) ] ) ) ));
end);

InstallGlobalFunction(OMATP,
function(r)
    return Objectify(MitM_OMRecType,
                     rec( name := "OMATP"
                        , content := Concatenation(
                                List( NamesOfComponents(r)
                                    , n -> [ OMS("scscp1", n)
                                           , r.(n) ] ) ) ));
end);

InstallGlobalFunction(OMOBJ,
function(obj)
    return Objectify( MitM_OMRecType
                    , rec( name := "OMOBJ"
                         , attributes := rec( version := "2.0" )
                         , content := [obj] ) );
end);

InstallGlobalFunction(OMA,
function(oms, args...)
    return Objectify( MitM_OMRecType
                    , rec( name := "OMA"
                         , content := Concatenation( [ oms ], args ) ) );
end);

InstallGlobalFunction(OMS,
function(args...)
    local res;

    res := rec( name := "OMS"
              , attributes := rec( ) );

    if Length(args) = 2 then
        res.attributes.cd := args[1];
        res.attributes.name := args[2];
    elif Length(args) = 3 then
        res.attributes.cdbase := args[1];
        res.attributes.cd := args[2];
        res.attributes.name := args[3];
    else
        return fail;
    fi;
    return Objectify(MitM_OMRecType, res);
end);

InstallGlobalFunction(MitM_SimpleOMS,
obj_name -> OMS(MitM_cdbase, "lib", obj_name));

InstallGlobalFunction(OMATTR,
function(attr, content)
    return Objectify( MitM_OMRecType
                    , rec( name := "OMATTR"
                         , content := [ MitM_RecToATP(attr)
                                      , content ] ) );
end);

InstallGlobalFunction(OMSTR,
function(string)
    if IsEmptyString(string) then
        return Objectify( MitM_OMRecType
                        , rec( name := "OMSTR"
                             , content := [ ] ) );
    else
        return Objectify( MitM_OMRecType
                        , rec( name := "OMSTR"
                             , content := [ string ] ) );
    fi;
end);

InstallGlobalFunction(OMI,
function(int)
    return Objectify( MitM_OMRecType
                    , rec( name := "OMI"
                         , content := [ String(int) ] ) );
end);

InstallGlobalFunction(OMF,
function(float)
    return Objectify( MitM_OMRecType
                    , rec( name := "OMF"
                         , attributes := rec( dec := String(float) ) ) );
end);

InstallGlobalFunction(OME,
function(oms, content)
    return Objectify( MitM_OMRecType
                    , rec( name := "OME"
                         , content := Concatenation( [oms], content ) ) );
end);

InstallGlobalFunction(OMV,
function(name)
    return Objectify( MitM_OMRecType
                    , rec( name := "OMV"
                         , attributes := rec( name := name )
                         , content := []  ) );
end);

InstallMethod(ViewString, "for an omrec",
              [MitM_OMRecRep],
function(r)
    local attr, i, content;
    if r!.name = "OMS" then
        if IsBound(r!.attributes.cdbase) then
            return StringFormatted( "OMS(cd=\"{}\", cdbase=\"{}\", name=\"{}\")"
                                  , r!.attributes.cd, r!.attributes.cdbase, r!.attributes.name );
        else
            return StringFormatted( "OMS(cd=\"{}\", name=\"{}\")"
                                  , r!.attributes.cd, r!.attributes.name );
        fi;
    elif r!.name = "OMA" then
        return StringFormatted( "OMA({})"
                              , JoinStringsWithSeparator(List(r!.content, ViewString), ", ") );
    elif r!.name = "OMSTR" then
        if IsEmpty(MitM_Content(r)) then
            return "OMSTR(\"\")";
        else
            return StringFormatted( "OMSTR(\"{}\")", MitM_Content(r)[1] );
        fi;
    elif r!.name = "OMI" then
        return StringFormatted( "OMI({})", r!.content[1] );
    elif r!.name = "OMF" then
        # TODO: this is not really right yet
        return StringFormatted( "OMF({})", r!.attributes.dec );
    elif r!.name = "OMATP" then
        attr := [];
        for i in [1, 3 .. Length(r!.content) - 1] do
            Add(attr, Concatenation(r!.content[i]!.attributes.name,
                                    " := ", ViewString(r!.content[i+1])));
        od;
        return StringFormatted( "OMATP( rec( {} ) )",
                                JoinStringsWithSeparator(attr, ", ") );
    elif r!.name = "OMATTR" then
        content := MitM_Content(r);
        return StringFormatted( "OMATTR( {}, {} )",
                                MitM_ATPToRec(content[1]),
                                ViewString(content[2]) );
    elif r!.name = "OMOBJ" then
        return StringFormatted( "OMOBJ({})", ViewString(MitM_Content(r)[1]) );
    elif r!.name = "OME" then
        return StringFormatted( "OME({}, {})",
                                ViewString(MitM_Content(r)[1]),
                                ViewString(MitM_Content(r)[2]) );
    else
        return StringFormatted( "ViewString for {} not implemented", r!.name );
    fi;
end);

InstallMethod(ViewObj, "for an omrec",
              [MitM_OMRecRep],
function(r)
    Print(ViewString(r));
end);

InstallMethod( MitM_Tag, "for an omrec",
               [MitM_OMRecRep],
r -> r!.name);

InstallMethod(MitM_Attributes, "for an omrec",
              [MitM_OMRecRep],
function(r)
    if IsBound(r!.attributes) then
        return r!.attributes;
    else
        return rec();
    fi;
end);

InstallMethod(MitM_Name, "for an omrec",
              [MitM_OMRecRep],
function(r)
    if IsBound(r!.attributes) and IsBound(r!.attributes.name) then
        return r!.attributes.name;
    else
        return fail;
    fi;
end);

InstallMethod(MitM_CD, "for an omrec",
              [MitM_OMRecRep],
function(r)
    if r!.name = "OMS" then
        return r!.attributes.cd;
    else
        return fail;
    fi;
end);

InstallMethod(MitM_CDBase, "for an omrec",
              [MitM_OMRecRep],
function(r)
    if r!.name = "OMS" and IsBound(r!.attributes.cdbase) then
        return r!.attributes.cdbase;
    else
        return fail;
    fi;
end);

InstallMethod(MitM_Content, "for an omrec",
              [MitM_OMRecRep],
function(r)
    if IsBound(r!.content) then
        return r!.content;
    else
        return fail;
    fi;
end);

InstallMethod(\=, "for omrec and omrec",
              [MitM_OMRecRep, MitM_OMRecRep],
{x, y} -> (x!.name = y!.name and
           IsBound(x!.content) = IsBound(y!.content) and
           ((not IsBound(x!.content)) or x!.content = y!.content)));

InstallMethod(\<, "for omrec and omrec",
              [MitM_OMRecRep, MitM_OMRecRep],
function(x, y)
    if x!.name < y!.name then
        return true;
    elif x!.name = y!.name then
        if (not IsBound(x!.content)) and IsBound(y!.content) then
            return true;
        elif IsBound(x!.content) and IsBound(y!.content) then
            if x!.content < y!.content then
                return true;
            fi;
        fi;
    fi;
    return false;
end);


#
# cls 14: \tilde A_1
#
handle14char3:=function()
    local tmp1,tmp2,o,info,rep,cent;
    o:=AllClasses(orbs)[14];
    info:=infos[14];

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[12]);#pr[12]=[1,0,2,1]-->[0,1,2,1]
    tmp1:=ConjugateByTorus(tmp1,3,-1);

    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[12]);#pr[12]=[1,0,2,1]-->[0,1,2,1]
    tmp2:=ConjugateByTorus(tmp2,3,-1);

    return [tmp1,tmp2];
end;

#
# cls 12: A_2
#
handle12char3:=function()
    local tmp1,tmp2,o,info,rep,cent,u;
    o:=AllClasses(orbs)[12];
    info:=infos[12];

    rep:=Representative(o);
    #pr[7]=[0,0,1,1]-->[0,1,1,0]
    #pr[13]=[0,1,2,1]-->[1,1,2,0]
    tmp1:=ApplyRootsReflections(rep,[7,13]);
    u:=Unipotent(algebraicU(orbs),[[4,-1]]);
    tmp1:=Conj(tmp1,u);
    tmp1:=ConjugateByTorus(tmp1,2,-1);

    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[7,13]);
    tmp2:=Conj(tmp2,u);
    tmp2:=ConjugateByTorus(tmp2,2,-1);

    return [tmp1,tmp2];
end;

#
# cls 9: B_2
#
handle9char3:=function()
    local tmp1,tmp2,o,info,rep,cent;
    o:=AllClasses(orbs)[9];
    info:=infos[9];

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[9]);#pr[9]=[0,1,1,1]-->[1,1,1,0]
    tmp1:=ConjugateByTorus(tmp1,4,-1);# merge si cu 1

    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[9]);#pr[9]=[0,1,1,1]-->[1,1,1,0]
    tmp2:=ConjugateByTorus(tmp2,4,-1);# merge si cu 1

    return [tmp1,tmp2];
end;

#
# cls 7: C_3(a_1)
#
handle7char3:=function()
    local tmp1,tmp2,o,info,rep,cent;
    o:=AllClasses(orbs)[7];
    info:=infos[7];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,1,-1);# h_1 --> h_4
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,1,-1);# h_1 --> h_4
    return [tmp1,tmp2];
end;

#
# cls 6: F_4(a_3) [4,6,10,18] (finished?)
#
handle6char3:=function()
    local tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,o,info,rep,cent,uu;
    o:=AllClasses(orbs)[6];
    info:=infos[6];

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[3]);#pr[3]=[0,0,1,0]-->[0,0,1,0]
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1],[6,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2,3,4],[1,-1,aaa,aaa^2]);

    tmp3:=ApplyRootsReflections(rep,[5,1]);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1]],Ordering(rep));#[1..24]);
    tmp3:=Conj(tmp3,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[16,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjNegUa(tmp3,2,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[13,1],[2,-1],[4,1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[3],[aaa]);

    tmp5:=ConjugateByTori(rep,[3],[-1]);

    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[3]);#pr[3]=[0,0,1,0]-->[0,0,1,0]
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1],[6,1]]);
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2,3,4],[1,-1,aaa,aaa^2]);

    tmp4:=ApplyRootsReflections(cent,[5,1]);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1]],Ordering(cent));#[1..24]);
    tmp4:=Conj(tmp4,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[16,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjNegUa(tmp4,2,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[13,1],[2,-1],[4,1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[3],[aaa]);

    tmp6:=ConjugateByTori(cent,[3],[-1]);

    return [tmp1,tmp3,tmp5,tmp2,tmp4,tmp6];
end;

#
# cls 3: F_4(a_2) (not finished)
#
handle3char3:=function()
    local tmp1,tmp2,o,info,rep,cent;
    o:=AllClasses(orbs)[3];
    info:=infos[3];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[4],[-1]);# h_1 --> h_4

    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[4],[-1]);# h_1 --> h_4
    return [tmp1,tmp2];
end;

#
# cls 2: F_4(a_1)
#
handle2char3:=function()
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=AllClasses(orbs)[2];
    info:=infos[2];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[3,1],[-1,-1]);# h_1 --> h_4, h_3 --> h_3
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1]],Ordering(rep));#pr[3]=[0,0,1,0]-->[0,0,1,0]
    tmp1:=Conj(tmp1,uu);

    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[3,1],[-1,-1]);# h_1 --> h_4, h_3 --> h_3
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1]],Ordering(cent));#pr[3]=[0,0,1,0]-->[0,0,1,0]
    tmp2:=Conj(tmp2,uu);

    return [tmp1,tmp2];
end;


#
# cls 67: A_2
#
handle67char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[67];
    info:=infos[67];

    rep:=Representative(o);
    #pr[19]=[0,0,1,1,1,0,0,0]
    #pr[17]=[0,1,1,1,0,0,0,0]
    #pr[37]=[1,1,1,2,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[19,17,37]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1]]);
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[19,17,37]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1]]);
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 65: A_2A_1
#
handle65char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[65];
    info:=infos[65];

    rep:=Representative(o);
    #pr[53]=[1,1,1,2,1,1,1,0]
    #pr[52]=[1,1,1,2,2,1,0,0]
    #pr[93]=[1,2,3,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[53,52,93]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[53,52,93]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 61: A_2^2
#
handle61char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[61];
    info:=infos[61];

    rep:=Representative(o);
    #pr[43]=[0,0,1,1,1,1,1,1]
    #pr[41]=[0,1,1,1,1,1,1,0]
    #pr[79]=[1,1,1,2,2,2,2,1]
    tmp1:=ApplyRootsReflections(rep,[43,41,79]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3],[-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[43,41,79]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3],[-1]);

    return [tmp1,tmp2];
end;

#
# cls 58: D_4(a_1)
#
handle58char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[58];
    info:=infos[58];

    rep:=Representative(o);
    #pr[4] =[0,0,0,1,0,0,0,0]
    #pr[51]=[1,1,2,2,1,1,0,0]
    #pr[52]=[1,1,1,2,2,1,0,0]
    tmp1:=ApplyRootsReflections(rep,[4,51,52]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[5,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,1,2,6],[-1,-1,-1,-1]);

    #pr[26]=[0,1,0,1,1,1,0,0]
    #pr[27]=[0,0,1,1,1,1,0,0]
    tmp3:=ApplyRootsReflections(rep,[26,27]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1],[4,1],[5,-1],[11,1],[12,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[4,51,52]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[5,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,1,2,6],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[26,27]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1],[4,1],[5,-1],[11,1],[12,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 54: D_4(a_1)A_1 Ross' rep
#
handle54char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[54];
    info:=infos[54];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    tmp1:=ConjNegUa(tmp1,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2],[-1,-1,-1,-1]);

    #pr[65]=[1,1,2,2,1,1,1,1]
    #pr[67]=[1,1,1,2,2,1,1,1]
    tmp3:=ApplyRootsReflections(rep,[65,67,4]);
    uu:=Unipotent(chevalleyAdj(rep),[[12,-1],[11,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[1,2,4,6,8],[-1,-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    tmp2:=ConjNegUa(tmp2,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[65,67,4]);
    uu:=Unipotent(chevalleyAdj(cent),[[12,-1],[11,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[1,2,4,6,8],[-1,-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;
#
# cls 54: D_4(a_1)A_1 ([2,5,9,10,7] in E_7) [2,5,10,11,7] in E_8
#
handle54char3old:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[54];
    info:=infos[54];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2],[-1,-1,-1,-1]);

    #pr[65]=[1,1,2,2,1,1,1,1]
    #pr[67]=[1,1,1,2,2,1,1,1]
    tmp3:=ApplyRootsReflections(rep,[65,67]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,-1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjNegUa(tmp3,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[4,-1],[5,-1],[12,1]],Ordering(rep));
    tmp3:=Conj(tmp3,uu);
    tmp3:=ConjugateByTori(tmp3,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2],[-1,-1,-1,-1]);

    tmp4:=0;
    tmp4:=ApplyRootsReflections(cent,[65,67]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,-1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjNegUa(tmp4,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[4,-1],[5,-1],[12,1]],Ordering(cent));
    tmp4:=Conj(tmp4,uu);
    tmp4:=ConjugateByTori(tmp4,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4];
end;

#
# cls 53: A_3A_2 [3,4,2,6,7]
#
handle53char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[53];
    info:=infos[53];

    rep:=Representative(o);

    #pr[26]=[0,1,0,1,1,1,0,0]
    #pr[27]=[0,0,1,1,1,1,0,0]
    #pr[55]=[0,1,1,2,2,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[26,27,55]);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1],[3,1],[6,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,6],[-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[26,27,55]);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1],[3,1],[6,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,6],[-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 52: A_4
#
handle52char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[52];
    info:=infos[52];

    rep:=Representative(o);

    #pr[33]=[0,1,1,1,1,1,0,0]
    #pr[31]=[1,0,1,1,1,1,0,0]
    #pr[64]=[1,1,2,2,2,1,1,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,1],[4,1],[11,-1],[17,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,1],[4,1],[11,-1],[17,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[1]:=vals[2];
#vals[3]:=-vals[1]+One(APR);
#vals[4]:=vals[2]+One(APR);
#vals[11]:=-(vals[2]^2-vals[2]-vals[10]+One(APR));
#vals[17]:=-(vals[9]-vals[10]+vals[16]+One(APR));
#
# cls 52: A_4 [1,2,3,4]
#
handle52char3old:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[52];
    info:=infos[52];

    rep:=Representative(o);

    #pr[33]=[0,1,1,1,1,1,0,0]
    #pr[31]=[1,0,1,1,1,1,0,0]
    #pr[64]=[1,1,2,2,2,1,1,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1],[4,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[33,31,64,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1],[4,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 49: D_4(a_1)A_2
#
handle49char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[49];
    info:=infos[49];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]  asta merge si cu rep=[2,3,10,12,7,8] urmat de ConjNegUa(tmp1,4,1)
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    tmp1:=ConjNegUa(tmp1,4,1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    tmp2:=ConjNegUa(tmp2,4,1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#
# cls 49: D_4(a_1)A_2 [2,5,10,11,7,8] in E_8
#
handle49char3old:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[49];
    info:=infos[49];

    rep:=Representative(o);

    #pr[23]=[1,1,1,1,0,0,0,0]  asta merge si cu rep=[2,3,10,12,7,8] urmat de ConjNegUa(tmp1,4,1)
    #pr[24]=[1,0,1,1,1,0,0,0]
    tmp1:=ApplyRootsReflections(rep,[23,24]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[23,24]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 48: A_4A_1
#
handle48char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[48];
    info:=infos[48];

    rep:=Representative(o);

    #pr[41]=[0,1,1,1,1,1,1,0]
    #pr[39]=[1,0,1,1,1,1,1,0]
    #pr[57]=[1,1,2,2,2,1,0,0]
    #pr[89]=[1,2,2,4,3,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[41,39,57,89]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[4,-1],[11,-1],[17,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[41,39,57,89]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[4,-1],[11,-1],[17,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[2]:=vals[1];
#vals[3]:=vals[1]-One(APR);
#vals[4]:=-vals[2]-One(APR);
#vals[11]:=vals[1]-vals[9]-One(APR);
#vals[10]:=-vals[1]^2+vals[9];
#vals[17]:=vals[1]^2-vals[16]-One(APR);

#
# cls 46: D_5(a_1)
#
handle46char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[46];
    info:=infos[46];

    rep:=Representative(o);

    #pr[82]=[1,1,2,3,3,2,1,0]
    #pr[80]=[1,2,2,3,2,2,1,0]
    tmp1:=ApplyRootsReflections(rep,[82,80]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[82,80]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 45: A_4A_1^2
#
handle45char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[45];
    info:=infos[45];

    rep:=Representative(o);

    #pr[71]=[1,1,2,2,2,2,1,0]
    #pr[72]=[1,1,2,2,2,1,1,1]
    #pr[112]=[1,3,3,5,4,3,2,1]
    #pr[111]=[2,2,3,5,4,3,2,1]
    tmp1:=ApplyRootsReflections(rep,[71,72,112,111]);
    uu:=Unipotent(chevalleyAdj(rep),[[1,1],[2,1],[3,-1],[9,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[5,8],[-1,aaa]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[71,72,112,111]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,1],[2,1],[3,-1],[9,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[5,8],[-1,aaa]);

    return [tmp1,tmp2];
end;

#
# cls 40: D_4A_2
#
handle40char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[40];
    info:=infos[40];

    rep:=Representative(o);

    #pr[34]=[0,1,0,1,1,1,1,0]
    #pr[35]=[0,0,1,1,1,1,1,0]
    #pr[68]=[0,1,1,2,2,2,1,1]
    tmp1:=ApplyRootsReflections(rep,[34,35,68]);
    uu:=Unipotent(chevalleyAdj(rep),[[3,-1],[4,-1],[5,-1],[8,-1],[11,-1],[12,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,6,7,8],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[34,35,68]);
    uu:=Unipotent(chevalleyAdj(cent),[[3,-1],[4,-1],[5,-1],[8,-1],[11,-1],[12,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,6,7,8],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#vals[3]:=vals[2]-One(APR);
#vals[4]:=-vals[2]-One(APR);
#vals[5]:=vals[4];
#vals[8]:=-vals[7]-One(APR);
#vals[11]:=-vals[2]^2+vals[2]-vals[10]-One(APR);
#vals[12]:=vals[2]-vals[10]+One(APR);

#
# cls 39: E_6(a_3) [1,4,6,17,18,19] this doesn't work in char2
#
handle39char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[39];
    info:=infos[39];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 34: D_6(a_2)
#
handle34char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[34];
    info:=infos[34];

    rep:=Representative(o);

    #pr[42]=[0,1,0,1,1,1,1,0]
    #pr[43]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[42,43]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[6,1],[10,1],[13,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[4,5,8],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[42,43]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[6,1],[10,1],[13,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[4,5,8],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 33: E_6(a_3)A_1 [1,4,6,8,17,18,19] this doesn't work in char2
#
handle33char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[33];
    info:=infos[33];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 32: E_7(a_5)
#
handle32char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[32];
    info:=infos[32];

    rep:=Representative(o);
    tmp1:=ConjNegUa(rep,1,1);
    tmp1:=ConjNegUa(tmp1,3,-1);
    tmp1:=ConjNegUa(tmp1,9,-1);
    tmp1:=ConjNegUa(tmp1,2,1);
    uu:=Unipotent(chevalleyAdj(rep),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[11,1],[14,1],[16,1],[20,1],[21,1],[25,1],[26,-1],[27,-1],[30,1],[33,-1],[35,-1],[37,-1],[38,-1],[39,1],[41,-1],[44,1],[45,1],[46,-1],[51,-1],[52,-1],[59,1],[64,-1],[66,1],[69,-1],[71,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTorus(tmp1,1,-1);

    tmp3:=ConjugateByTorus(rep,18,-1);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjNegUa(cent,1,1);
    tmp2:=ConjNegUa(tmp2,3,-1);
    tmp2:=ConjNegUa(tmp2,9,-1);
    tmp2:=ConjNegUa(tmp2,2,1);
    uu:=Unipotent(chevalleyAdj(cent),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    uu:=Unipotent(chevalleyAdj(cent),[[11,1],[14,1],[16,1],[20,1],[21,1],[25,1],[26,-1],[27,-1],[30,1],[33,-1],[35,-1],[37,-1],[38,-1],[39,1],[41,-1],[44,1],[45,1],[46,-1],[51,-1],[52,-1],[59,1],[64,-1],[66,1],[69,-1],[71,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTorus(tmp2,1,-1);

    tmp4:=0;
    tmp4:=ConjugateByTorus(cent,18,-1);

    return [tmp1,tmp3,tmp2,tmp4,uu];
end;

#
# cls 30: E_8(a_7) (NOT FINISHED)
#
handle30char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[30];
    info:=infos[30];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    #cent:=FromPositiveBorel(o,info[2]);
    #tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 28: D_6(a_1)
#
handle28char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[28];
    info:=infos[28];

    rep:=Representative(o);

    #pr[42]=[0,1,0,1,1,1,1,0]
    #pr[43]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[42,43]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[11,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[3,4],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[42,43]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[11,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[3,4],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 26: E_7(a_4) [1,4,7,14,17,18,19,26] this doesn't work in char2
#
handle26char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[26];
    info:=infos[26];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 25: E_6(a_1)
#
handle25char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[25];
    info:=infos[25];

    #pr[58]=[1,1,2,2,1,1,1,0]
    #pr[59]=[1,1,1,2,2,1,1,0]
    #pr[61]=[0,1,1,2,2,2,1,0]

    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[58,59,61]);
    tmp1:=ConjNegUa(tmp1,4,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1],[5,-1],[10,-1],[11,-1],[12,1],[18,1],[19,1],[26,-1],[27,-1],[32,-1],[40,1],[48,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[5,7],[-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[58,59,61]);
    tmp2:=ConjNegUa(tmp2,4,-1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,1],[5,-1],[10,-1],[11,-1],[12,1],[18,1],[19,1],[26,-1],[27,-1],[32,-1],[40,1],[48,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[5,7],[-1,-1]);

    return [tmp1,tmp2,uu];
end;

#
# cls 24: D_5A_2
#
handle24char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[24];
    info:=infos[24];

    rep:=Representative(o);

    #pr[87]=[1,1,2,3,3,2,1,1]
    #pr[86]=[1,2,2,3,2,2,1,1]
    #pr[119]=[2,3,4,6,5,4,3,1]
    tmp1:=ApplyRootsReflections(rep,[87,86,119]);
    uu:=Unipotent(chevalleyAdj(rep),[[8,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,4,7],[-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[87,86,119]);
    uu:=Unipotent(chevalleyAdj(cent),[[8,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,4,7],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;

#
# cls 21: D_7(a_2)
#
handle21char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[21];
    info:=infos[21];

    rep:=Representative(o);

    #pr[113]=[2,3,3,5,4,3,2,1]
    #pr[114]=[2,2,4,5,4,3,2,1]
    tmp1:=ApplyRootsReflections(rep,[113,114]);
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[6,1],[11,-1],[13,-1],[20,-1],[27,1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[5,6],[-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[113,114]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[6,1],[11,-1],[13,-1],[20,-1],[27,1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[5,6],[-1,-1,-1,-1]);

    return [tmp1,tmp2];
end;
#
# THIS IS FOR THE D_7(a_2) class in E_8 characteristic 3
#
#set:=Filtered(subs,i->i<=63);
#Sort(set);
#uu:=Unipotent(alg,List(set,i->[i,avars[i]]),Ordering(rep));
#
#vals:=ShallowCopy(avars);
#vals[4]:=0;
#vals[3]:=vals[2];
#vals[5]:=vals[3]-vals[2];
#vals[6]:=One(APR);
#vals[7]:=0;
#vals[8]:=vals[2];
#vals[11]:=-vals[3]-vals[10]-One(APR);
#vals[12]:=vals[3];
#vals[13]:=-vals[2]+vals[10]-One(APR);
#vals[14]:=vals[8];
#vals[17]:=vals[2]^2+vals[2]-vals[15];
#vals[18]:=-vals[2]-vals[17];
#vals[19]:=vals[3]^2-vals[2]-vals[18];
#vals[20]:=vals[13]+vals[10];
#vals[21]:=vals[15];
#vals[22]:=-vals[2]^2-vals[2]+vals[15]-vals[17];
#vals[26]:=-vals[2]*vals[10]-vals[10]^2-vals[10]+vals[17];
#vals[27]:=vals[2]+vals[10]+vals[17]-vals[26]+One(APR);
#vals[28]:=vals[18]+vals[15];
#vals[32]:=-(-vals[2]^3-vals[2]+vals[15]-vals[25]-vals[29]);
#vals[33]:=-(vals[2]^2*vals[10]-vals[2]^2+vals[2]*vals[10]-vals[2]-vals[15]-vals[32]);
#vals[34]:=vals[2]^2+vals[25]+vals[32];
#vals[35]:=-vals[2]^3-vals[2]^2-vals[2]+vals[15]+vals[25]-vals[34];
#vals[36]:=vals[2]*vals[15]+vals[10]*vals[15]+vals[15]+vals[29]+vals[34];
#vals[41]:=-(vals[2]^4+vals[2]^3+vals[2]^2-vals[15]^2+vals[25]);
#vals[43]:=vals[2]^3-vals[2]^2*vals[15]+vals[2]^2-vals[2]*vals[15]+vals[15]^2+vals[2]-vals[15]-vals[25]+vals[34]+vals[35]-vals[36]+vals[41]-vals[42];
#vals[48]:=-vals[2]^4+vals[2]^3*vals[10]+vals[2]^3-vals[2]^2*vals[15]+vals[2]*vals[10]*vals[15]+vals[10]^2*vals[15]+vals[2]*vals[10]-vals[10]*vals[15]-vals[15]^2-vals[2]-vals[25]+vals[29]+vals[42];
#vals[49]:=-(vals[2]^4+vals[2]^3+vals[2]^2*vals[15]+vals[2]*vals[10]*vals[15]+vals[10]^2*vals[15]-vals[2]*vals[15]+vals[10]*vals[15]+vals[15]^2+vals[41]-vals[42]);
#vals[55]:=-(-vals[2]^4-vals[2]^2*vals[10]*vals[15]-vals[2]^3+vals[2]^2*vals[15]-vals[2]^2*vals[25]-vals[2]*vals[10]*vals[15]-vals[2]^2+vals[2]*vals[15]+vals[2]*vals[25]-vals[15]^2-vals[15]*vals[25]-vals[25]+vals[50]);
#vals[61]:=-(vals[2]^4*vals[10]+vals[2]^3*vals[10]-vals[2]^2*vals[10]*vals[15]+vals[2]^3+vals[2]^2*vals[10]+vals[2]^2*vals[15]-vals[2]*vals[10]*vals[15]-vals[2]*vals[10]-vals[2]*vals[15]-vals[10]*vals[15]-vals[15]^2-vals[2]-vals[15]-vals[32]-vals[41]+vals[42]+vals[48]-vals[49]+vals[56]);
#vals[62]:=-(-vals[2]^6+vals[2]^5+vals[2]^3*vals[10]*vals[15]-vals[2]^3*vals[15]+vals[2]^3*vals[25]-vals[2]^3*vals[29]+vals[2]^2*vals[10]*vals[15]-vals[2]*vals[10]*vals[15]^2-vals[10]^2*vals[15]^2+vals[2]^3+vals[2]^2*vals[15]+vals[2]^2*vals[25]-vals[2]*vals[10]*vals[15]+vals[2]*vals[15]^2+vals[2]*vals[15]*vals[25]+vals[10]*vals[15]*vals[25]-vals[15]^3-vals[2]^2+vals[2]*vals[15]+vals[2]*vals[25]-vals[2]*vals[29]+vals[15]*vals[29]+vals[25]^2-vals[25]*vals[29]+vals[29]^2+vals[25]-vals[50]);
#
#vv:=Value(uu,avars,vals);
#vvv:=Value(vv,avars,List(avars,i->0));

#
# cls 18: E_6(a_1)A_1
#
handle18char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[18];
    info:=infos[18];

    #pr[106]=[1,2,2,4,4,3,2,1]
    #pr[105]=[1,2,3,4,3,3,2,1]
    #pr[104]=[2,2,3,4,3,2,2,1]

    # this is for E_6(a_1)A_1
    rep:=Representative(o);
    tmp1:=ApplyRootsReflections(rep,[106,105,104]);
    tmp1:=ConjNegUa(tmp1,4,-1);
    uu:=Unipotent(chevalleyAdj(rep),[[2,1],[11,1],[12,-1],[5,1],[10,-1],[18,-1],[19,-1],[26,-1],[27,1],[32,1],[40,-1],[48,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[1,2,3,5,6],[-1,-1,-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[106,105,104]);
    tmp2:=ConjNegUa(tmp2,4,-1);
    uu:=Unipotent(chevalleyAdj(cent),[[2,1],[11,1],[12,-1],[5,1],[10,-1],[18,-1],[19,-1],[26,-1],[27,1],[32,1],[40,-1],[48,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[1,2,3,5,6],[-1,-1,-1,-1,-1]);

    return [tmp1,tmp2,uu];
end;
#
# THIS IS FOR THE E_6(a_1)A_1 class in E_7 characteristic 3
#
#set:=List(Filtered(pr,i->i[7]=0 and i[8]=0),j->Position(pr,j));
#uu:=Unipotent(alg,List(set,i->[i,avars[i]]),Ordering(rep));
#vals:=ShallowCopy(avars);
#vals[2]:=One(APR)-vals[1];
#vals[3]:=0;
#vals[4]:=0;
#vals[5]:=vals[1]+One(APR);
#vals[6]:=vals[5]-One(APR);
#vals[11]:=One(APR)-vals[1];
#vals[10]:=-One(APR);
#vals[12]:=-vals[1]-vals[10]+One(APR);
#vals[13]:=-vals[1]^2-vals[1]-vals[9];
#vals[16]:=-(-vals[1]^2+vals[1]+vals[9]);
#vals[17]:=-(-vals[1]^2+vals[1]-vals[16]);
#vals[18]:=-vals[1]^2+vals[1]+vals[9]-One(APR);
#vals[19]:=-(-vals[1]^2-vals[1]+vals[9]-vals[16]-One(APR));
#vals[20]:=vals[1]^2-vals[18]-One(APR);
#vals[24]:=-(vals[1]^3-vals[1]^2+vals[1]*vals[9]+vals[9]-vals[23]);
#vals[25]:=-(vals[1]^3-vals[1]^2-vals[1]*vals[9]-vals[9]-vals[23]-vals[24]);
#vals[26]:=-vals[1]^2-vals[23]-One(APR);
#vals[27]:=-(vals[1]^3+vals[1]^2-vals[1]*vals[9]-vals[1]-vals[9]-vals[24]-One(APR));
#vals[30]:=-(vals[1]^4+vals[1]^3+vals[1]^2*vals[9]+vals[1]^2-vals[1]*vals[9]+vals[9]^2-vals[23]);
#vals[32]:=-(vals[1]^3+vals[1]^2-vals[9]-vals[23]+One(APR));
#vals[33]:=-(vals[1]^4-vals[1]^3-vals[1]^2-vals[1]*vals[9]+vals[1]+vals[24]-vals[30]-vals[31]);
#vals[37]:=-vals[1]^4+vals[1]^3+vals[1]^2*vals[9]-vals[1]*vals[9]-vals[9]^2+vals[9]-vals[23]+vals[31];
#vals[40]:=-(vals[1]^4+vals[1]^3-vals[1]^2*vals[9]+vals[1]^2+vals[1]*vals[9]-vals[1]-vals[9]-vals[37]+One(APR));
#vals[44]:=vals[1]^4-vals[1]^3*vals[9]+vals[1]^3+vals[1]^2*vals[9]+vals[1]*vals[9]^2+vals[1]^2-vals[9]^2-vals[23]+vals[38];
#vals[48]:=-(-vals[1]^5-vals[1]^4-vals[1]^3*vals[9]-vals[1]^2*vals[9]-vals[1]^2+vals[1]*vals[9]-vals[9]^2-vals[1]+vals[9]-vals[23]+vals[37]+vals[38]-vals[45]+One(APR));
#vals[51]:=-vals[1]^4-vals[1]^3*vals[23]+vals[1]^2*vals[9]^2-vals[1]^3+vals[1]*vals[9]^2-vals[1]^2-vals[1]*vals[23]-vals[9]^2+vals[23]^2+vals[23]+vals[38];
#vals[52]:=vals[1]^6+vals[1]^5-vals[1]^4*vals[9]+vals[1]^4+vals[1]^3*vals[9]+vals[1]^2*vals[9]^2+vals[1]^3-vals[1]^2*vals[9]-vals[1]^2*vals[23]-vals[1]*vals[9]^2+vals[9]^3-vals[1]^2+vals[9]^2+vals[23]^2+vals[23]-vals[31]-vals[38]+vals[45];
#vals[63]:=-(-vals[1]^6-vals[1]^5*vals[9]-vals[1]^4*vals[9]-vals[1]^3*vals[9]^2-vals[1]^3*vals[9]-vals[1]^3*vals[23]-vals[1]^3*vals[31]-vals[1]*vals[9]^3+vals[1]^3-vals[1]^2*vals[9]+vals[1]^2*vals[23]-vals[1]^2*vals[31]-vals[9]^3-vals[9]^2*vals[23]-vals[1]*vals[9]-vals[1]*vals[23]+vals[9]^2+vals[9]*vals[31]+vals[23]^2+vals[23]*vals[31]-vals[9]+vals[23]-vals[31]);
#
#vv:=Value(uu,avars,vals);
#vvv:=Value(vv,avars,List(avars,i->0));

#
# cls 17: E_7(a_3) ([1,4,6,7,15,16,17] in E_7) [1,4,6,7,17,18,19] in E_8 this doesn't work in char2
#
handle17char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[17];
    info:=infos[17];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

# This is for Seitz' representative in first table
#
# cls 16: E_8(b_6)
#
#handle16char3:=function(orbs,infos)
#    local tmp1,tmp2,o,info,rep,cent;
#    o:=Classes(orbs)[16];
#    #info:=infos[16];
#
#    rep:=Representative(o);
#    tmp1:=ConjugateByTori(rep,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    tmp2:=0;
#    #cent:=FromPositiveBorel(o,info[2]);
#    #tmp2:=ConjugateByTori(cent,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    return [tmp1,tmp2];
#end;

# This is for Seitz' representative used in proof
#
# cls 16: E_8(b_6)
#
handle16char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[16];
    info:=infos[16];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[12,13,15],[-1,-1,-1,-1]);# should be Z(D_8)

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[12,13,15],[-1,-1,-1,-1]);# should be Z(D_8)

    return [tmp1,tmp2];
end;

#
# cls 15: D_7(a_1)
#
handle15char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent,uu;
    o:=Classes(orbs)[15];
    info:=infos[15];

    rep:=Representative(o);

    #pr[113]=[2,3,3,5,4,3,2,1]
    #pr[114]=[0,0,1,1,1,1,1,0]
    tmp1:=ApplyRootsReflections(rep,[113,114]);
    #uu:=Unipotent(chevalleyAdj(rep),[[4,1],[10,-1]],Ordering(rep)); si asta merge
    uu:=Unipotent(chevalleyAdj(rep),[[4,1],[11,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTori(tmp1,[2,3,4],[aaa,aaa,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ApplyRootsReflections(cent,[113,114]);
    uu:=Unipotent(chevalleyAdj(cent),[[4,1],[11,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTori(tmp2,[2,3,4],[aaa,aaa,-1]);

    return [tmp1,tmp2];
end;

#
# cls 12: E_8(a_6)
#
handle12char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu,vars;
    o:=Classes(orbs)[12];
    info:=infos[12];

    # L(Q)_2 has dimension 24 and should correspond to [ 4, 12, 14, 15, 21, 23, 25, 26, 31, 37, 46, 47, 53, 55, 57, 72, 73, 82, 90, 92, 97, 104, 106, 113 ]
    rep:=Representative(o);

    vars:=ShallowCopy(avars);#List([1..120],i->avars[i]);
    #vars[5]:=vars[1]*vars[2]*vars[3]-vars[1]*vars[3]*vars[13]-vars[2]*vars[3]*vars[5]+vars[2]*vars[9]-vars[2]*vars[13]-vars[9]*vars[13];
    vars[9]:=One(APR);
    vars[1]:=-vars[9]^2;#0;
    vars[2]:=vars[9]^3;
    #vars[9]:=One(APR);# sau -1
    vars[3]:=0;#-vars[9];
    vars[5]:=vars[1];
    #vars[23]:=-vars[9];
    #vars[2]:=vars[3]*vars[9]*vars[23]-vars[9]^2*vars[23];
    #vars[5]:=1;
    vars[26]:=-One(APR);
    vars[21]:=Zero(APR);
    vars[13]:=vars[1]*vars[3]-vars[3]*vars[5]+vars[9];
    vars[23]:=-vars[9]^3;
    vars[29]:=-(vars[9]^3*vars[21]+vars[2]-vars[9]);#0=-vars[21];

    tmp1:=ConjNegUa(rep,2,vars[2]);#1
    tmp1:=ConjNegUa(tmp1,5,vars[5]);#-1
    #tmp1:=ConjNegUa(tmp1,6,avars[6]);
    tmp1:=ConjNegUa(tmp1,13,vars[13]);#1
    #uu:=Unipotent(chevalleyAdj(rep),[[6,One(APR)]],Ordering(rep));
    #tmp1:=Conj(tmp1,uu);
    tmp1:=ConjNegUa(tmp1,1,vars[1]);#-1
    tmp1:=ConjNegUa(tmp1,3,vars[3]);#0
    tmp1:=ConjNegUa(tmp1,9,vars[9]);#1
    uu:=Unipotent(chevalleyAdj(rep),[[1,vars[21]],[3,vars[23]],[6,vars[26]],[9,vars[29]]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[4, -1 ], [ 8, -1 ], [ 10, 1 ], [ 11, -1 ], [ 14, 1 ], [ 15, 1 ], [ 16, 1 ], [ 19, -1 ], [ 21, -1 ], [ 22, -1 ], [ 23, -1 ], [ 25, 1 ], [ 26, 1 ], [ 27, -1 ], [ 28, 1 ], [ 30, -1 ], [ 31, 1 ], [ 32, 1 ], [ 33, -1 ], [ 34, 1 ], [ 36, -1 ], [ 37, -1 ], [ 40, -1 ], [ 41, 1 ], [ 42, 1 ], [ 44, 1 ], [ 47, -1 ], [ 50, 1 ], [ 52, -1 ], [ 54, 1 ], [ 55, -1 ], [ 57, -1 ], [ 61, -1 ], [ 62, 1 ], [ 65, 1 ], [ 69, 1 ], [ 76, -1 ], [ 77, -1 ], [ 78, 1 ], [ 81, -1 ], [ 82, -1 ], [ 83, 1 ], [ 85, -1 ], [ 86, -1 ], [ 91, 1 ], [ 93, -1 ], [ 94, 1 ], [ 97, 1 ], [ 98, -1 ], [ 102, -1 ], [ 103, -1 ], [ 106, 1 ], [ 107, -1 ], [ 108, 1 ], [ 109, -1 ], [ 111, -1 ], [ 114, -1 ], [ 115, -1 ], [ 117, 1 ], [ 118, -1 ] ],Ordering(rep));
    #uu:=Unipotent(chevalleyAdj(rep),[[1,avars[1]],[9,avars[9]]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    #tmp1:=ConjNegUa(tmp1,3,avars[3]);

    tmp3:=ConjugateByTori(rep,[4,6,7],[-1,-1,-1]);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjNegUa(cent,2,vars[2]);
    tmp2:=ConjNegUa(tmp2,5,vars[5]);
    tmp2:=ConjNegUa(tmp2,13,vars[13]);
    tmp2:=ConjNegUa(tmp2,1,vars[1]);
    tmp2:=ConjNegUa(tmp2,3,vars[3]);
    tmp2:=ConjNegUa(tmp2,9,vars[9]);
    uu:=Unipotent(chevalleyAdj(cent),[[1,vars[21]],[3,vars[23]],[6,vars[26]],[9,vars[29]]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    uu:=Unipotent(chevalleyAdj(cent),[[4, -1 ], [ 8, -1 ], [ 10, 1 ], [ 11, -1 ], [ 14, 1 ], [ 15, 1 ], [ 16, 1 ], [ 19, -1 ], [ 21, -1 ], [ 22, -1 ], [ 23, -1 ], [ 25, 1 ], [ 26, 1 ], [ 27, -1 ], [ 28, 1 ], [ 30, -1 ], [ 31, 1 ], [ 32, 1 ], [ 33, -1 ], [ 34, 1 ], [ 36, -1 ], [ 37, -1 ], [ 40, -1 ], [ 41, 1 ], [ 42, 1 ], [ 44, 1 ], [ 47, -1 ], [ 50, 1 ], [ 52, -1 ], [ 54, 1 ], [ 55, -1 ], [ 57, -1 ], [ 61, -1 ], [ 62, 1 ], [ 65, 1 ], [ 69, 1 ], [ 76, -1 ], [ 77, -1 ], [ 78, 1 ], [ 81, -1 ], [ 82, -1 ], [ 83, 1 ], [ 85, -1 ], [ 86, -1 ], [ 91, 1 ], [ 93, -1 ], [ 94, 1 ], [ 97, 1 ], [ 98, -1 ], [ 102, -1 ], [ 103, -1 ], [ 106, 1 ], [ 107, -1 ], [ 108, 1 ], [ 109, -1 ], [ 111, -1 ], [ 114, -1 ], [ 115, -1 ], [ 117, 1 ], [ 118, -1 ] ],Ordering(cent));
    tmp2:=Conj(tmp2,uu);

    tmp4:=0;
    tmp4:=ConjugateByTori(cent,[4,6,7],[-1,-1,-1]);

    return [tmp1,tmp3,tmp2,tmp4,uu];
end;

#
# cls 10: E_8(b_5)
#
handle10char3:=function(orbs,infos)
    local tmp1,tmp2,tmp3,tmp4,o,info,rep,cent,uu;
    o:=Classes(orbs)[10];
    info:=infos[10];

    rep:=Representative(o);
    tmp1:=ConjNegUa(rep,1,1);
    tmp1:=ConjNegUa(tmp1,3,-1);
    tmp1:=ConjNegUa(tmp1,9,-1);
    tmp1:=ConjNegUa(tmp1,2,1);
    uu:=Unipotent(chevalleyAdj(rep),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    uu:=Unipotent(chevalleyAdj(rep),[[8,1],[10,-1],[11,1],[16,-1],[20,1],[21,1],[25,1],[27,-1],[30,-1],[31,1],[32,-1],[33,-1],[37,1],[38,-1],[40,1],[44,-1],[46,-1],[52,1],[55,-1],[59,1],[61,1],[63,1],[64,-1],[69,-1],[82,-1],[90,1],[93,1],[97,-1]],Ordering(rep));
    tmp1:=Conj(tmp1,uu);
    tmp1:=ConjugateByTorus(tmp1,1,-1);

    tmp3:=ConjugateByTorus(rep,18,-1);

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjNegUa(cent,1,1);
    tmp2:=ConjNegUa(tmp2,3,-1);
    tmp2:=ConjNegUa(tmp2,9,-1);
    tmp2:=ConjNegUa(tmp2,2,1);
    uu:=Unipotent(chevalleyAdj(cent),[[1,-1],[3,1],[5,-1],[6,-1],[9,1],[13,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    uu:=Unipotent(chevalleyAdj(cent),[[8,1],[10,-1],[11,1],[16,-1],[20,1],[21,1],[25,1],[27,-1],[30,-1],[31,1],[32,-1],[33,-1],[37,1],[38,-1],[40,1],[44,-1],[46,-1],[52,1],[55,-1],[59,1],[61,1],[63,1],[64,-1],[69,-1],[82,-1],[90,1],[93,1],[97,-1]],Ordering(cent));
    tmp2:=Conj(tmp2,uu);
    tmp2:=ConjugateByTorus(tmp2,1,-1);

    tmp4:=0;
    tmp4:=ConjugateByTorus(cent,18,-1);

    return [tmp1,tmp3,tmp2,tmp4,uu];
end;

# For representative deduced from Seitz' E_8(b_6) given in first table
#
# cls 8: E_8(a_5)
#
#handle8char3:=function(orbs,infos)
#    local tmp1,tmp2,o,info,rep,cent;
#    o:=Classes(orbs)[8];
#    #info:=infos[8];
#
#    rep:=Representative(o);
#    tmp1:=ConjugateByTori(rep,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    tmp2:=0;
#    #cent:=FromPositiveBorel(o,info[2]);
#    #tmp2:=ConjugateByTori(cent,[3,4,7,8],[-1,-1,-1,-1]);# same as [11,15] should be Z(D_8)
#
#    return [tmp1,tmp2];
#end;

# For representative deduced from Seitz' E_8(a_6) used in proof
#
# cls 8: E_8(a_5)
#
handle8char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[8];
    info:=infos[8];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[4,6,7],[-1,-1,-1,-1]);# should be Z(D_8)

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[4,6,7],[-1,-1,-1,-1]);# should be Z(D_8)

    return [tmp1,tmp2];
end;

#
# cls 7: E_8(b_4) [1,4,7,8,14,17,19,26]  this doesn't work in char2
#
handle7char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[7];
    info:=infos[7];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;

#
# cls 5: E_8(a_4) [1,4,6,8,17,18,19,21]  this doesn't work in char2
#
handle5char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[5];
    info:=infos[5];

    rep:=Representative(o);
    tmp1:=ConjugateByTori(rep,[4,8],[-1,-1]);# h_4, h_8

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTori(cent,[4,8],[-1,-1]); # h_4, h_8

    return [tmp1,tmp2];
end;

#
# cls 4: E_8(a_3) [1,4,6,7,8,17,18,19]  this doesn't work in char2
#
handle4char3:=function(orbs,infos)
    local tmp1,tmp2,o,info,rep,cent;
    o:=Classes(orbs)[4];
    info:=infos[4];

    rep:=Representative(o);
    tmp1:=ConjugateByTorus(rep,4,-1);# h_1 --> h_4

    tmp2:=0;
    cent:=FromPositiveBorel(o,info[2]);
    tmp2:=ConjugateByTorus(cent,4,-1);# h_1 --> h_4

    return [tmp1,tmp2];
end;