# Problem Description
The problem requires us to determine the minimum number of steps needed to convert one string (`str1`) to another string (`str2`) by repeatedly moving the last two characters of the string to the front. If the conversion is not possible, the function should return -1.

# Visual Facts
1. **Example 1**:
   - Initial string: "Abacbv"
   - Step 1: "bvAbac"
   - Step 2: "acbvAb"
   - Step 3: "Abacbv" (back to the original string)
   
2. **Example 2**:
   - Initial string: "openai"
   - Step 1: "aiopen"
   - Step 2: "enaaiop"
   - Step 3: "openai" (back to the original string)
   
3. **Example 3**:
   - Initial string: "ababa"
   - Step 1: "baaba"
   - Step 2: "babaa"
   - Step 3: "aabab"

# Visual Patterns
1. **Transformation Rule**: Each step involves moving the last two characters of the string to the front.
2. **Cycle Detection**: After a certain number of steps, the string returns to its original form. This indicates a cyclic pattern.
3. **Step Count**: The number of steps required to return to the original string is equal to the length of the string divided by the greatest common divisor (GCD) of the length of the string and 2 (since we are moving two characters each time).
4. **String Length**: The length of the string remains constant throughout the transformation process.
5. **Reversibility**: If `str2` can be obtained from `str1` by the described transformation, then `str1` can be transformed back to `str2` by the same number of steps.

# Solution
def solution(str1: str, str2: str) -> int:
    """
    Returns the minimum number of steps needed to convert the first string to the second string.
    Returns -1 if the conversion is not possible.

    Parameters:
        str1 (str): The source string to convert from
        str2 (str): The target string to convert to

    Returns:
        int: Minimum number of steps required for the conversion, or -1 if not possible
    """
    if len(str1) != len(str2):
        return -1
    for i in range(len(str1)):
        str1 = str1[-2:] + str1[:-2]
        if str1 == str2:
            return i + 1
    return -1


# Test Script
def test():
    test_cases = [
        ("openai", "enaiop", 2),
        ("openai", "aiopen", 1),
        ("ababa", "babaa", 2),
        ("ababa", "abaab", 4),
        ("ababa", "aabab", 3),
        ("Trump","Susan", -1),
        ("Trump","trump", -1),
        ("Trump","pTrum", 3),
        ("abacbv","acbvab", 2),
        ("abacbv", "bvabac", 1)
    ]

    for str1, str2, expected_output in test_cases:
        try:
            output = solution(str1, str2)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`str1`: {str1}\n"
                f"`str2`: {str2}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

        if output != expected_output:
            error_message = (
                f"The following Test Case failed:\n"
                f"`str1`: {str1}\n"
                f"`str2`: {str2}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {expected_output}"
            )
            assert False, error_message

test()