#include <iostream>
using namespace std;
int main(){
int n, h1, m1, h2, m2, mn, hp;
cin >> n;
while(n--){
cin >> h1 >> m1 >> h2 >> m2 >> mn;
hp = 0;
m1 += mn;
while(m1 >= 60){
m1 -= 60;
hp ++;
}
h1 += hp;
if(h1 < h2) cout << "Yes";
else if(h1 == h2 && m1 <= m2) cout << "Yes";
else cout << "No";
cout << endl;
}
return 0;
}