#include <iostream>
using namespace std;
int main ( ) {
int n, h1, m1, h2, m2, m3;
while ( cin >> n ) {
for ( int i = 0; i < n; i++ ) {
cin >> h1 >> m1 >> h2 >> m2 >> m3;
m1 += ( m3 % 60 );
h1 += m3 / 60 + m1 / 60;
m1 %= 60;
cout << ( ( h1 < h2 || ( h1 == h2 && m1 <= m2 ) ) ? "Yes" : "No" ) << endl;
}
}
}