#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    double h1,m1,s1,h2,m2,s2;
    cin>>h1>>m1>>s1>>h2>>m2>>s2;
    double q1,q2;
    q1=h1*60*60+m1*60+s1;
    q2=h2*60*60+m2*60+s2;
    if(q1>q2)q2+=12*60*60;
    double x=(double)360/12/60/60*60,y=(double)6/60*60;
    double a,b;
    a=x*q1;
    b=y*(m1*60+s1);
   //cout<<a<<" "<<b<<endl;
    int br=0;
    double n,m;
    cin>>n>>m;
    double k=n*60+m;
    while(q1<=q2)
    {
        if(fabs(a-b)<k||fabs(360-a-b)<k||fabs(a-360+b)<k)br++;
        a+=x;
        if(a>=360)a-=360*60;
        b+=y;
        if(b>=360)b-=360*60;
        s1++;
        if(s1==60){s1=0;m1++;}
        if(m1==60){m1=0;h1++;}
        if(h1==12){h1=0;}
        q1++;
    }
    cout<<br/60<<" "<<br%60<<endl;
    return 0;
}
/*

6 15 20
6 27 21
30 0



11 0 0
1 0 0
6 0
*/
