function F = root_MBZL44_S04(x,epsilon,thetah,betaa,Pi_ss,deltah,h,sigmaa,phii,A_ss,alphaa,etaa,Pistar_ss,thetaf,deltaf,E_q_ss,Rstar_ss,R_ss,Astar_ss,thetastar,deltahstar)
% x(1)=Prhnew_ss
% x(2)=Prhind_ss
% x(3)=Y_ss
% x(4)=ZN_ss
% x(5)=Z_ss
% x(6)=N_ss
% x(7)=RealWage_ss
% x(8)=RMC_ss
% x(9)=Pih_ss
% x(10)=Pif_ss
% x(11)=C_ss
% x(12)=Ch_ss
% x(13)=Cf_ss
% x(14)=Chstar_ss
% x(15)=Cstar_ss
% x(16)=Q_ss
% x(17)=S_ss
% x(18)=Prh_ss
% x(19)=Prf_ss
% x(20)=Prfnew_ss
% x(21)=Prfind_ss
% x(22)=Psi_ss

% x(23)=DE_ss
% x(24)=Prstarnew_ss
% x(25)=Prstarind_ss
% x(26)=RMCstar_ss
% x(27)=RealWagestar_ss
% x(28)=Nstar_ss
% x(29)=Ystar_ss
% x(30)=Zstar_ss
% x(31)=ZNstar_ss


F(1) = x(1) - ( epsilon/(epsilon-1)*(1-thetah*betaa*Pi_ss^(-1)*x(9)^(deltah+epsilon*(1-deltah)))/(1-thetah*betaa*Pi_ss^(-1)*x(9)^(1+epsilon*(1-deltah)))* x(8) );
F(2) = x(2) - ( x(9)^(-1+deltah)*((1-thetah)*x(1)^(1-epsilon)+thetah*x(2)^(1-epsilon))^(1/(1-epsilon)) ); 
F(3) = 1 - ((1 - thetah)*x(1)^(1-epsilon) + thetah* x(2)^(1-epsilon));
F(4) = x(8) - ( x(7)/A_ss*(1-alphaa+alphaa*x(17)^(1-etaa))^(1/(1-etaa)) );
F(5) = x(7) - ( ((1-h)*x(11))^(sigmaa)*x(6)^phii ); 
F(6) = x(6) - ( x(3)/A_ss*x(5) );
F(7) = x(5) - (1/x(3)*(x(12)+x(14)*(x(17)*x(22))^epsilon)*(thetah*x(4)+(1-thetah)*x(1)^(-epsilon)) );
F(8) = x(4) - (1/(1-x(9)^(epsilon*(1-deltah))*thetah)*x(9)^(epsilon*(1-deltah))*(1-thetah)*x(1)^(-epsilon) );
F(9) = x(3) - ( x(12) + x(14) );
F(10) = x(12) - ( (1-alphaa)*x(18)^(-etaa)*x(11) );
F(11) = x(13) - ( alphaa*x(19)^(-etaa)*x(11) );
F(12) = x(14) - ( alphaa*x(16)^etaa*((1-alphaa)+alphaa*x(17)^(1-etaa))^(etaa/(1-etaa))*x(15) );
F(13) = x(15) - ( x(29) );
F(14) = 1 - ( (1 - alphaa)*x(18)^(1-etaa) + alphaa *x(19)^(1-etaa) ); 
F(15) = x(9) - ( Pi_ss );
F(16) = x(11) - ( x(29)*x(16)^(1/sigmaa) );
F(17) = x(16) - ( x(22)*x(17)*((1-alphaa)+alphaa*x(17)^(1-etaa))^(-1/(1-etaa)) );
F(18) = x(17) - ( x(19)/x(18) );
F(19) = x(10) - ( Pi_ss );
% F(20) = x(10) - ( x(20)*Pistar_ss ); //Agora tem LOP Gap
F(20) = x(20) - ( epsilon/(epsilon-1)*(1-thetaf * betaa * Pi_ss^(-1)* x(10)^(deltaf+epsilon*(1-deltaf)))/(1-thetaf * betaa * Pi_ss^(-1)* x(10)^(1+epsilon*(1-deltaf)))*x(22) );
F(21) = x(21) - ( x(10)^(-1+deltaf)*((1-thetaf)*x(20)^(1-epsilon)+thetaf*x(21)^(1-epsilon))^(1/(1-epsilon)) ); 
F(22) = 1 - ( (1 - thetaf)*x(20)^(1-epsilon) + thetaf*x(21)^(1-epsilon) );
F(23) = x(22) - ( x(16)*x(17)^(-1)*((1-alphaa)+alphaa*x(17)^(1-etaa))^(1/(1-etaa)) );

F(24) = x(10) - (x(23)*Pistar_ss);
F(25) = x(23) - (R_ss*E_q_ss/Rstar_ss);
F(26) = x(24) - (epsilon/(epsilon-1)*(1-thetastar*betaa*Pistar_ss^((deltahstar-1)*(1-epsilon)))/(1-thetastar*betaa*Pistar_ss^(epsilon*(1-deltahstar)))*x(26) );
F(27) = x(25) - ( Pistar_ss^(deltahstar-1)*((1-thetastar)*x(24)^(1-epsilon)+thetastar*x(25)^(1-epsilon))^(1/(1-epsilon)) ); 
F(28) = 1 - ( (1 - thetastar)*x(24)^(1-epsilon) + thetastar* x(25)^(1-epsilon) );
F(29) = x(26) - ( x(27)/Astar_ss );
F(30) = x(27) - ( ((1-h)*x(15))^(sigmaa)*x(28)^phii );
F(31) = x(28) - ( x(29)/Astar_ss*x(30) );
F(32) = x(30) - ( thetastar*x(31) + (1-thetastar)*x(24)^(-epsilon) );
F(33) = x(31) - ( 1/(1-Pistar_ss^(epsilon*(deltahstar-1))*thetastar)*Pistar_ss^(epsilon*(deltahstar-1))*(1-thetastar)*x(24)^(-epsilon) );

end


