Balance strings, by definition, are the strings that contain all the characters of the alphabet, from a to z, equal no of times.
eg- abcdefghijklmnopqrstuvwxyz is a balanced string, aabb is not.
Input:
First line contains number of test cases T. Each test case contains a string S which made up of only lowercase characters.
Output:
For each test case print Yes if the string is balanced string else print No.
We are asked: "Balance strings, by definition, are the strings that contain all the characters of the alphabet, from a to z, equal no of times." So a string is balanced if it contains all 26 letters each exactly the same number of times. That implies length must be a multiple of 26, and count of each letter is exactly length/26. The example "abcdefghijklmnopqrstuvwxyz" is balanced (each appears once). Also note they said "equal no of times", not necessarily once; could be multiple times each, but they must all be equal and include all 26 letters. So condition: for each letter a-z, count must be equal and >0. In other words, check if the set of letters present is exactly 26 and all counts are equal.
We need to process T test cases, each string S of lowercase only, length up to 1000. Output Yes/No.
Implementation: For each string, compute frequency array of size 26. Check if all frequencies are the same and >0. That is, let count = freq[0]; then ensure count > 0 and for all i, freq[i] == count.
Alternatively, if any freq is 0 or different, No.
Edge Cases: length 0? Not given; length >=1, but for length <26, certainly not balanced because some letters missing. Also length not multiple of 26 -> automatically fails.
So algorithm straightforward.
But wait: The problem statement: "Balance strings, by definition, are the strings that contain all the characters of the alphabet, from a to z, equal no of times." That can be interpreted as: The string contains each letter from a to z and each appears the same number of times. Yes.
Thus sample: codemyca -> length 8, not all letters present, so No.
So implement: Read T, for each, read S, count frequencies, check if all equal >0, print Yes/No.
But there might be nuance: Could it be that the string only needs to have all characters that appear be equal times? The definition says: "contain all the characters of the alphabet, from a to z, equal no of times." So it's explicit: must contain all a-z. So we require all 26.
Thus done.
But I recall a similar problem might consider "balanced strings" as those where the frequency of each character is the same, not necessarily all 26, but the problem's definition here is explicit. So follow definition.
Thus final answer: For each test case, compute histogram; check.
Complexities: O(|S|) per case.
Now, the output: "Yes" and "No" exactly, with capital Y and N? Sample output shows "No" and "Yes". So output exactly.
So let's provide solution.
But the user asked: "Balance strings, by definition, are the strings that contain all the characters of the alphabet, from a to z, equal no of times." This is the problem statement. We need to write code to solve.
I'll respond with explanation and code.
Since the environment isn't specified, but typical competitive programming, we can write in Python.
I'll produce solution:
def is_balanced(s):
if len(s) % 26 != 0: return False
freq = [0]*26
for ch in s:
freq[ord(ch)-97] += 1
target = freq[0]
if target == 0: return False
for cnt in freq:
if cnt != target:
return False
return True
Then process T.
Edge: string may contain uppercase? No, only lowercase.
So fine.
Now, sometimes we need to consider that target may be zero if first character is missing? But we already check all counts; if any count is zero, then not all letters present. So we could also check min count >0. But our loop will detect mismatch if first is zero and others >0? Actually if first count is zero, then target=0, but we need all counts >0; so we can also check if min(freq) >0. Simpler: after building freq, check if all(cnt == len(s)//26 for cnt in freq). Because if all equal and len(s) divisible by 26, that ensures each count >0 if len(s)>0. Actually if len(s)=0, but constraints len>=1, so len(s)//26 would be >0 only if len>=26; if len<26 then len(s)//26 = 0, and all counts zero? But if len<26, the string cannot have all 26 letters, so some freq>0, some zero, thus not all equal to zero. But our condition of all equal to len(s)//26 (which would be 0) would be satisfied only if all counts zero, which can't happen because string length >0, so at least one count >0. So it's safe. Actually if len<26, len(s)//26 = 0, but counts are not all zero, so fails. So we can simply compute target = len(s)//26, check all freq[i]==target. But careful: This only works if we also ensure target >0? Actually if target=0, then all counts must be zero for equality, which is impossible for non-empty string. So it will return false. So it's safe. And it's simpler: if len(s) % 26 != 0: return False else: target = len(s)//26; then check all frequencies == target.
Implementation: after counting, for cnt in freq: if cnt != target: return False; return True.
That handles everything.
Thus solution.
Now produce final answer with code and explanation.
I'll respond. ```python
import sys
def is_balanced(s: str) -> bool:
n = len(s)
# Length must be a multiple of 26
if n % 26 != 0:
return False
code
target = n // 26
freq = [0] * 26
for ch in s:
freq[ord(ch) - ord('a')] += 1
# Every character must appear exactly 'target' times
for cnt in freq:
if cnt != target:
return False
return True
def solve() -> None:
data = sys.stdin.read().strip().split()
if not data:
return
t = int(data[0])
out = []
idx = 1
for _ in range(t):
s = data[idx]
idx += 1
out.append("Yes" if is_balanced(s) else "No")
sys.stdout.write("\n".join(out))