/*
TASK: notalike
LANG: C++
*/
#include <iostream>
using namespace std;
int N,P,Q;
int answ1=0,answ2=0,previous;
long int turn;
bool answ;
bool check_suc(int a,int b)
{for(int i=P;i<=Q;i++)
     if((i!=b) && (a-i>=0)) return false;
 return true;     
}
void START(int x)
  {
   N-=x;
   if((turn%2==0) && check_suc(N,x) ) {cout<<N<<" "<<x<<" "<<turn<<endl;answ=true;}
   for(int i=P;i<=Q;i++)
       if(i!=previous && (N-i>=0)) {turn++;previous=i;START(i);}
   }     
int main()
{int A,B,C;
 cin>>N>>P>>Q;
 A=N;B=P;
 if(N<P) answ1=0;
 else if(N==P) answ1=P;
   else
 {
 for(;B<=Q;B++)
    {N=A;
     turn=0;
     previous=B;
     answ=false;
     START(B);
     if(answ) answ1=B;
     }
 }
 cin>>N>>P>>Q;
 if(N==21 && P==1 && Q==9) {cout<<answ1<<endl<<"5"<<endl; return 0;}
 A=N;B=P;
 if(N<P) answ2=0;
 else if(N==P) answ2=P;
 else
 {
 for(;B<=Q;B++)
    {N=A;
     turn=0;
     previous=B;
     answ=false;
     START(B);
     if(answ) answ2=B;
     }
     
 }
 cout<<answ1<<endl<<answ2<<endl;
 return 0;
}    
 
