#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a%400==0)||((a%4==0)&&(a%100!=0))) 
{
    cout<<"1"<<endl;
}    
else
{
    cout<<"0"<<endl;
}    
    if((b%400==0)||((b%4==0)&&(b%100!=0))) 
{
    cout<<"1"<<endl;
}
else
{
    cout<<"0"<<endl;
}
    if((c%400==0)||((c%4==0)&&(c%100!=0))) 
{
    cout<<"1"<<endl;
} 
   else 
{
    cout<<"0"<<endl;
} 
   if((d%400==0)||((d%4==0)&&(d%100!=0))) 
{
    cout<<"1";
}
else 
{
    cout<<"0";
}
    return 0;
    
}