# Python solution to "Fake Writing" from 2025 CS@UCF Summer camp
test_count = int(input())

def greatestCommonDivisor(big, small):
    if(small == 0):
        return big
    else:
        return greatestCommonDivisor(small, big % small)


vowels = {'a', 'e', 'i', 'o', 'u'}
for _ in range(test_count):
    above = input()
    below = input()

    target_vowels = 0
    for letter in below:
        if letter in vowels:
            target_vowels += 1

    target_size = len(below)
    factor = greatestCommonDivisor(target_size, target_vowels)
    target_vowels /= factor
    target_size /= factor

    total_score = 0
    match_count = 0
    counts = {0: 1}
    for (index,letter) in enumerate(above):
        if letter in vowels:
            total_score += (target_size - target_vowels)
        else:
            total_score -= target_vowels

        if(total_score in counts):
            match_count += counts[total_score]
            counts[total_score] += 1
        else:
            counts[total_score] = 1

    print(match_count)
