#include<iostream>
using namespace std;
int main(void)
{
int H1,M1,H2,M2,M3,total1,total2,N,T;
cin>>N;
for(int i=1;i<=N;i++)
{
cin>>H1>>M1>>H2>>M2>>M3;
total1=60*H1+M1;
total2=60*H2+M2;
if(total2-total1>=M3)
cout<<"Yes\n";
else if(total2-total1<M3)
cout<<"No\n";
}
return 0;
}