for(int i=1;i<=1e9;i++){ for(int j=1;j<=1e9;j++){ if(i*2+j*4==n&&i+j==m){ cout<<i<<' '<<j<<end; } } }