• + 0 comments

    for Python3 Platform

    from itertools import combinations_with_replacement
    
    def stones(n, a, b):
        ans = set()
        diff_perm = combinations_with_replacement((a, b), n-1)
        
        for i in diff_perm:
            ans.add(sum(i))
        
            
        return sorted(ans)
    
    T = int(input())
    while (T > 0):
        n = int(input())
        a = int(input())
        b = int(input())
        
        result = stones(n, a, b)
        
        print(*result)
        
        T -= 1