function [V1,W1]=circuits(Bperp,M) 
V=[];
W=[];
%% We look for the circuits of Bperp:
for j1=1:8
  for j2=j1+1:9
    for j3=j2+1:10
      J=[j1,j2,j3];
      if rank(Bperp(:,J))==3
        v=[];
        for l=1:10  
          v=[v,(-1)^(sum(J<l))*det(Bperp(:,sort([J,l])))];
        endfor
        V=[V;v];%we keep the circiuts of Bperp in each row of V 
      endif
    endfor %j3
  endfor %j2
endfor %j1
%
%we make the first nonzero coordinate of each circuit positive:
for i=1:size(V,1)
  ww=find(V(i,:));
  if length(ww)!=0
    if V(i,ww(1))<0
      V(i,:)=-V(i,:);
    endif
  endif
endfor
%we keep in V1 different circuits of Bperp with first nonzero coordinate positive:
V1=V(1,:);
for i=2:size(V,1)
  l=size(V1,1);
  m1=[];
  for k=1:l
    m1(k)=prod(V(i,:)==V1(k,:));
  endfor
  if sum(m1)==0
    V1=[V1;V(i,:)];
  endif
endfor
%
%We now look for circuits of M:
for j1=1:6
  for j2=j1+1:7
    for j3=j2+1:8
      for j4=j3+1:9
        for j5=j4+1:10
          J=[j1,j2,j3,j4,j5];
          if rank(M(:,J))==5
            w=[];
            for l=1:10
              w=[w,(-1)^(sum(J<l))*det(M(:,sort([J,l])))];
            endfor %l
            W=[W;w];;%we keep the circiuts of Bperp in each row of W
          endif
        endfor %j5
      endfor %j4
    endfor %j3
  endfor %j2
endfor %j1
%we make the first nonzero coordinate of each circuit positive:
for i=1:size(W,1)
  ww=find(W(i,:));
  if length(ww)!=0
    if W(i,ww(1))<0
      W(i,:)=-W(i,:);
    endif
  endif
endfor
%we keep in W1 different circuits of M with first nonzero coordinate positive:
W1=W(1,:);
for i=2:size(W,1)
  l=size(W1,1);
  m1=[];
  for k=1:l
    m1(k)=prod(W(i,:)==W1(k,:));
  endfor
  if sum(m1)==0
    W1=[W1;W(i,:)];
  endif
endfor
%