function [out] = queries_n4t2(f)

n = 4;

E0 = eimat(n,0);
E1 = eimat(n,1);
E2 = eimat(n,2);
E3 = eimat(n,3);
E4 = eimat(n,4);

cvx_begin quiet

  cvx_precision best;

  % variables m_ij : 0 <= i <= n, 0 <= j <= t-1
  
  variable m00(2^n,2^n) symmetric;
  variable m10(2^n,2^n) symmetric;
  variable m20(2^n,2^n) symmetric;
  variable m30(2^n,2^n) symmetric;
  variable m40(2^n,2^n) symmetric;
  
  variable m01(2^n,2^n) symmetric;
  variable m11(2^n,2^n) symmetric;
  variable m21(2^n,2^n) symmetric;
  variable m31(2^n,2^n) symmetric;
  variable m41(2^n,2^n) symmetric;
  
  variable g0(2^n,2^n) symmetric;
  variable g1(2^n,2^n) symmetric;
  
  variable epss;
  
  minimise( epss );
  
  subject to
  
    % Input condition.
  
    m00 + m10 + m20 + m30 + m40 == ones(2^n,2^n);
    
    % Running conditions (between 1 and t-1).
    
    m01 + m11 + m21 + m31 + m41 == E0 .* m00 + E1 .* m10 + E2 .* m20 + E3 .* m30 + E4 .* m40;
    
    % Output matches last but one query.
    
    g0 + g1 == E0 .* m01 + E1 .* m11 + E2 .* m21 + E3 .* m31 + E4 .* m41;
    
    % Output constraints.
    
    diag(g0) >= (1-epss)*(1-f);
    diag(g1) >= (1-epss)*f;
    
    m01(1,4)==0;m01(1,6)==0;m01(1,7)==0;m01(1,10)==0;m01(1,11)==0;
    m01(2,4)==0;m01(2,6)==0;m01(2,7)==0;m01(2,10)==0;m01(2,11)==0;
    m01(3,4)==0;m01(3,6)==0;m01(3,7)==0;m01(3,10)==0;m01(3,11)==0;
    m01(4,4)==0;m01(4,6)==0;m01(4,7)==0;m01(4,10)==0;m01(4,11)==0;
    m01(5,4)==0;m01(5,6)==0;m01(5,7)==0;m01(5,10)==0;m01(5,11)==0;
    m01(6,4)==0;m01(6,6)==0;m01(6,7)==0;m01(6,10)==0;m01(6,11)==0;
    m01(7,4)==0;m01(7,6)==0;m01(7,7)==0;m01(7,10)==0;m01(7,11)==0;
    m01(8,4)==0;m01(8,6)==0;m01(8,7)==0;m01(8,10)==0;m01(8,11)==0;
    m01(9,4)==0;m01(9,6)==0;m01(9,7)==0;m01(9,10)==0;m01(9,11)==0;
    
    m11(1,4)==0;m11(1,6)==0;m11(1,10)==0;
    m21(1,4)==0;m21(1,6)==0;m21(1,10)==0;
    m21(1,2)==m21(1,3);
    m21(1,2)==m21(1,5);
    
    m01(2,2)==m01(2,3);m01(2,2)==m01(2,5);m01(2,2)==m01(2,9);
    
    % Semidefinite constraints.

    m00 == semidefinite(2^n);
    m10 == semidefinite(2^n);
    m20 == semidefinite(2^n);
    m30 == semidefinite(2^n);
    m40 == semidefinite(2^n);
    
    m01 == semidefinite(2^n);
    m11 == semidefinite(2^n);
    m21 == semidefinite(2^n);
    m31 == semidefinite(2^n);
    m41 == semidefinite(2^n);
            
    g0 == semidefinite(2^n);
    g1 == semidefinite(2^n);
    
%cvx_problem

cvx_end

dlmwrite('c:/work/sdp/m0.csv',m00+m10+m20+m30+m40,'precision',14)
dlmwrite('c:/work/sdp/m1.csv',m01+m11+m21+m31+m41,'precision',14)
dlmwrite('c:/work/sdp/m2.csv',g0+g1,'precision',14)

dlmwrite('c:/work/sdp/m01.csv',m01,'precision',14)
dlmwrite('c:/work/sdp/m11.csv',m11,'precision',14)
dlmwrite('c:/work/sdp/m21.csv',m21,'precision',14)
dlmwrite('c:/work/sdp/m31.csv',m31,'precision',14)
dlmwrite('c:/work/sdp/m41.csv',m41,'precision',14)

out = epss;