12871287 SUSTech Online Judge
Problem 1287 --The Sword of Damocles

1287: The Sword of Damocles

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 923  Solved: 184
[Submit][Status][Web Board]


One day, an elder told Pisces that there was a legendary sword at the end of the sky - the sword of Damocles. Pisces decided to get the sword at any cost. The area between Pisces and the sword can be described as a rectangular field of \(n*m\) square meters, with Pisces currently at the top left corner and the sword at the bottom right corner. However, \(k\) monsters are living in this area, and to keep himself safe, Pisces must keep a distance longer than \(S_i\) from the \(i\)-th monster (Euclidean Distance). Given the locations of these \(k\) monsters, Pisces wants to find whether he can get the legendary sword.


The first line of input contains an integer \(T\) \((1\leq T \leq 10)\), which denotes the number of test cases.

For each of the test case, the first line contains three integers, \(N\), \(M\), and \(K\) \((10 ≤ N, M ≤ 10^4 , 1 ≤ K ≤ 1000)\). Pisces is now at position \((0, 0)\), and the sword at position \((N, M)\). Each of the next \(K\) lines describes one of the \(K\) monsters, it contains three integers, \(X, Y,\) and \(S\), where \((X, Y)\) represents the location and \(S\) represents the distance that must be kept. \((0\leq X\leq N, 0\leq Y\leq M, 0 < S ≤ 10^4 )\).


For each test case, print “Yes” if Pisces can get the sword, and “No” otherwise.

Sample Input

10 10 2
3 7 4
5 4 4

Sample Output