#include<iostream>
using namespace std;
int main(){
int n;
int a,b,c,d,e;
int total1,total2;
cin>>n;
for(int i=1;i<n+1;i++){
cin>>a,b,c,d,e;
int M;
total1=a*60+b;
total2=c*60+d;
M=total2-total1;
if(M>e&&M==e){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
return 0;
}