(*{{2,8,9,16},{3,4}}

 I only add comments where there is non-trivial deviation from the "commented" and "bettercommented" file.
*)

Dynamic[{j,i,g, mark}]
Clear[n,B,R,Tile,A,U,mark,T,g,x];

L=Expand[Cyclotomic[4,x^(9)]Cyclotomic[3,x^(16)]];

n=144;

B=Array[0&,Length[L]];
For[j=2, j≤Length[L], B[[j]]=Mod[L[[j,2]],n];
j++];
B⋃{}


(*{{2,8,9,16},{3,4}};

Here i make a crosscheking of the "maxperiod" procedure. In fact i KNOW that there will be different maxperiods, and i wanted to see that my program indeed finds them. It does. 

*)

Dynamic[{jj,j,i,g, mark, rr}]
Clear[n,J,B,R,Tile,A,U,mark,T,g,x];

n=144;

J={{0,16,18,32,34,50}};
rr=1;
gcd=Array[0&,{Length[J],Length[J[[1]]]}];
For[kk=1,kk≤Length[J],
For[mm=2,mm≤Length[J[[kk]]],
gcd[[kk,mm]]=GCD[gcd[[kk,mm-1]],J[[kk,mm]]];
mm++];
kk++];
For[kk=1,kk≤Length[J], gcd[[kk,Length[J[[1]]]]]=GCD[gcd[[kk,Length[J[[1]]]]],n];
kk++];

maxperiod=Array[0&,{Length[J],10000}];

For[jj=1, jj≤Length[J],Clear[B,R,Tile,A,U,mark,T,g,x];n=144;n=n/gcd[[jj, Length[J[[1]]]]];B=J[[jj]]/gcd[[jj,Length[J[[1]]]]];

Tile=Array[0&,100000];
R=Array[0&,n];
A=Array[200&,{n/Length[B],n,Length[B]}];
U=Array[0&,n/Length[B]];
U[[1]]=B;
mark=Array[1&,n/Length[B]+1];
T=Array[{0}&,n/Length[B]];
g=1;

For[i=1, i>0,
If[Length[U[[i]]]==n,  Tile[[g]]=T[[i]]⋃{};maxperiod[[jj,g]]=99;
For[ff=Length[Divisors[n]]-1, ff>0,
If[Mod[((Divisors[n][[ff]])+Tile[[g]]),n]⋃{}==Tile[[g]],Tile[[g]]=0;maxperiod[[jj,g]]=Divisors[n][[ff]];ff=0;
 ];
ff=ff-1];
 g=g+1;T[[i]]=T[[i-1]];mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1,
For[j=1, j≤n,k=100;
If[Not[MemberQ[U[[i]],Mod[j,n]]], k=0;
For[m=1, m≤Length[B],
If[U[[i]]⋂ Mod[(j-B[[m]])+B,n]=={}, k=k+1; A[[i,j,m]]=Mod[j-B[[m]],n]];
m++]];
R[[j]]=k;
j++];
min=Min[R]; 
If[(Not[min==0]),
t=Catch[Do[If[R[[ii]]==min, Throw[ii]],{ii,n}]];
If[mark[[i]]≤Length[B],
For[b=mark[[i]], b<=Length[B],mark[[i]]=b+1;z=0;
If[Not[A[[i,t,b]]==200], U[[i+1]]=U[[i]]⋃Mod[A[[i,t,b]]+B,n]; T[[i+1]]=T[[i]]⋃{A[[i,t,b]]}; b=Length[B]+1;z=1;i=i+1;];
b++];
If[z==0, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
];
];

Tile=Drop[Tile⋃{0},1];
Length[Tile]
Tile;

For[j=1, j≤Length[Tile], P=Tile[[j]];
For[i=2, i<=Length[P], 
If[MemberQ[Tile,Mod[P-P[[i]],n]⋃{}], Tile[[j]]=0;i=Length[P]+1];
i++];
j++]; 
Tile=Drop[Tile⋃{0},1];
If[Not[Length[Tile]==0], rr=rr+1];
Tile;
jj++];
rr

For[j=1,j≤Length[maxperiod],maxperiod[[j]]=Drop[maxperiod[[j]]⋃{0},1];
j++];
maxperiod

(*{{2,8,9,16},{3,4}}; Let us get back to the normal track of events. The fill-out procedure for B. *)

Dynamic[{j,i,g, mark}]
Clear[n,B,R,Tile,A,U,mark,T,g,x];

n=144;

B={0,16,18,32,34,50}

Length[B];

Tile=Array[0&,1000000];
R=Array[0&,n];
A=Array[200&,{n/Length[B],n,Length[B]}];
U=Array[0&,n/Length[B]];
U[[1]]=B;
mark=Array[1&,n/Length[B]+1];
T=Array[{0}&,n/Length[B]];
g=1;

For[i=1, i>0,
If[Length[U[[i]]]==n,  Tile[[g]]=T[[i]]⋃{};g=g+1;T[[i]]=T[[i-1]];mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1,
For[j=1, j≤n,k=100;
If[Not[MemberQ[U[[i]],Mod[j,n]]], k=0;
For[m=1, m≤Length[B],
If[U[[i]]⋂ Mod[(j-B[[m]])+B,n]=={}, k=k+1; A[[i,j,m]]=Mod[j-B[[m]],n]];
m++]];
R[[j]]=k;
j++];
min=Min[R]; 
If[(Not[min==0]),
t=Catch[Do[If[R[[ii]]==min, Throw[ii]],{ii,n}]];
If[mark[[i]]≤Length[B],
For[b=mark[[i]], b<=Length[B],mark[[i]]=b+1;z=0;
If[Not[A[[i,t,b]]==200], U[[i+1]]=U[[i]]⋃Mod[A[[i,t,b]]+B,n]; T[[i+1]]=T[[i]]⋃{A[[i,t,b]]}; b=Length[B]+1;z=1;i=i+1;];
b++];
If[z==0, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
];
];

Tile=Drop[Tile⋃{},1];
Length[Tile]
Tile;

H=Array[{0}&,Length[Tile[[1]]]+1];
K=Tile[[3]];
For[j=1, j≤Length[K], 
H[[j+1]]=Mod[(K[[j]]+B)⋃ H[[j]],n];
j++];
H[[Length[K]+1]]⋃{} 

For[j=1, j≤Length[Tile], P=Tile[[j]];
For[i=2, i<=Length[P], 
If[MemberQ[Tile,Mod[P-P[[i]],n]⋃{}], Tile[[j]]=0;i=Length[P]+1];
i++];
j++]; 
Tile=Drop[Tile⋃{},1];
Length[Tile]
Tile

(* Here comes a slightly earlier-written version of the Fourier-selection procedure. It is just non-optimal programming. It contains MT and MTT and all that stuff. But it does the job, the 36 tiles fall into 2 classes. 

*)

T2={{0,17,20,23,28,29,40,48,53,59,65,68,76,88,89,95,96,101,116,124,125,131,136,137},{0,17,24,25,30,36,37,45,60,65,66,72,73,85,93,96,102,108,113,121,132,133,138,141},{0,19,20,24,25,28,31,48,55,61,67,68,72,76,91,96,97,103,116,120,124,127,133,139},{0,19,20,25,28,31,40,48,55,61,67,68,76,88,91,96,97,103,116,124,127,133,136,139},{0,19,23,24,30,31,36,43,60,66,67,71,72,79,91,96,102,108,115,119,127,132,138,139},{0,19,24,25,28,31,36,48,55,61,67,72,76,84,91,96,97,103,120,124,127,132,133,139},{0,19,24,25,31,36,44,48,55,61,67,72,84,91,92,96,97,103,120,127,132,133,139,140},{0,19,24,27,30,36,39,47,60,66,67,72,75,87,95,96,102,108,115,123,132,135,138,143},{0,19,24,30,31,36,39,43,60,66,67,72,79,87,91,96,102,108,115,127,132,135,138,139},{0,19,24,30,36,39,43,47,60,66,67,72,87,91,95,96,102,108,115,132,135,138,139,143},{0,20,21,24,27,28,33,48,57,63,68,69,72,76,93,96,99,105,116,120,124,129,135,141},{0,20,21,27,28,33,40,48,57,63,68,69,76,88,93,96,99,105,116,124,129,135,136,141},{0,20,21,27,33,40,44,48,57,63,68,69,88,92,93,96,99,105,116,129,135,136,140,141},{0,20,23,24,28,29,35,48,59,65,68,71,72,76,95,96,101,107,116,120,124,131,137,143},{0,20,23,28,29,35,40,48,59,65,68,71,76,88,95,96,101,107,116,124,131,136,137,143},{0,20,23,29,35,40,44,48,59,65,68,71,88,92,95,96,101,107,116,131,136,137,140,143},{0,21,24,25,30,33,36,45,60,66,69,72,73,81,93,96,102,108,117,121,129,132,138,141},{0,21,24,27,28,33,36,48,57,63,69,72,76,84,93,96,99,105,120,124,129,132,135,141},{0,21,24,27,33,36,44,48,57,63,69,72,84,92,93,96,99,105,120,129,132,135,140,141},{0,21,24,29,30,33,36,41,60,66,69,72,77,81,89,96,102,108,117,125,129,132,137,138},{0,21,24,30,33,36,41,45,60,66,69,72,81,89,93,96,102,108,117,129,132,137,138,141},{0,21,27,28,33,36,40,48,57,63,69,76,84,88,93,96,99,105,124,129,132,135,136,141},{0,23,24,27,30,35,36,47,60,66,71,72,75,83,95,96,102,108,119,123,131,132,138,143},{0,23,24,28,29,35,36,48,59,65,71,72,76,84,95,96,101,107,120,124,131,132,137,143},{0,23,24,29,35,36,44,48,59,65,71,72,84,92,95,96,101,107,120,131,132,137,140,143},{0,23,24,30,31,35,36,43,60,66,71,72,79,83,91,96,102,108,119,127,131,132,138,139},{0,23,24,30,35,36,43,47,60,66,71,72,83,91,95,96,102,108,119,131,132,138,139,143},{0,23,28,29,35,36,40,48,59,65,71,76,84,88,95,96,101,107,124,131,132,136,137,143},{0,24,25,29,30,33,36,37,60,66,72,73,77,81,85,96,102,108,121,125,129,132,133,138},{0,24,25,30,33,36,37,45,60,66,72,73,81,85,93,96,102,108,121,129,132,133,138,141},{0,24,27,30,31,35,36,39,60,66,72,75,79,83,87,96,102,108,123,127,131,132,135,138},{0,24,27,30,35,36,39,47,60,66,72,75,83,87,95,96,102,108,123,131,132,135,138,143},{0,24,29,30,33,36,37,41,60,66,72,77,81,85,89,96,102,108,125,129,132,133,137,138},{0,24,30,31,35,36,39,43,60,66,72,79,83,87,91,96,102,108,127,131,132,135,138,139},{0,24,30,33,36,37,41,45,60,66,72,81,85,89,93,96,102,108,129,132,133,137,138,141},{0,24,30,35,36,39,43,47,60,66,72,83,87,91,95,96,102,108,131,132,135,138,139,143}};


Length[T2]

H=Array[0&,{Length[T2],144}];
MF=Array[0&,Length[T2]];
MT=Array[0&,Length[T2]];
For[j=1, j≤Length[T2], 
For[k=1, k≤144,
If[MemberQ[T2[[j]],Mod[k,144]],H[[j,k]]=1];
k++];
j++];

(*vv=1;
For[k=1, k<=144,
If[Chop[Fourier[H[[1]]]][[k]]==0, vv=vv+1];
k++];*)
v=1;
For[j=2, j≤Length[T2],
For[k=1, k≤144,
If[(Not[Chop[Fourier[H[[1]]]][[k]]==Chop[Fourier[H[[j]]]][[k]]])∧(Chop[Fourier[H[[1]]]][[k]]==0∨Chop[Fourier[H[[j]]]][[k]]==0), MF[[v]]=H[[j]];MT[[v]]=T2[[j]]; v=v+1; k=145];
k++];
j++]; 


MT=Drop[MT⋃{},1];
MF=Drop[MF⋃{},1];
Length[MF]

MMF=Array[0&,Length[T2]];
MMT=Array[0&,Length[T2]];
vvv=1;

For[j=2, j≤Length[MF],
For[k=1, k≤144,
If[(Not[Chop[Fourier[MF[[1]]]][[k]]==Chop[Fourier[MF[[j]]]][[k]]])∧(Chop[Fourier[MF[[1]]]][[k]]==0∨Chop[Fourier[MF[[j]]]][[k]]==0), MMF[[vvv]]=MF[[j]];MMT[[vvv]]=MT[[j]]; vvv=vvv+1; k=145];
k++];
j++]; 

MMT=Drop[MMT⋃{},1];
MMF=Drop[MMF⋃{},1];
Length[MMF]


MT



(*{{2,8,9,16},{3,4}};*)

Dynamic[{j,i,g, mark}]
Clear[n,B,R,Tile,A,U,mark,T,g,x];

n=144;
(*A representative of the first class*)
B={0,21,24,29,30,33,36,41,60,66,69,72,77,81,89,96,102,108,117,125,129,132,137,138}
Length[B];

Tile=Array[0&,1000000];
R=Array[0&,n];
A=Array[200&,{n/Length[B],n,Length[B]}];
U=Array[0&,n/Length[B]];
U[[1]]=B;
mark=Array[1&,n/Length[B]+1];
T=Array[{0}&,n/Length[B]];
g=1;

For[i=1, i>0,
If[Length[U[[i]]]==n,  Tile[[g]]=T[[i]]⋃{};g=g+1;T[[i]]=T[[i-1]];mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1,
For[j=1, j≤n,k=100;
If[Not[MemberQ[U[[i]],Mod[j,n]]], k=0;
For[m=1, m≤Length[B],
If[U[[i]]⋂ Mod[(j-B[[m]])+B,n]=={}, k=k+1; A[[i,j,m]]=Mod[j-B[[m]],n]];
m++]];
R[[j]]=k;
j++];
min=Min[R]; 
If[(Not[min==0]),
t=Catch[Do[If[R[[ii]]==min, Throw[ii]],{ii,n}]];
If[mark[[i]]≤Length[B],
For[b=mark[[i]], b<=Length[B],mark[[i]]=b+1;z=0;
If[Not[A[[i,t,b]]==200], U[[i+1]]=U[[i]]⋃Mod[A[[i,t,b]]+B,n]; T[[i+1]]=T[[i]]⋃{A[[i,t,b]]}; b=Length[B]+1;z=1;i=i+1;];
b++];
If[z==0, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
];
];

Tile=Drop[Tile⋃{},1];
Length[Tile]
Tile;

H=Array[{0}&,Length[Tile[[1]]]+1];
K=Tile[[3]];
For[j=1, j≤Length[K], 
H[[j+1]]=Mod[(K[[j]]+B)⋃ H[[j]],n];
j++];
H[[Length[K]+1]]⋃{} 

For[j=1, j≤Length[Tile], P=Tile[[j]];
For[i=2, i<=Length[P], 
If[MemberQ[Tile,Mod[P-P[[i]],n]⋃{}], Tile[[j]]=0;i=Length[P]+1];
i++];
j++]; 
Tile=Drop[Tile⋃{},1];
Length[Tile]
Tile



(*{{2,8,9,16},{3,4}};*)

Dynamic[{j,i,g, mark}]
Clear[n,B,R,Tile,A,U,mark,T,g,x];

n=144;
(*A representative of the second class*)
B={0,17,20,23,28,29,40,48,53,59,65,68,76,88,89,95,96,101,116,124,125,131,136,137}

Length[B];

Tile=Array[0&,1000000];
R=Array[0&,n];
A=Array[200&,{n/Length[B],n,Length[B]}];
U=Array[0&,n/Length[B]];
U[[1]]=B;
mark=Array[1&,n/Length[B]+1];
T=Array[{0}&,n/Length[B]];
g=1;

For[i=1, i>0,
If[Length[U[[i]]]==n,  Tile[[g]]=T[[i]]⋃{};g=g+1;T[[i]]=T[[i-1]];mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1,
For[j=1, j≤n,k=100;
If[Not[MemberQ[U[[i]],Mod[j,n]]], k=0;
For[m=1, m≤Length[B],
If[U[[i]]⋂ Mod[(j-B[[m]])+B,n]=={}, k=k+1; A[[i,j,m]]=Mod[j-B[[m]],n]];
m++]];
R[[j]]=k;
j++];
min=Min[R]; 
If[(Not[min==0]),
t=Catch[Do[If[R[[ii]]==min, Throw[ii]],{ii,n}]];
If[mark[[i]]≤Length[B],
For[b=mark[[i]], b<=Length[B],mark[[i]]=b+1;z=0;
If[Not[A[[i,t,b]]==200], U[[i+1]]=U[[i]]⋃Mod[A[[i,t,b]]+B,n]; T[[i+1]]=T[[i]]⋃{A[[i,t,b]]}; b=Length[B]+1;z=1;i=i+1;];
b++];
If[z==0, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
, mark[[i]]=1;A[[i]]=Array[200&,{n,Length[B]}];T[[i]]=T[[i-1]];i=i-1];
];
];

Tile=Drop[Tile⋃{},1];
Length[Tile]
Tile;

H=Array[{0}&,Length[Tile[[1]]]+1];
K=Tile[[3]];
For[j=1, j≤Length[K], 
H[[j+1]]=Mod[(K[[j]]+B)⋃ H[[j]],n];
j++];
H[[Length[K]+1]]⋃{} 

For[j=1, j≤Length[Tile], P=Tile[[j]];
For[i=2, i<=Length[P], 
If[MemberQ[Tile,Mod[P-P[[i]],n]⋃{}], Tile[[j]]=0;i=Length[P]+1];
i++];
j++]; 
Tile=Drop[Tile⋃{},1];
Length[Tile]
Tile

(*the same 6 tiles emerge for both classes*)

(* Crosscheking that all tiles with all.*)

Dynamic[{t1,t2, dd}]

T1={{0,32,58,90,112,122},{0,46,64,110,126,128},{0,54,64,80,118,134},{0,58,74,90,112,128},{0,62,80,94,112,126},{0,94,110,112,126,128}};

T2={{0,17,20,23,28,29,40,48,53,59,65,68,76,88,89,95,96,101,116,124,125,131,136,137},{0,17,24,25,30,36,37,45,60,65,66,72,73,85,93,96,102,108,113,121,132,133,138,141},{0,19,20,24,25,28,31,48,55,61,67,68,72,76,91,96,97,103,116,120,124,127,133,139},{0,19,20,25,28,31,40,48,55,61,67,68,76,88,91,96,97,103,116,124,127,133,136,139},{0,19,23,24,30,31,36,43,60,66,67,71,72,79,91,96,102,108,115,119,127,132,138,139},{0,19,24,25,28,31,36,48,55,61,67,72,76,84,91,96,97,103,120,124,127,132,133,139},{0,19,24,25,31,36,44,48,55,61,67,72,84,91,92,96,97,103,120,127,132,133,139,140},{0,19,24,27,30,36,39,47,60,66,67,72,75,87,95,96,102,108,115,123,132,135,138,143},{0,19,24,30,31,36,39,43,60,66,67,72,79,87,91,96,102,108,115,127,132,135,138,139},{0,19,24,30,36,39,43,47,60,66,67,72,87,91,95,96,102,108,115,132,135,138,139,143},{0,20,21,24,27,28,33,48,57,63,68,69,72,76,93,96,99,105,116,120,124,129,135,141},{0,20,21,27,28,33,40,48,57,63,68,69,76,88,93,96,99,105,116,124,129,135,136,141},{0,20,21,27,33,40,44,48,57,63,68,69,88,92,93,96,99,105,116,129,135,136,140,141},{0,20,23,24,28,29,35,48,59,65,68,71,72,76,95,96,101,107,116,120,124,131,137,143},{0,20,23,28,29,35,40,48,59,65,68,71,76,88,95,96,101,107,116,124,131,136,137,143},{0,20,23,29,35,40,44,48,59,65,68,71,88,92,95,96,101,107,116,131,136,137,140,143},{0,21,24,25,30,33,36,45,60,66,69,72,73,81,93,96,102,108,117,121,129,132,138,141},{0,21,24,27,28,33,36,48,57,63,69,72,76,84,93,96,99,105,120,124,129,132,135,141},{0,21,24,27,33,36,44,48,57,63,69,72,84,92,93,96,99,105,120,129,132,135,140,141},{0,21,24,29,30,33,36,41,60,66,69,72,77,81,89,96,102,108,117,125,129,132,137,138},{0,21,24,30,33,36,41,45,60,66,69,72,81,89,93,96,102,108,117,129,132,137,138,141},{0,21,27,28,33,36,40,48,57,63,69,76,84,88,93,96,99,105,124,129,132,135,136,141},{0,23,24,27,30,35,36,47,60,66,71,72,75,83,95,96,102,108,119,123,131,132,138,143},{0,23,24,28,29,35,36,48,59,65,71,72,76,84,95,96,101,107,120,124,131,132,137,143},{0,23,24,29,35,36,44,48,59,65,71,72,84,92,95,96,101,107,120,131,132,137,140,143},{0,23,24,30,31,35,36,43,60,66,71,72,79,83,91,96,102,108,119,127,131,132,138,139},{0,23,24,30,35,36,43,47,60,66,71,72,83,91,95,96,102,108,119,131,132,138,139,143},{0,23,28,29,35,36,40,48,59,65,71,76,84,88,95,96,101,107,124,131,132,136,137,143},{0,24,25,29,30,33,36,37,60,66,72,73,77,81,85,96,102,108,121,125,129,132,133,138},{0,24,25,30,33,36,37,45,60,66,72,73,81,85,93,96,102,108,121,129,132,133,138,141},{0,24,27,30,31,35,36,39,60,66,72,75,79,83,87,96,102,108,123,127,131,132,135,138},{0,24,27,30,35,36,39,47,60,66,72,75,83,87,95,96,102,108,123,131,132,135,138,143},{0,24,29,30,33,36,37,41,60,66,72,77,81,85,89,96,102,108,125,129,132,133,137,138},{0,24,30,31,35,36,39,43,60,66,72,79,83,87,91,96,102,108,127,131,132,135,138,139},{0,24,30,33,36,37,41,45,60,66,72,81,85,89,93,96,102,108,129,132,133,137,138,141},{0,24,30,35,36,39,43,47,60,66,72,83,87,91,95,96,102,108,131,132,135,138,139,143}};

NN={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143};

K=T1[[1]];
H=Array[{0}&,Length[K]+1];
dd=1;
For[t1=1, t1≤Length[T1], K=T1[[t1]];
For[t2=1,t2≤Length[T2],B=T2[[t2]];H[[1]]={0};
For[j=1, j≤Length[K], 
H[[j+1]]=Mod[(K[[j]]+B)⋃ H[[j]],n];
j++];
If[Not[H[[Length[K]+1]]⋃{}  == NN], dd=dd+1];
t2++];
t1++]; 
dd




Dynamic[{j,v,vvv,vvvv}]

T2={{0,17,20,23,28,29,40,48,53,59,65,68,76,88,89,95,96,101,116,124,125,131,136,137},{0,17,24,25,30,36,37,45,60,65,66,72,73,85,93,96,102,108,113,121,132,133,138,141},{0,19,20,24,25,28,31,48,55,61,67,68,72,76,91,96,97,103,116,120,124,127,133,139},{0,19,20,25,28,31,40,48,55,61,67,68,76,88,91,96,97,103,116,124,127,133,136,139},{0,19,23,24,30,31,36,43,60,66,67,71,72,79,91,96,102,108,115,119,127,132,138,139},{0,19,24,25,28,31,36,48,55,61,67,72,76,84,91,96,97,103,120,124,127,132,133,139},{0,19,24,25,31,36,44,48,55,61,67,72,84,91,92,96,97,103,120,127,132,133,139,140},{0,19,24,27,30,36,39,47,60,66,67,72,75,87,95,96,102,108,115,123,132,135,138,143},{0,19,24,30,31,36,39,43,60,66,67,72,79,87,91,96,102,108,115,127,132,135,138,139},{0,19,24,30,36,39,43,47,60,66,67,72,87,91,95,96,102,108,115,132,135,138,139,143},{0,20,21,24,27,28,33,48,57,63,68,69,72,76,93,96,99,105,116,120,124,129,135,141},{0,20,21,27,28,33,40,48,57,63,68,69,76,88,93,96,99,105,116,124,129,135,136,141},{0,20,21,27,33,40,44,48,57,63,68,69,88,92,93,96,99,105,116,129,135,136,140,141},{0,20,23,24,28,29,35,48,59,65,68,71,72,76,95,96,101,107,116,120,124,131,137,143},{0,20,23,28,29,35,40,48,59,65,68,71,76,88,95,96,101,107,116,124,131,136,137,143},{0,20,23,29,35,40,44,48,59,65,68,71,88,92,95,96,101,107,116,131,136,137,140,143},{0,21,24,25,30,33,36,45,60,66,69,72,73,81,93,96,102,108,117,121,129,132,138,141},{0,21,24,27,28,33,36,48,57,63,69,72,76,84,93,96,99,105,120,124,129,132,135,141},{0,21,24,27,33,36,44,48,57,63,69,72,84,92,93,96,99,105,120,129,132,135,140,141},{0,21,24,29,30,33,36,41,60,66,69,72,77,81,89,96,102,108,117,125,129,132,137,138},{0,21,24,30,33,36,41,45,60,66,69,72,81,89,93,96,102,108,117,129,132,137,138,141},{0,21,27,28,33,36,40,48,57,63,69,76,84,88,93,96,99,105,124,129,132,135,136,141},{0,23,24,27,30,35,36,47,60,66,71,72,75,83,95,96,102,108,119,123,131,132,138,143},{0,23,24,28,29,35,36,48,59,65,71,72,76,84,95,96,101,107,120,124,131,132,137,143},{0,23,24,29,35,36,44,48,59,65,71,72,84,92,95,96,101,107,120,131,132,137,140,143},{0,23,24,30,31,35,36,43,60,66,71,72,79,83,91,96,102,108,119,127,131,132,138,139},{0,23,24,30,35,36,43,47,60,66,71,72,83,91,95,96,102,108,119,131,132,138,139,143},{0,23,28,29,35,36,40,48,59,65,71,76,84,88,95,96,101,107,124,131,132,136,137,143},{0,24,25,29,30,33,36,37,60,66,72,73,77,81,85,96,102,108,121,125,129,132,133,138},{0,24,25,30,33,36,37,45,60,66,72,73,81,85,93,96,102,108,121,129,132,133,138,141},{0,24,27,30,31,35,36,39,60,66,72,75,79,83,87,96,102,108,123,127,131,132,135,138},{0,24,27,30,35,36,39,47,60,66,72,75,83,87,95,96,102,108,123,131,132,135,138,143},{0,24,29,30,33,36,37,41,60,66,72,77,81,85,89,96,102,108,125,129,132,133,137,138},{0,24,30,31,35,36,39,43,60,66,72,79,83,87,91,96,102,108,127,131,132,135,138,139},{0,24,30,33,36,37,41,45,60,66,72,81,85,89,93,96,102,108,129,132,133,137,138,141},{0,24,30,35,36,39,43,47,60,66,72,83,87,91,95,96,102,108,131,132,135,138,139,143}};


Clear[H];

Length[T2]

n=144;
H=Array[0&,{Length[T2],n}];
MF=Array[0&,100];
MT=Array[0&,100];

For[j=1, j≤Length[T2], 
For[k=1, k≤n,
If[MemberQ[T2[[j]],Mod[k,n]],H[[j,k]]=1];
k++];
j++];

MF[[1]]=H[[1]];
MT[[1]]=T2[[1]];

cont=1;
v=1;
For[j=2, j≤Length[T2], cont=1;
For[c=1,c≤v,
For[k=1, k≤n,
If[(Not[Chop[Fourier[MF[[c]]]][[k]]==Chop[Fourier[H[[j]]]][[k]]])∧(Chop[Fourier[MF[[c]]]][[k]]==0∨Chop[Fourier[H[[j]]]][[k]]==0), 
k=n+1;cont=cont+1];
k++];
If[cont≤c, c=v+1];
c++];
If[cont==v+1, MF[[v+1]]=H[[j]];MT[[v+1]]=T2[[j]]; v=v+1];
j++]; 


MT=Drop[MT⋃{},1];
MF=Drop[MF⋃{},1];
Length[MF]



MT

(*{{3,8,16},{2,4,9}};*)

(* Next, we see what those Fourier-zero sets are. *)

n=144;
J=MF;
F1=Array[1&,{Length[J],n}];

For[i=1,i<=Length[J],
For[j=1,j≤n,
If[Chop[Fourier[J[[i]]]][[j]]==0, F1[[i,j]]=0];
j++];
i++];

F1;


n=144;
FF1=Array[0&,{Length[F1],n}];

For[i=1,i≤Length[F1],
For[j=1,j≤n,
If[F1[[i,j]]==0, FF1[[i,j]]=j];
j++];
i++];

For[j=1,j≤Length[FF1],
FF1[[j]]=Drop[FF1[[j]]⋃{},1];
j++];
FF1;


FF=FF1-1;

For[m=1,m≤Length[FF1],
For[j=1,j≤Length[FF1[[m]]],
FF[[m,j]]=GCD[FF[[m,j]],n];
j++];
m++];
FF;
For[j=1,j≤Length[FF],
FF[[j]]=FF[[j]]⋃{};
j++];
FF

FT=n/FF
CFT=Array[0&,Length[FT]];
For[j=1,j≤Length[FT],
CFT[[j]]=Complement[Divisors[n],FT[[j]]];
j++];
CFT







Dynamic[{j,v,vvv,vvvv}]

T2={{0,32,58,90,112,122},{0,46,64,110,126,128},{0,54,64,80,118,134},{0,58,74,90,112,128},{0,62,80,94,112,126},{0,94,110,112,126,128}};


Clear[H];

Length[T2]

n=144;
H=Array[0&,{Length[T2],n}];
MF=Array[0&,100];
MT=Array[0&,100];

For[j=1, j≤Length[T2], 
For[k=1, k≤n,
If[MemberQ[T2[[j]],Mod[k,n]],H[[j,k]]=1];
k++];
j++];

MF[[1]]=H[[1]];
MT[[1]]=T2[[1]];

cont=1;
v=1;
For[j=2, j≤Length[T2], cont=1;
For[c=1,c≤v,
For[k=1, k≤n,
If[(Not[Chop[Fourier[MF[[c]]]][[k]]==Chop[Fourier[H[[j]]]][[k]]])∧(Chop[Fourier[MF[[c]]]][[k]]==0∨Chop[Fourier[H[[j]]]][[k]]==0), 
k=n+1;cont=cont+1];
k++];
If[cont≤c, c=v+1];
c++];
If[cont==v+1, MF[[v+1]]=H[[j]];MT[[v+1]]=T2[[j]]; v=v+1];
j++]; 


MT=Drop[MT⋃{},1];
MF=Drop[MF⋃{},1];
Length[MF]



MT

(*{{3,8,16},{2,4,9}};*)

(* Next, we see what those Fourier-zero sets are. *)

n=144;
J=MF;
F1=Array[1&,{Length[J],n}];

For[i=1,i<=Length[J],
For[j=1,j≤n,
If[Chop[Fourier[J[[i]]]][[j]]==0, F1[[i,j]]=0];
j++];
i++];

F1;


n=144;
FF1=Array[0&,{Length[F1],n}];

For[i=1,i≤Length[F1],
For[j=1,j≤n,
If[F1[[i,j]]==0, FF1[[i,j]]=j];
j++];
i++];

For[j=1,j≤Length[FF1],
FF1[[j]]=Drop[FF1[[j]]⋃{},1];
j++];
FF1;


FF=FF1-1;

For[m=1,m≤Length[FF1],
For[j=1,j≤Length[FF1[[m]]],
FF[[m,j]]=GCD[FF[[m,j]],n];
j++];
m++];
FF;
For[j=1,j≤Length[FF],
FF[[j]]=FF[[j]]⋃{};
j++];
FF

FT=n/FF
CFT=Array[0&,Length[FT]];
For[j=1,j≤Length[FT],
CFT[[j]]=Complement[Divisors[n],FT[[j]]];
j++];
CFT