People of the future live in a 26 dimensional space. Chef's great great grand child has found a way to send messages back in time to him to tell the coordinates of a place where chef can find treasure. His evil twin brother has also found a way to send messages back in time and he too sends the coordinates of a place to chef. But this place, instead of containing a treasure actually contains a witch who kills whoever she meets. Chef sees that he has recieved two messages and becomes suspicious. He decides to find the manhattan distance between these two points. If this value is greater than a certain value D then he decides not to visit any of the two places since there is a high chance that there might be danger in one of the places. If it is less than or equal to D then he decides to visit the midpoint of the two coordinates in the hope that he can actually see which place contains the treasure from there.
The messages are encoded as a string and sent by the brothers as string S1 and S2 respectively. You can convert the string into the 26 dimensional coordinate by doing the following. The first coordinate is the number of times the character 'a' occurs, the second coordinate is the number of times the character 'b' occurs, and so on and the 26th coordinate is the number of times the character 'z' occurs. All the characters of the string will be lowercase alphabets.
You can read about manhattan distance here: https://en.wiktionary.org/wiki/Manhattan_distance
The first line of the input contains an integer T denoting the number of test cases.
The next T lines contains two strings and an integer separated by a space S1 and S2 and D.
For each test case print "YES" (without quotes) if chef decides to visit the midpoint of the two coordinates, else print "NO" (without quotes), in a separate line.
- 1 ≤ T ≤ 102
- 1 ≤ |S1| ≤ 102
- 1 ≤ |S2| ≤ 102
- 1 ≤ D ≤ 102
Input: 2 ab ab 2 ab cd 1 Output: YES NO
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions