t = int(input())

for i in range(t):
    n , x, y = map(int, input().split())
    term = 0
    finalmax = 10000000000
    mx = 0
    for j in range(n-1,0,-1):
        gan = j
        if (y - x) % gan == 0:
            if y - (y-x) // gan * (n - 1) < 0 :
                mx = y + (abs(y - (y-x) // gan * (n - 1)) // ((y-x) // gan) + 1) * ((y-x) // gan)
            else:
                mx = y
            if finalmax > mx:
                finalmax = mx
                term = (y-x) // gan
    if n != 2:
        line = []
        for j in range(n):
            if j != n-1:
                print(finalmax - j*term, end = ' ')
            else : print(finalmax - j*term)
    else:
        print(x, y)


t = int(input())

for i in range(t):
    n , x, y = map(int, input().split())
    term = 0
    finalmax = 10000000000
    mx = 0
    for j in range(n-1,0,-1):
        gan = j
        if (y - x) % gan == 0:
            if y - (y-x) // gan * (n - 1) <= 0 :
                mx = y + (abs(y - (y-x) // gan * (n - 1)) // ((y-x) // gan) + 1) * ((y-x) // gan)
            else:
                mx = y
            if finalmax > mx:
                finalmax = mx
                term = (y-x) // gan
    if n != 2:
        line = []
        for j in range(n):
            if j != n-1:
                print(finalmax - j*term, end = ' ')
            else : print(finalmax - j*term)
    else:
        print(x, y)


t = int(input())

for i in range(t):
    n , x, y = map(int, input().split())
    term = 0
    finalmax = 10000000000
    mx = 0
    for j in range(n-1,0,-1):
        gan = j
        if (y - x) % gan == 0:
            if y - (y-x) // gan * (n - 1) < 0 :
                mx = y + (abs(y - (y-x) // gan * (n - 1)) // ((y-x) // gan) + 1) * ((y-x) // gan)
            else:
                mx = y
            if finalmax > mx:
                finalmax = mx
                term = (y-x) // gan
    if n != 2:
        line = []
        for j in range(n):
            print(finalmax - j*term, end = ' ')
        print()
    else:
        print(x, y)


import bisect
import collections
import functools
import itertools
import math
import heapq
import random
import string

def repeat(_func=None, *, times=1):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            for _ in range(times):
                func(*args, **kwargs)

        return wrapper

    if _func is None:
        return decorator
    else:
        return decorator(_func)

def unpack(func=int):
    return map(func, input().split())

def l_unpack(func=int):
    """list unpack"""
    return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
    """sorted list unpack"""
    return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):  # multiple line unpack
    """list of n integers passed on n line, one on each"""
    return [int(input()) for _ in range(n)]

def range_n():
    return range(int(input()))

def getint():
    return int(input())

def factor(n):
    d = {}
    while not n % 2:
        d[2] = d.get(2, 0) + 1
        n //= 2
    i = 3
    while i * i <= n:
        while not n % i:
            d[i] = d.get(i, 0) + 1
            n //= i
        i += 2
    if n > 1:
        d[n] = d.get(n, 0) + 1
    return d

def get_sum(a):
    """return sum of difference of all unique pairs"""
    ans = 0
    n = len(a)
    for i in range(n):
        # ans += (a[i] * i) - (n - i - 1) * a[i]
        ans += (i - (n - i - 1)) * a[i]
    return ans

@repeat(times=getint())
def main():
    n, x, y = unpack()
    ans = [0] * n
    p, q = 0, 0
    for i in range(n):
        for j in range(i + 1, n):
            if not (y - x) % (j - i) and j - i >= q - p:
                p, q = i, j

    d = (y - x) // (q - p)
    ans[p] = x
    for i in range(p - 1, -1, -1):
        ans[i] = ans[i + 1] - d
    for i in range(p + 1, n):
        ans[i] = ans[i - 1] + d
    if ans[0] < 0:
        for i in range(n):
            if ans[i] < 0:
                ans.append(ans[-1] + d)
            else:
                ans = ans[i:]
                break

    print(ans)

main()


import bisect
import collections
import functools
import itertools
import math
import heapq
import random
import string

def repeat(_func=None, *, times=1):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            for _ in range(times):
                func(*args, **kwargs)

        return wrapper

    if _func is None:
        return decorator
    else:
        return decorator(_func)

def unpack(func=int):
    return map(func, input().split())

def l_unpack(func=int):
    """list unpack"""
    return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
    """sorted list unpack"""
    return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):  # multiple line unpack
    """list of n integers passed on n line, one on each"""
    return [int(input()) for _ in range(n)]

def range_n():
    return range(int(input()))

def getint():
    return int(input())

def factor(n):
    d = {}
    while not n % 2:
        d[2] = d.get(2, 0) + 1
        n //= 2
    i = 3
    while i * i <= n:
        while not n % i:
            d[i] = d.get(i, 0) + 1
            n //= i
        i += 2
    if n > 1:
        d[n] = d.get(n, 0) + 1
    return d

def get_sum(a):
    """return sum of difference of all unique pairs"""
    ans = 0
    n = len(a)
    for i in range(n):
        # ans += (a[i] * i) - (n - i - 1) * a[i]
        ans += (i - (n - i - 1)) * a[i]
    return ans

@repeat(times=getint())
def main():
    n, x, y = unpack()
    ans = [0] * n
    p, q = 0, 0
    for i in range(n):
        for j in range(i + 1, n):
            if (not (y - x) % (j - i)) and j - i >= q - p:
                p, q = i, j

    d = (y - x) // (q - p)
    ans[p] = x
    for i in range(p - 1, -1, -1):
        ans[i] = ans[i + 1] - d
    for i in range(p + 1, n):
        ans[i] = ans[i - 1] + d
    if ans[0] <= 0:
        for i in range(n):
            if ans[i] <= 0:
                ans.append(ans[-1] + d)
            else:
                ans = ans[i:]
                break

    print(*ans)

main()


import bisect
import collections
import functools
import itertools
import math
import heapq
import random
import string

def repeat(_func=None, *, times=1):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            for _ in range(times):
                func(*args, **kwargs)

        return wrapper

    if _func is None:
        return decorator
    else:
        return decorator(_func)

def unpack(func=int):
    return map(func, input().split())

def l_unpack(func=int):
    """list unpack"""
    return list(map(func, input().split()))

def s_unpack(func=int, rev=False):
    """sorted list unpack"""
    return sorted(map(func, input().split()), reverse=rev)

def ml_unpack(n):  # multiple line unpack
    """list of n integers passed on n line, one on each"""
    return [int(input()) for _ in range(n)]

def range_n():
    return range(int(input()))

def getint():
    return int(input())

def factor(n):
    d = {}
    while not n % 2:
        d[2] = d.get(2, 0) + 1
        n //= 2
    i = 3
    while i * i <= n:
        while not n % i:
            d[i] = d.get(i, 0) + 1
            n //= i
        i += 2
    if n > 1:
        d[n] = d.get(n, 0) + 1
    return d

def get_sum(a):
    """return sum of difference of all unique pairs"""
    ans = 0
    n = len(a)
    for i in range(n):
        # ans += (a[i] * i) - (n - i - 1) * a[i]
        ans += (i - (n - i - 1)) * a[i]
    return ans

@repeat(times=getint())
def main():
    n, x, y = unpack()
    ans = [0] * n
    p, q = 0, 0
    for i in range(n):
        for j in range(i + 1, n):
            if not (y - x) % (j - i) and j - i >= q - p:
                p, q = i, j

    d = (y - x) // (q - p)
    ans[p] = x
    for i in range(p - 1, -1, -1):
        ans[i] = ans[i + 1] - d
    for i in range(p + 1, n):
        ans[i] = ans[i - 1] + d
    if ans[0] < 0:
        for i in range(n):
            if ans[i] < 0:
                ans.append(ans[-1] + d)
            else:
                ans = ans[i:]
                break

    print(*ans)

main()


def get_result():
    n, x, y = list(map(int, input().split()))

    if n==2:
        return [x,y]

    diff = y-x
    min_d = diff
    for i in range(1, diff):
        if diff%i==0 and diff//i<=n and y-(n-1)*i<=x :
            min_d = i
            break
    arr = []

    c = y
    while(n>0 and c>0):
        arr.append(c)
        n -= 1
        c -= min_d

    c = y+min_d
    while(n>0):
        arr.append(c)
        n -= 1
        c += min_d

    return arr

def main():
    t = int(input())
    for i in range(t):
        for j in get_result():
            print(j, end=' ')
        print()

if __name__=='__main__':
    main()


def get_result():
    n, x, y = list(map(int, input().split()))

    if n==2:
        return [x,y]

    diff = y-x
    min_d = diff
    for i in range(1, diff):
        if diff%i==0 and x-i>0 and diff//i<=n-2 and y-(n-1)*i<=x :
            min_d = i
            break
    arr = []

    c = y
    while(n>0 and c>0):
        arr.append(c)
        n -= 1
        c -= min_d

    c = y+min_d
    while(n>0):
        arr.append(c)
        n -= 1
        c += min_d

    return sorted(arr)

def main():
    t = int(input())
    for i in range(t):
        for j in get_result():
            print(j, end=' ')
        print()

if __name__=='__main__':
    main()


def get_result():
    n, x, y = list(map(int, input().split()))

    if n==2:
        return [x,y]

    diff = y-x
    min_d = diff
    for i in range(1, diff):
        if diff%i==0 and x-i>0 and diff//i<=n+1 and y-(n-1)*i<=x :
            min_d = i
            break
    arr = []

    c = y
    while(n>0 and c>0):
        arr.append(c)
        n -= 1
        c -= min_d

    c = y+min_d
    while(n>0):
        arr.append(c)
        n -= 1
        c += min_d

    return sorted(arr)

def main():
    t = int(input())
    for i in range(t):
        for j in get_result():
            print(j, end=' ')
        print()

if __name__=='__main__':
    main()


def get_result():
    n, x, y = list(map(int, input().split()))

    if n==2:
        return [x,y]

    diff = y-x
    min_d = diff
    for i in range(1, diff):
        if diff%i==0 and x-i>0 and diff//i<=n-1 and y-(n-1)*i<=x :
            min_d = i
            break
    arr = []

    c = y
    while(n>0 and c>0):
        arr.append(c)
        n -= 1
        c -= min_d

    c = y+min_d
    while(n>0):
        arr.append(c)
        n -= 1
        c += min_d

    return sorted(arr)

def main():
    t = int(input())
    for i in range(t):
        for j in get_result():
            print(j, end=' ')
        print()

if __name__=='__main__':
    main()


def get_result():
    n, x, y = list(map(int, input().split()))

    if n==2:
        return [x,y]

    diff = y-x
    min_d = diff
    for i in range(1, diff):
        if diff%i==0 and x-i>0 and diff//i<=n and y-(n-1)*i<=x :
            min_d = i
            break
    arr = []

    c = y
    while(n>0 and c>0):
        arr.append(c)
        n -= 1
        c -= min_d

    c = y+min_d
    while(n>0):
        arr.append(c)
        n -= 1
        c += min_d

    return arr

def main():
    t = int(input())
    for i in range(t):
        for j in get_result():
            print(j, end=' ')
        print()

if __name__=='__main__':
    main()


for _ in range(int(input())):
    n,x,y=map(int,input().split())
    if n==2:
        print(x,y)
    else:
        ans=False
        maxx=max(x,y)
        for i in range(1,maxx):
            if (abs(x-y)%i==0) and (n>=(abs(x-y)/i)+1):
                k=0
                count=0
                for j in range(n):
                    if maxx-k*i>0:
                        print(maxx-k*i,end=" ")
                        k+=1
                    else:
                        count+=1
                        if count==1:
                            k=1
                        print(maxx+k*i,end=" ")
                        k+=1
                print()
                ans=True
            if ans:
                break


for _ in range(int(input())):
    n,x,y=map(int,input().split())
    arr=[x,y]
    diff=y-x
    ans=0
    for i in range(diff,0,-1):
        if diff%i==0 and diff//(diff//i)<=n-1:
            ans=i
            break
    if ans:
        ans=diff//ans
    i=x
    while i+ans<y and ans!=0:
        arr.append(i+ans)
        i+=ans
    man=x
    women=y
    p=1
    q=1
    for j in range(n-len(arr)):
        if man-ans*p>=0:
            arr.append(man-ans*p)
            p+=1
        else:
            arr.append(women+ans*q)
            q+=1
    for k in arr:
        print(k,end=" ")
    print()


for _ in range(int(input())):
    n,x,y=map(int,input().split())
    if n==2:
        print(x,y)
    else:
        ans=False
        maxx=max(x,y)
        mainarr=[1000000000000]
        for i in range(1,maxx):
            arr=[]
            if (abs(x-y)%i==0) and (n>=((abs(x-y)/i)+1)):
                k=0
                count=0
                for j in range(n):
                    if maxx-k*i>0:
                        arr.append(maxx-k*i)
                        k+=1
                    else:
                        count+=1
                        if count==1:
                            k=1
                        arr.append(maxx+k*i)
                        k+=1
            if len(arr)==n:
                if max(arr)<max(mainarr):
                    mainarr=arr
        for i in mainarr:
            print(i,end=" ")
        print()


for _ in range(int(input())):
    n,x,y=map(int,input().split())
    arr=[x,y]
    diff=y-x
    ans=0
    for i in range(diff,0,-1):
        if diff%i==0 and diff//(diff//i)<=n-1:
            ans=i
            break
    if ans:
        ans=diff//ans
    i=x
    while i+ans<y and ans!=0:
        arr.append(i+ans)
        i+=ans
    man=x
    women=y
    p=1
    q=1
    for j in range(n-len(arr)):
        if man-ans*p>0:
            arr.append(man-ans*p)
            p+=1
        else:
            arr.append(women+ans*q)
            q+=1
    for k in arr:
        print(k,end=" ")
    print()


for _ in range(int(input())):
    n,x,y=map(int,input().split())
    if n==2:
        print(x,y)
    else:
        ans=False
        maxx=max(x,y)
        mainarr=[1000000000000]
        for i in range(1,maxx):
            arr=[]
            if (abs(x-y)%i==0) and (n>=((abs(x-y)/i)+1)):
                k=0
                count=0
                for j in range(n):
                    if maxx-k*i>0:
                        arr.append(maxx-k*i)
                        k+=1
                    else:
                        count+=1
                        if count==1:
                            k=1
                        arr.append(maxx+k*i)
                        k+=1
            if len(arr)!=0:
                if max(arr)<max(mainarr):
                    mainarr=arr
        for i in mainarr:
            print(i,end=" ")
        print()


for s in[*open(0)][1:]:
 n,x,y=map(int,s.split());d=y-x;i=1
 while d%i or d//i>=n:i+=1
 x=max(x%i or i,y-n*i);print(*range(x,x+n*i,i))


for s in[*open(0)][1:]:
 n,x,y=map(int,s.split());d=y-x;i=1
 while d%i or d//i>=n:i+=1
 x=max(x%i or i,y-n*i+i);print(*range(x,x+n*i,i))


for s in[*open(0)][1:]:
 n,x,y=map(int,s.split());d=y-x;i=d//n+1
 while d%i:i+=1
 x=max(x%i or i,y-n*i+i);print(*range(x,x+n*i,i))


def util(d, n):
    factors = set()
    for i in range(1, int(d**0.5)):
        factors.add(i)
        factors.add(d//i)
    return [i for i in factors if d//i < n]

def process():
    n, x, y = map(int, input().split())
    d = y-x
    consider = sorted(util(d, n))
    diff = consider[0]
    middle = d//diff - 1
    seq = [x, y]
    n -= (middle+2)
    for i in range(1, middle + 1):
        seq.append(x + i*diff)
    i = 1
    while n > 0:
        item = x - i*diff
        if item < 1:
            break
        seq.append(item)
        i += 1
        n -= 1
    i = 1
    while n > 0:
        item = y + i*diff
        seq.append(item)
        i += 1
        n -= 1
    print(sorted(seq))

for i in range(int(input())):
    process()


def process():
    n, x, y = map(int, input().split())
    d = y-x
    for i in range(n):
        print(x + i*d, end=" ")
    print()

for i in range(int(input())):
    process()


def util(d, n):
    factors = set()
    for i in range(1, int(d**0.5)+1):
        if d % i == 0:
            factors.add(i)
            factors.add(d//i)
    return [i for i in factors if d//i < n]

def process():
    n, x, y = map(int, input().split())
    d = y-x
    consider = sorted(util(d, n))
    # print(consider)
    diff = consider[0]
    middle = d//diff - 1
    seq = [x, y]
    n -= (middle+2)
    for i in range(1, middle + 1):
        seq.append(x + i*diff)
    i = 1
    while n > 0:
        item = x - i*diff
        if item < 1:
            break
        seq.append(item)
        i += 1
        n -= 1
    i = 1
    while n > 0:
        item = y + i*diff
        seq.append(item)
        i += 1
        n -= 1
    print(*seq)

for i in range(int(input())):
    process()


def util(d, n):
    factors = set()
    for i in range(1, int(d**0.5)):
        factors.add(i)
        factors.add(d//i)
    return [i for i in factors if d//i < n]

def process():
    n, x, y = map(int, input().split())
    d = y-x
    consider = sorted(util(d, n))
    diff = consider[0]
    middle = d//diff - 1
    seq = [x, y]
    n -= (middle+2)
    for i in range(1, middle + 1):
        seq.append(x + i*diff)
    i = 1
    while n > 0:
        item = x - i*diff
        if item < 1:
            break
        seq.append(item)
        i += 1
        n -= 1
    i = 1
    while n > 0:
        item = y + i*diff
        seq.append(item)
        i += 1
        n -= 1
    print(*seq)

for i in range(int(input())):
    process()


import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

t = ini()
for _ in range(t):
    n, x, y = inm()
    dif = y - x
    ans = 0
    for i in range(1, dif+1):
        if dif % i != 0:
            continue
        count = n - 1
        tmp = y
        ok = False
        while count > 0 and tmp > 0:
            tmp -= i
            count -= 1
            if tmp == x:
                ok = True
        if tmp < 0:
            tmp += i
        if ok:
            # print(tmp, i)
            break
    numbers = []
    for j in range(0, n):
        numbers.append(tmp + i*j)
    out(numbers, " ")


import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

t = ini()
for _ in range(t):
    n, x, y = inm()
    dif = y - x
    for i in range(1, dif+1):
        if dif % i != 0:
            continue
        count = n - 1
        start = y
        ok = False
        while count > 0 and start > 0:
            start -= i
            count -= 1
            if start == x:
                ok = True
        start += i if start <= 0 else 0
        if ok:
            break
    ans = []
    for j in range(n):
        ans.append(start + i*j)
    out(ans, " ")


import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

t = ini()
for _ in range(t):
    n, x, y = inm()
    dif = y - x
    ans = 0
    for i in range(1, dif+1):
        if dif % i != 0:
            continue
        count = n - 1
        tmp = y
        ok = False
        while count > 0 and tmp > 0:
            tmp -= i
            count -= 1
            if tmp == x:
                ok = True
        if tmp <= 0:
            tmp += i
        if ok:
            # print(tmp, i)
            break
    numbers = []
    for j in range(0, n):
        numbers.append(tmp + i*j)
    out(numbers, " ")


import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

t = ini()
for _ in range(t):
    n, x, y = inm()
    dif = y - x
    for i in range(1, dif+1):
        if dif % i != 0:
            continue
        count = n - 1
        start = y
        ok = False
        while count > 0 and start > 0:
            start -= i
            count -= 1
            if start == x:
                ok = True
        start += i if start <= 0 else 0
        if ok:
            break
    ans = []
    for j in range(0, n):
        ans.append(start + i*j)
    out(ans, " ")


import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

ans = []
t = ini()
for _ in range(t):
    n, x, y = inm()
    dif = y - x
    for i in range(1, dif+1):
        if dif % i != 0:
            continue
        count = n - 1
        start = y
        ok = False
        while count > 0 and start > 0:
            start -= i
            count -= 1
            ok = True if start == x else False
        start += i if start <= 0 else 0
        if ok:
            break
    numbers = [start + i*j for j in range(n)]
    ans.append(numbers)
for i in ans:
    print(*i)


import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))

ans = []
t = ini()
for _ in range(t):
    n, x, y = inm()
    dif = y - x
    for i in range(1, dif+1):
        if dif % i != 0:
            continue
        count = n - 1
        start = y
        ok = False
        while count > 0 and start > 0:
            start -= i
            count -= 1
            if start == x:
                ok = True
        start += i if start <= 0 else 0
        if ok:
            break
    numbers = [start + i*j for j in range(n)]
    ans.append(numbers)
for i in ans:
    print(*i)


for _ in range(int(input().strip())):
    n,x,y = tuple(map(int,input().strip().split()))
    step = y-x
    for i in range(n-1,1,-1):
        diff = y-x
        if(diff%i==0):
            print(diff,i)
            step = diff/i
            break
    li = []
    i = x
    co = 0
    while(i!=(y+step)):
        li.append(i)
        i+=step
        co+=1
    i = x
    while (co<n):
        while ((i-step)>=1):
            i-=step
            li.append(i)
            co+=1

        if(co!=n):
            li.append(max(li)+step)
            co+=1
    for i in li:
        print(i,sep="",end=" ")
    print()


for _ in range(int(input().strip())):
    n,x,y = tuple(map(int,input().strip().split()))
    step = y-x
    for i in range(n-1,1,-1):
        diff = y-x
        if(diff%i==0):
            step = diff/i
            break
    li = []
    i = x
    co = 0
    while(i!=(y+step)):
        li.append(i)
        i+=step
        co+=1
    i = x
    if (co<n):
        while ((i-step)>=1 or co<n):
            i-=step
            li.append(i)
            co+=1

        while(co<n):
            li.append(max(li)+step)
            co+=1
    for i in li:
        print(int(i),sep="",end=" ")
    print()


for _ in range(int(input().strip())):
    n,x,y = tuple(map(int,input().strip().split()))
    step = y-x
    for i in range(n-1,1,-1):
        diff = y-x
        if(diff%i==0):
            print(diff,i)
            step = diff/i
            break
    li = []
    i = x
    co = 0
    while(i!=(y+step)):
        li.append(i)
        i+=step
        co+=1
    i = x
    while (co<n):
        while ((i-step)>=1):
            i-=step
            li.append(i)
            co+=1

        if(co!=n):
            li.append(max(li)+step)
            co+=1
    for i in li:
        print(int(i),sep="",end=" ")
    print()


for _ in range(int(input().strip())):
    n,x,y = tuple(map(int,input().strip().split()))
    step = y-x
    for i in range(n-1,1,-1):
        diff = y-x
        if(diff%i==0):
            step = diff/i
            break
    li = []
    i = x
    co = 0
    while(i!=(y+step)):
        li.append(i)
        i+=step
        co+=1
    i = x
    if (co<n):
        while ((i-step)>=1 and co<n):
            i-=step
            li.append(i)
            co+=1

        while(co<n):
            li.append(max(li)+step)
            co+=1
    for i in li:
        print(int(i),sep="",end=" ")
    print()


for _ in range(int(input().strip())):
    n,x,y = tuple(map(int,input().strip().split()))
    step = y-x
    for i in range(n-1,1,-1):
        diff = y-x
        if(diff%i==0):
            print(diff,i)
            step = diff/i
            break
    li = []
    i = x
    co = 0
    while(i!=(y+step)):
        li.append(i)
        i+=step
        co+=1
    i = x
    while (co<n):
        while ((i-step)>=1):
            i-=step
            li.append(i)
            co+=1

        if(co!=n):
            li.append(max(li)+step)
            co+=1
    print(li)


from sys import stdin

def AP(a1,d,n):
    arr = []
    for i in range(n):
        arr.append(a1+d*i)
    print(arr)

def apos(n1,r1,d):
    while(r1>0):
        if( n1-r1*d > 0 ):
            return n1-r1*d
        else:
            r1-=1
    return n1

for _ in range( int(stdin.readline().rstrip() )):
    temp = stdin.readline().rstrip().split()
    r = int(temp[0])
    n1 = int(temp[1])
    n2 = int(temp[2])
    diff = r - 1
    d = 0
    while(diff>0):
        val = (n2-n1)/diff
        if( val.is_integer() ):
            d = int(val)
            break
        else:
            diff-=1
    a1 = apos(n1,r-1-diff,d)
    AP(a1,d,r)


from sys import stdin

def AP(a1,d,n):

    for i in range(n):
        print(a1+d*i,end=" ")
    print()

def apos(n1,r1,d):
    while(r1>0):
        if( n1-r1*d > 0 ):
            return n1-r1*d
        else:
            r1-=1
    return n1

for _ in range( int(stdin.readline().rstrip() )):
    temp = stdin.readline().rstrip().split()
    r = int(temp[0])
    n1 = int(temp[1])
    n2 = int(temp[2])
    diff = r - 1
    d = 0
    while(diff>0):
        val = (n2-n1)/diff
        if( val.is_integer() ):
            d = int(val)
            break
        else:
            diff-=1
    a1 = apos(n1,r-1-diff,d)
    AP(a1,d,r)


from sys import stdin

def AP(a1,d,n):
    arr = []
    for i in range(n):
        arr.append(a1+d*i)
    print(arr)

def apos(n1,r1,d):
    while(r1>0):
        if( n1-r1*d > 0 ):
            return n1-r1*d
        else:
            r1-=1
    return n1

temp = input().split()
r = int(temp[0])
n1 = int(temp[1])
n2 = int(temp[2])
diff = r - 1
d = 0
while(diff>0):
    val = (n2-n1)/diff
    if( val.is_integer() ):
       d = int(val)
       break
    else:
        diff-=1
print("d=",d,"diff=",diff)

a1 = apos(n1,r-1-diff,d)
AP(a1,d,r)


t=int(input())
for i in range(t):
    n,x,y=map(int,input().split())
    n1=n-1
    for i in range(n):
        if (y-x)%n1==0:
            d=(y-x)//n1
            break
        n1-=1
    # print(d)
    z1=x
    z=0
    while z1>1:
        z=z1
        z1-=d
    final=z+(n-1)*d
    # print(z)
    if final<y:
        final=y
    cd=(final-z)//(n-1)
    # print(cd)
    for i in range(n):
        print(final,end=" ")
        final-=d
    print()


t=int(input())
for i in range(t):
    n,x,y=map(int,input().split())
    n1=n-1
    for i in range(n):
        if (y-x)%n1==0:
            d=(y-x)//n1
            break
        n1-=1
    # print(d)
    z1=x
    z=0
    while z1>0:
        z=z1
        z1-=d
    final=z+(n-1)*d
    # print(z)
    if final<y:
        final=y
    cd=(final-z)//(n-1)
    # print(cd)
    for i in range(n):
        print(final,end=" ")
        final-=d
    print()


t=int(input())
for i in range(t):
    series= None
    n,x,y=map(int,input().split())
    #AP terms are a+(i-1)d
    for a in range(1,51):           #first term
        for d in range(1,51):       #common difference
            ap=[]
            for i in range(n):
                ap.append(a+i*d)        #i shows (i+1)th term
            if x in ap and y in ap:
                if series==None or series[n-1]>ap[n-1]:
                    series=ap
    # for c in series:
    #     print(c,end=' ')
    c=" ".join(list(map(str,series)))
    print(c)


t=int(input())
for i in range(t):
    n,x,y=map(int,input().split())
    for i in range(n-1,0,-1):
        if (y-x)%i==0:
            d=(y-x)//i
            break
    # print(d)
    z1=x
    z=0
    while z1>0:
        z=z1
        z1-=d
    final=z+(n-1)*d
    # print(z)
    if final<y:
        final=y
    d=(final-z)//(n-1)
    # print(d)
    for i in range(n):
        print(final,end=" ")
        final-=d
    print()


t=int(input())
for i in range(t):
    n,x,y=map(int,input().split())
    # n1=n-1
    # for i in range(n):
    #     if (y-x)%n1==0:
    #         d=(y-x)//n1
    #         break
    #     n1-=1
    for i in range(n-1,0,-1):
        if (y-x)%i==0:
            d=(y-x)//i
            break
    # print(d)
    z1=x
    z=0
    while z1>0:
        z=z1
        z1-=d
    final=z+(n-1)*d
    # print(z)
    if final<y:
        final=y
    cd=(final-z)//(n-1)
    # print(cd)
    for i in range(n):
        print(final,end=" ")
        final-=d


for i in range(int(input())):
    n, x, y = map(int, input().split())
    for i in range(1, y-x+1):
        a = (y-x)/i
        if a == int(a) and a < n:
            ans = list(range(x,y+i,i))
            k = x - i
            while len(ans) < n and k > 0:
                ans.append(k)
                k -= i
            k = y + i
            while len(ans) < n:
                ans.append(k)
                k += i
            print(ans)
            break


for i in range(int(input())):
    n, x, y = map(int, input().split())
    for i in range(1, y-x+1):
        a = (y-x)/i
        if a == int(a) and a < n:
            ans = list(range(x,y+i,i))
            k = x - i
            while len(ans) < n and k > 0:
                ans.append(k)
                k -= i
            k = y + i
            while len(ans) < n:
                ans.append(k)
                k += i
            print(*ans)
            break


T = int(input())

for _ in range(T):
    n, x, y = map(int, input().split())

    res = [10 ** 18]
    if n == 2:
        res = [x, y]
    else:
        for i in range(1, 51):
            tmp = []
            if (y - x) % i == 0 and (y - x) // i <= n - 1:
                tmp = [j for j in range(x, y + 1, i)]
                nn = n - len(tmp)
                # print(tmp)
                if nn > 0:
                    for j in reversed(range(x - i, 0, -i)):
                        tmp = [j] + tmp
                        nn -= 1
                        if nn == 0:
                            break
                if nn > 0:
                    for j in range(y + i, y + nn * i + 1, i):
                        tmp.append(j)
                        nn -= 1
                        if nn == 0:
                            break

                if res[-1] > tmp[-1]:
                    res = tmp
    print(*res)


T = int(input())

for _ in range(T):
    n, x, y = map(int, input().split())

    res = [10 ** 18]
    if n == 2:
        res = [x, y]
    else:
        for i in range(1, 51):
            tmp = []
            if (y - x) % i == 0 and (y - x) // i <= n - 1:
                tmp = [j for j in range(x, y + 1, i)]
                nn = n - len(tmp)
                # print(tmp)
                if nn > 0:
                    for j in reversed(range(x - i, 0, -i)):
                        tmp = [j] + tmp
                        nn -= 1
                        if nn == 0:
                            break
                if nn > 0:
                    for j in range(y + i, 10 ** 9 + 1, i):
                        tmp.append(j)
                        nn -= 1
                        if nn == 0:
                            break

                if res[-1] > tmp[-1]:
                    res = tmp
    print(*res)


T = int(input())

for _ in range(T):
    n, x, y = map(int, input().split())

    res = [10 ** 18]
    if n == 2:
        res = [x, y]
    else:
        for i in range(1, 51):
            tmp = []
            if (y - x) % i == 0 and (y - x) // i <= n - 1:
                tmp = [j for j in range(x, y + 1, i)]
                nn = n - len(tmp)
                # print(tmp)
                if nn > 0:
                    for j in range(x - i, 0, -i):
                        tmp = [j] + tmp
                        nn -= 1
                        if nn == 0:
                            break
                if nn > 0:
                    for j in range(y + i, 10 ** 9 + 1, i):
                        tmp.append(j)
                        nn -= 1
                        if nn == 0:
                            break

                if res[-1] > tmp[-1]:
                    res = tmp

    print(*res)


t = int(input())
for _ in range(t):
    n,x,y = map(int,input().split())
    d = 0
    q = 0
    for i in range(1,n):
        d = (y-x)/(n-i)
        q = int(d)
        if d==q:
            break

    for ber in range(n):
        if (y-(ber*q)) > 0:
            print(y-(ber*q),end=' ')
        else:

            for car in range(1,(n-ber+1)):
                print(y+(car*q),end=' ')
            break

    print()


t = int(input())
for _ in range(t):
    n,x,y = map(int,input().split())
    d = 0
    q = 0
    for i in range(1,n):
        d = (y-x)/(n-i)
        q = int(d)
        if d==q:
            break
    a = 0
    for yeet in range(1,x+1):
        if (x-yeet)%q == 0:
            a = yeet
            break

    for ber in range(n):
        print(a+(ber*q),end=' ')
    print()


t = int(input())
for _ in range(t):
    n,x,y = map(int,input().split())
    d = 0
    q = 0
    for i in range(1,n):
        d = (y-x)/(n-i)
        q = int(d)
        if d==q:
            break
    a = 0
    for yeet in range(1,x+1):
        if (x-yeet)%q == 0:
            a = yeet
            break

    for ber in range(n):
        if (y-(ber*q)) > 0:
            print(y-(ber*q),end=' ')
        else:

            for car in range(1,(n-ber+1)):
                print(y+(ber*q),end=' ')
            break

    print()


t = int(input())
for _ in range(t):
    n,x,y = map(int,input().split())
    d = 0
    q = 0
    for i in range(1,n):
        d = (y-x)/(n-i)
        q = int(d)
        if d==q:
            break
    for ber in range(n):
        print(x+(ber*q),end=' ')
    print()


for _ in range(int(input())):
    n,x,y=[int(i) for i in input().split()]
    AL=[2**32]*n
    for a in range(1,51):
        for d in range(1,51):
            AP=set({})
            for i in range(n):
                AP.add(a+i*d)
            if x in AP and y in AP and max(AL)>(a+(n-1)*d) :
                AL=list(AP)
    print(*AL)


for _ in range(int(input())):
    n,x,y=[int(i) for i in input().split()]
    AL=[2**32]*n
    for a in range(1,51):
        for d in range(1,51):
            AP=[]
            for i in range(n):
                AP.append(a+i*d)
            if x in AP and y in AP and AL[n-1]>(a+(n-1)*d) :
                AL=AP
    print(*AL)


for _ in range(int(input())):
    n,x,y=[int(i) for i in input().split()]
    AL=[2**32]*n
    for a in range(1,51):
        for d in range(1,51):
            AP=set({})
            for i in range(n):
                AP.add(a+i*d)
            if x in AP and y in AP and AL[n-1]>(a+(n-1)*d) :
                AL=sorted(list(AP))
    print(*AL)


for _ in range(int(input())):
    n,x,y=[int(i) for i in input().split()]
    AL=[2**32]*n
    for a in range(1,51):
        for d in range(1,51):
            l=a+(n-1)*d
            AP=list(range(a,l+1,d))
            if x in AP and y in AP and AL[n-1]>(a+(n-1)*d) :
                AL=AP
    print(*AL)


t = int(input())
while t > 0:
    n, x, y = map(int, input().split())
    diff = y-x
    arr1 = list()
    arr2 = list()
    arr3 = list()
    arr = []*n
    for i in range(1, diff+1):
        if diff%i == 0:
            arr1.append(i)
    arr1.sort(reverse = True)
    for j in range(len(arr1)):
        if arr1[j] > n-1:
            continue
        elif arr1[j] <= n-1:
            arr2 = arr1[j:]
            break
    a = int(diff/(arr2[0]))
    for b in reversed(range(n)):
        if (y-a*b) > 0:
            arr.insert(0, (y-a*b))
            break
    for m in range(n):
        arr3.append(arr[0] + a*m)
    print(*arr3)
    t -= 1


t = int(input())
while t > 0:
    n, x, y = map(int, input().split())
    diff = y-x
    arr1 = list()
    arr2 = list()
    arr3 = list()
    arr = []*n
    for i in range(1, diff+1):
        if diff%i == 0:
            arr1.append(i)
    arr1.sort(reverse = True)
    for j in range(len(arr1)):
        if arr1[j] > n-1:
            continue
        elif arr1[j] <= n-1:
            arr2 = arr1[j:]
            break
    a = int(diff/(arr2[0]))
    '''if arr2[0] == n-1:
        for k in range(n):
            arr3.append(y-a*k)
    else:'''
    for b in reversed(range(n)):
        if (y-a*b) > 0:
            arr.insert(0, (y-a*b))
            break
    for m in range(n):
        arr3.append(arr[0] + a*m)
    print(*arr3)
    t -= 1


t = int(input())
while t > 0:
    n, x, y = map(int, input().split())
    diff = y-x
    arr1 = list()
    arr2 = list()
    arr3 = list()
    arr = []*n
    for i in range(1, diff+1):
        if diff%i == 0:
            arr1.append(i)
    arr1.sort(reverse = True)
    for j in range(len(arr1)):
        if arr1[j] > n-1:
            continue
        elif arr1[j] <= n-1:
            arr2 = arr1[j:]
            break
    a = int(diff/(arr2[0]))
    if arr2[0] == n-1:
        for k in range(n):
            arr3.append(x+a*k)
    else:
        arr.insert(0, (y-a*(n-2)))
        for m in range(n):
            arr3.append(arr[0] + a*m)
    print(*arr3)
    t -= 1


t = int(input())
while t > 0:
    n, x, y = map(int, input().split())
    diff = y-x
    arr1 = list()
    arr2 = list()
    arr3 = list()
    arr = []*n
    for i in range(1, diff+1):
        if diff%i == 0:
            arr1.append(i)
    arr1.sort(reverse = True)
    for j in range(len(arr1)):
        if arr1[j] > n-1:
            continue
        elif arr1[j] <= n-1:
            arr2 = arr1[j:]
            break
    a = int(diff/(arr2[0]))
    if arr2[0] <= n-1:
        for k in range(n):
            arr3.append(y-a*k)
    else:
        for b in reversed(range(2, n+1)):
            if (y-a*(b-2)) > 0:
                arr.insert(0, (y-a*(b-2)))
                break
        for m in range(n):
            arr3.append(arr[0] + a*m)
    print(*arr3)
    t -= 1


t = int(input())
while t > 0:
    n, x, y = map(int, input().split())
    diff = y-x
    arr1 = list()
    arr2 = list()
    arr3 = list()
    arr = []*n
    for i in range(1, diff+1):
        if diff%i == 0:
            arr1.append(i)
    arr1.sort(reverse = True)
    for j in range(len(arr1)):
        if arr1[0] > n-1:
            arr2 = arr1[1:]
    arr.insert(n-2, y)
    arr.insert(n-arr2[0], x)
    a = int(diff/(arr2[0]))
    arr.insert(0, (y-a*(n-2)))
    for k in range(n):
        arr3.append(arr[0] + a*k)
    print(*arr3)
    t -= 1


for i in range(int(input())):
    n,x,y = list(map(int,input().split()))
    kol = y-x

    print(x,end = ' ')
    for j in range(1,n):
        print(x+kol*j,end =  ' ')
    print()


for i in range(int(input())):
    n,x,y = list(map(int,input().split()))
    kol = y-x

    chislo = 0

    for j in range(1,kol+1):
        if ((kol)%j == 0 and (y//j) <= n-1):
            chislo = j
            break
    if not(x%chislo == 0):
        ost = x%chislo
    else:
        ost = chislo
    for j in range(0,n):
        print(ost + chislo*(j),end =  ' ')
    print()


for i in range(int(input())):
    n,x,y = list(map(int,input().split()))
    min_n = 0
    min_k = 1000000000000000
    raz = 0
    for j in range(1,110):
        for k in range(1,110):
            if ((x-j)%k == 0 and (y-j)%k == 0):
                if (j+k*(n-1) >= y) and(j <= x):
                    if (min_k  > j+k*(n-1)):
                        min_n = j
                        min_k = j+k*(n-1)
                        raz = k
    for j in range(n):
        print(min_n+raz*(j),end = ' ')
    print()


def divisors(n):
    a = []
    for i in range(1,n+1):
        if n%i == 0:
            a.append(i)
    return a
F = [None]*51
for i in range(1,51):
    F[i] = divisors(i)

def cal(n,x,y,t):
    if (y-x)/t > n-1:
        return
    start = x%t
    if (n-1)*t >= y:
        return start
    else:
        return y-(n-1)*t

def solve(n,x,y):
    end,start,t = 9999999,0,0
    global F

    for i in F[y-x]:
        s = cal(n,x,y,i)
        if s is None:
            continue
        else:
            if s+(n-1)*i < end:
                end = s+(n-1)*i
                start = s
                t = i
    return start, end, t

t = int(input())
for _ in range(t):
    n,x,y = map(int,input().split(' '))
    start,end,t = solve(n,x,y)
    for i in range(start,end+t,t):
        print(i,end=' ')
    print('')


def divisors(n):
    a = []
    for i in range(1,n+1):
        if n%i == 0:
            a.append(i)
    return a
F = [None]*51
for i in range(1,51):
    F[i] = divisors(i)

def cal(n,x,y,t):
    if (y-x)/t > n-1:
        return
    start = x%t
    if start ==0:
        start += t
    if (n-1)*t >= y:
        return start
    else:
        return y-(n-1)*t

def solve(n,x,y):
    end,start,t = 9999999,0,0
    global F

    for i in F[y-x]:
        s = cal(n,x,y,i)
        if s is None:
            continue
        else:
            if s+(n-1)*i < end:
                end = s+(n-1)*i
                start = s
                t = i
    return start, end, t

t = int(input())
for _ in range(t):
    n,x,y = map(int,input().split(' '))
    start,end,t = solve(n,x,y)
    for i in range(start,end+t,t):
        print(i,end=' ')
    print('')


t=int(input())
for i in range(t):
    n,x,y=input().split()
    n,x,y=int(n),int(x),int(y)

    if (y-x)%(n-1)==0:
        #print("inside if")
        k=(y-x)//(n-1)
        a=[int(x+j*k) for j in range(n)]
    else:
        #print("inside else")
        temp=n-1
        while (y-x)%temp!=0:
            temp-=1
        k=(y-x)//temp

        a=[]
        for j in range((y-x)//(k)+1):
            a.append(x+j*k)
        temp=n-((y-x)//(k)+1)
        while x-k>0 and temp>0:
            a.append(x-k)
            x-=k
            temp-=1
        while temp>0:
            a.append(y+k)
            y+=k
            temp-=1
    for c in a:
        print(c,end=" ")


t=int(input())
for i in range(t):
    n,x,y=input().split()
    n,x,y=int(n),int(x),int(y)

    if (y-x)%(n-1)==0:
        #print("inside if")
        k=(y-x)//(n-1)
        a=[int(x+j*k) for j in range(n)]
    else:
        #print("inside else")
        temp=n-1
        while (y-x)%temp!=0:
            temp-=1
        k=(y-x)//temp
        print(temp,k)
        a=[]
        for j in range((y-x)//(k)+1):
            a.append(x+j*k)
        temp=n-((y-x)//(k)+1)
        while x-k>0 and temp>0:
            a.append(x-k)
            x-=k
            temp-=1
        while temp>0:
            a.append(y+k)
            y+=k
            temp-=1
    for c in a:
        print(c,end=" ")


import sys
for _ in range (int(input())):
    n,x,y = [int(i) for i in input().split()]
    diff = y-x
    p = []
    check = -1
    for i in range (1,diff+1):
        if diff%i == 0 and diff//i<=n-1:
            check = i
            break
    a = [x]
    for i in range (n-1):
        a.append(a[-1]+check)
    temp = []
    while len(a)<n:
        if len(temp)==0 and a[0]-check<1:
            a.append(a[-1]+check)
        elif (len(temp)!=0 and temp[-1]-check<1):
            a.append(a[-1]+check)
        elif len(temp)==0 and a[0]-check>=1:
            temp.append(a[0]-check)
        elif len(temp)!=0 and temp[-1]-check>=1:
            temp.append(temp[0]-check)
    temp.reverse()
    ans = temp[:]
    ans.extend(a)
    print(*ans)


import sys
for _ in range (int(input())):
    n,x,y = [int(i) for i in input().split()]
    diff = y-x
    p = []
    check = -1
    for i in range (1,diff+1):
        if diff%i == 0 and diff//i<=n-1:
            check = i
            break
    a = [x]
    for i in range (n-1):
        if a[-1]+check<=y:
            a.append(a[-1]+check)
        else:
            break
    temp = []
    while len(a)+len(temp)<n:
        if len(temp)==0 and a[0]-check<1:
            a.append(a[-1]+check)
        elif (len(temp)!=0 and temp[-1]-check<1):
            a.append(a[-1]+check)
        elif len(temp)==0 and a[0]-check>=1:
            temp.append(a[0]-check)
        elif len(temp)!=0 and temp[-1]-check>=1:
            temp.append(temp[-1]-check)
    temp.reverse()
    ans = temp[:]
    ans.extend(a)
    print(*ans)


import sys
for _ in range (int(input())):
    n,x,y = [int(i) for i in input().split()]
    diff = y-x
    p = []
    check = -1
    for i in range (1,diff+1):
        if diff%i == 0 and diff//i<=n-1:
            check = i
            break
    a = [x]
    for i in range (n-1):
        if a[-1]+check<=y:
            a.append(a[-1]+check)
        else:
            break
    temp = []
    while len(a)<n:
        if len(temp)==0 and a[0]-check<1:
            a.append(a[-1]+check)
        elif (len(temp)!=0 and temp[-1]-check<1):
            a.append(a[-1]+check)
        elif len(temp)==0 and a[0]-check>=1:
            temp.append(a[0]-check)
        elif len(temp)!=0 and temp[-1]-check>=1:
            temp.append(temp[0]-check)
    temp.reverse()
    ans = temp[:]
    ans.extend(a)
    print(*ans)


import math
def isprime(n) :
    if (n <= 1) :
        return False
    if (n <= 3) :
        return True
    if (n % 2 == 0 or n % 3 == 0) :
        return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True
for _ in range(int(input())):
    l=[]
    n,x,y=list(map(int,input().split()))
    n-=2
    l.append(x)
    l.append(y)
    if(isprime(abs(x-y))):
        diff=abs(x-y)
        present=min(x,y)-diff
        while(n!=0 and present>0):
            l.append(present)
            present-=diff
            n-=1
        present=max(x,y)+diff
        while(n!=0):
            l.append(present)
            present+=diff
            n-=1
    else:
        copy=n+1
        diff=0
        while(copy!=0):
            # print(abs(x-y),copy)
            if(abs(x-y)%copy==0):
                # print("hi")
                diff=abs(x-y)//copy
                break
            copy-=1
        # print(diff)
        present=min(x,y)+diff
        while(n!=0 and present<max(x,y)):
            l.append(present)
            present+=diff
            n-=1
        present=min(x,y)-diff
        while(n!=0 and present>0):
            l.append(present)
            present-=diff
            n-=1
        present=max(x,y)+diff
        while(n!=0):
            l.append(present)
            present+=diff
            n-=1
    print(*l)


import math
def primefactor(n):
    copy=n
    while(n % 2 == 0):
        return(copy//2)
        n = n / 2
    for i in range(3,int(math.sqrt(n))+1, 2):
        while n % i == 0:
            return(copy//i)
            n=n/i
    if(n>2):
        return(copy//n)
def isprime(n) :
    if (n <= 1) :
        return False
    if (n <= 3) :
        return True
    if (n % 2 == 0 or n % 3 == 0) :
        return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True
for _ in range(int(input())):
    l=[]
    n,x,y=list(map(int,input().split()))
    n-=2
    l.append(x)
    l.append(y)
    if(isprime(abs(x-y))):
        present=min(x,y)-diff
        diff=abs(x-y)
        present=min(x,y)-diff
        while(n!=0 and present>0):
            l.append(present)
            present-=diff
            n-=1
        present=max(x,y)+diff
        while(n!=0):
            l.append(present)
            present+=diff
            n-=1
    else:
        diff=abs(x-y)//primefactor(abs(x-y))
        present=min(x,y)+diff
        while(n!=0 and present<max(x,y)):
            l.append(present)
            present+=diff
            n-=1
        present=min(x,y)-diff
        while(n!=0 and present>0):
            l.append(present)
            present-=diff
            n-=1
        present=max(x,y)+diff
        while(n!=0):
            l.append(present)
            present+=diff
            n-=1
    print(*l)


import math
def isprime(n) :
    if (n <= 1) :
        return False
    if (n <= 3) :
        return True
    if (n % 2 == 0 or n % 3 == 0) :
        return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True
for _ in range(int(input())):
    l=[]
    n,x,y=list(map(int,input().split()))
    n-=2
    l.append(x)
    l.append(y)
    if(isprime(abs(x-y)-1)):
        diff=abs(x-y)
        present=min(x,y)-diff
        while(n!=0 and present>0):
            l.append(present)
            present-=diff
            n-=1
        present=max(x,y)+diff
        while(n!=0):
            l.append(present)
            present+=diff
            n-=1
    else:
        copy=n+1
        # print(copy)
        diff=0
        while(copy!=0):
            if((abs(x-y))%copy==0):
                diff=(abs(x-y))//copy
                break
            copy-=1
        present=min(x,y)+diff
        while(n!=0 and present<max(x,y)):
            l.append(present)
            present+=diff
            n-=1
        present=min(x,y)-diff
        while(n!=0 and present>0):
            l.append(present)
            present-=diff
            n-=1
        present=max(x,y)+diff
        while(n!=0):
            l.append(present)
            present+=diff
            n-=1
    print(*l)


import math
for _ in range(int(input())):
    l=[]
    n,x,y=list(map(int,input().split()))
    n-=2
    l.append(x)
    l.append(y)
    copy=n+1
    diff=abs(x-y)
    while(copy!=0):
        if((abs(x-y))%copy==0):
            diff=(abs(x-y))//copy
            break
        copy-=1
    present=min(x,y)+diff
    while(n!=0 and present<max(x,y)):
        l.append(present)
        present+=diff
        n-=1
    present=min(x,y)-diff
    while(n!=0 and present>0):
        l.append(present)
        present-=diff
        n-=1
    present=max(x,y)+diff
    while(n!=0):
        l.append(present)
        present+=diff
        n-=1
    print(*l)


for _ in range(int(input())):
    n,x,y=input().split()
    n=int(n)
    y=int(y)
    x=int(x)
    for i in reversed(range(1,n)):
        if((y-x)%i==0):
            z=(y-x)//i
            break
    if(y-((n-1)*z)<=0):
        x=y//z
        y=y+(n-x-1)*z
    for i in range(n):
        print(y-i*z,end=" ")
    print()


import math
for _ in range(int(input())):
    n,x,y=input().split()
    n=int(n)
    y=int(y)
    x=int(x)
    for i in reversed(range(1,n)):
        if((y-x)%i==0):
            z=(y-x)//i
            break
    if(y-((n-1)*z)<=0):
        x=math.ceil(y//z)
        y=y+(n-x)*z
    for i in range(n):
        print(y-i*z,end=" ")
    print()


import math
for _ in range(int(input())):
    n,x,y=input().split()
    n=int(n)
    y=int(y)
    x=int(x)
    for i in reversed(range(1,n)):
        if((y-x)%i==0):
            z=(y-x)//i
            break
    if(y-((n-1)*z)<=0):
        x=math.ceil(y/z)
        y=y+(n-x)*z
    for i in range(n):
        print(y-i*z,end=" ")
    print()


t = int(input())

for _ in range(t):

    hello = list(map(int,input().split()))
    n = hello[0]
    x = hello[1]
    y= hello[2]
    m = n-1
    while m!=0:
        if (x-y)%m==0:
            dif = (y-x)//m
            break
        m-=1
    while True:
        if y - dif*(n-1) <1:

            y+=dif

        else:
            break

    for i in range(n):
        #ans.append(x)
        print(y,end=" ")
        y-=dif
    print()


t = int(input())

for _ in range(t):

    hello = list(map(int,input().split()))
    n = hello[0]
    x = hello[1]
    y= hello[2]
    m = n-1
    while m!=0:
        if (x-y)%m==0:
            dif = (y-x)//m
            break
        m-=1
    while True:
        if y - dif*(n-1) <0:

            y+=dif

        else:
            break

    for i in range(n):
        #ans.append(x)
        print(y,end=" ")
        y-=dif
    print()


t = int(input())

for _ in range(t):

    hello = list(map(int,input().split()))
    n = hello[0]
    x = hello[1]
    y= hello[2]
    m = n-1
    while m!=0:
        if (x-y)%m==0:
            dif = (y-x)//m
            break
        m-=1
    while True:
        if y - dif*n <0:
            y+=m
        else:
            break

    for i in range(n):
        #ans.append(x)
        print(y,end=" ")
        y-=dif
    print()


t = int(input())

for _ in range(t):

    hello = list(map(int,input().split()))
    n = hello[0]
    x = hello[1]
    y= hello[2]
    m = n-1
    while m!=0:
        if (x-y)%m==0:
            dif = (y-x)//m
            break
        m-=1

    for i in range(n):
        #ans.append(x)
        print(x,end=" ")
        x+=dif
    print()


for s in [*open(0)][1:]:
    n,x,y=map(int,s.split()); t=n;
    while (y-x)%t:
        t=t-1
    i=(y-x)//t
    x=max(x%i or i, y-(n-1)*i)
    print(*range(x,x+n*i,i))


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
typedef long long ll;
typedef long double ld;
std::map<ld,ld> co;
int main()
{
	int n,k,w,it,q;
	cin>>n>>k;
	std::vector<ld> a(n+1);
	std::vector<ld> ans;
	std::vector<ld> aux;
	FOR(i,1,n+1)cin>>a[i];
	ld temp;
	it=n/k;
	cin>>q;
	FOR(i,0,q)
	{
		temp=0;
		FOR(j,0,it)
		{
			cin>>w;
			co[w]++;
			temp+=a[w];
		}
		ans.push_back(temp/it);
	}
	FOR(i,1,n+1)if(!co[i])aux.push_back(a[i]);
	sort(aux.begin(), aux.end());
	int size=aux.size();
	ld max=INT_MIN,min=INT_MAX;
	cout<<n-(it*q)<<endl;
	if(n-(it*q)<size)
	{
		max=0,min=0;
		FOR(i,size-it,size)max+=aux[i];
		FOR(i,0,it)min+=aux[i];
		max/=it;
		min/=it;
	}
	size=ans.size();
	sort(ans.begin(), ans.end());
	if(ans[size-1]>max)max=ans[size-1];
	if(ans[0]<min)min=ans[0];
	printf("%.10Lf %.10Lf\n",min,max );
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        //cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    for(int i=1;i<=n;i++){
        if(check[i]==1) cnt++;
    }
    vector <int> neww;
    if(n-cnt>=theorem){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      do{
        sum=0;
       // cout << "check: ";
        for(int i=0;i<theorem;i++){
           // cout << neww[i] << " ";
           sum+=neww[i];
        }
        //cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
       // cout << "prof: "<< prof << " "<<minprof << " " << maxprof << endl;
      }
      while(next_permutation(neww.begin(),neww.end()));
      sum=0;
    for(int i=0;i<theorem;i++){
            //cout << neww[i] << " ";
           sum+=neww[i];
        }
       // cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
    }

    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        //cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    for(int i=1;i<=n;i++){
        if(check[i]==1) cnt++;
    }
    vector <int> neww;
    if(n-cnt>=theorem&&theorem>1){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      sum=0;

      do{
        sum=0;
       // cout << "check: ";
        for(int i=0;i<theorem;i++){
           // cout << neww[i] << " ";
           sum+=neww[i];
        }
        //cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
       // cout << "prof: "<< prof << " "<<minprof << " " << maxprof << endl;
      }
      while(next_permutation(neww.begin(),neww.end()));
      sum=0;
    for(int i=0;i<theorem;i++){
            //cout << neww[i] << " ";
           sum+=neww[i];
        }
       // cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
    }

    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        //cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    for(int i=1;i<=n;i++){
        if(check[i]==1) cnt++;
    }
    vector <int> neww;
    if(n-cnt>=theorem&&cnt<k*theorem){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      sum=0;

      do{
        sum=0;
       // cout << "check: ";
        for(int i=0;i<theorem;i++){
           // cout << neww[i] << " ";
           sum+=neww[i];
        }
        //cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
       // cout << "prof: "<< prof << " "<<minprof << " " << maxprof << endl;
      }
      while(next_permutation(neww.begin(),neww.end()));
      sum=0;
    for(int i=0;i<theorem;i++){
            //cout << neww[i] << " ";
           sum+=neww[i];
        }
       // cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
    }

    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    for(int i=1;i<=n;i++){
        if(check[i]==1) cnt++;
    }
    vector <int> neww;
    if(n-cnt>=theorem){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      do{
        sum=0;
       // cout << "check: ";
        for(int i=0;i<theorem;i++){
           // cout << neww[i] << " ";
           sum+=neww[i];
        }
        //cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
       // cout << "prof: "<< prof << " "<<minprof << " " << maxprof << endl;
      }
      while(next_permutation(neww.begin(),neww.end()));
      sum=0;
    for(int i=0;i<theorem;i++){
            //cout << neww[i] << " ";
           sum+=neww[i];
        }
       // cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
    }

    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        //cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    for(int i=1;i<=n;i++){
        if(check[i]==1) cnt++;
    }
    vector <int> neww;
    if(n-cnt>=theorem&&cnt>k){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      sum=0;

      do{
        sum=0;
       // cout << "check: ";
        for(int i=0;i<theorem;i++){
           // cout << neww[i] << " ";
           sum+=neww[i];
        }
        //cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
       // cout << "prof: "<< prof << " "<<minprof << " " << maxprof << endl;
      }
      while(next_permutation(neww.begin(),neww.end()));
      sum=0;
    for(int i=0;i<theorem;i++){
            //cout << neww[i] << " ";
           sum+=neww[i];
        }
       // cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
    }

    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back
#define debug                   cout << "check"

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
            cnt++;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        //cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    vector <int> neww;
    if(n-cnt>=theorem){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      do{
        sum=0;
       // cout << "check: ";
        for(int i=0;i<theorem;i++){
           // cout << neww[i] << " ";
           sum+=neww[i];
        }
        //cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
       // cout << "prof: "<< prof << " "<<minprof << " " << maxprof << endl;
      }
      while(next_permutation(neww.begin(),neww.end()));
    }
    sum=0;
    for(int i=0;i<theorem;i++){
            //cout << neww[i] << " ";
           sum+=neww[i];
        }
       // cout << endl;
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        //cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    for(int i=1;i<=n;i++){
        if(check[i]==1) cnt++;
    }
    vector <int> neww;
    if(n-cnt>=theorem&&cnt<k*theorem){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      sum=0;
        sort(neww.begin(),neww.end());
        for(int i=0;i<theorem;i++){
            sum+=neww[i];
        }
        prof=(double)sum/(double)theorem;
        minprof=min(minprof,prof);
        maxprof=max(maxprof,prof);

      sum=0;
      for(int i=0;i<theorem;i++){
            sum+=neww[neww.size()-1-i];
        }
        prof=(double)sum/(double)theorem;
        minprof=min(minprof,prof);
        maxprof=max(maxprof,prof);

    }

    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define	FastRead                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll                      long long
#define ull                     unsigned long long
#define SP(n)                   cout << setprecision(n)
#define PI                      acos(-1.0)
#define For(i,a,b)              for(int i=0;i<b;i+=a)
#define Rof(i,a,b)              for(int i=b;i>=0;i-=a)
#define Read()                  freopen("input.txt","r",stdin);
#define pb                      push_back

int check[1000];

int main()
{
    FastRead
    int n,k;
    cin >> n >> k;
    int theorem=n/k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    int q,a,sum,cnt=0;
    cin >> q;
    double prof,minprof=1000,maxprof=0;
    while(q--){
        sum=0;
        for(int i=0;i<theorem;i++){
            cin >> a;
            sum+=arr[a-1];
            check[a]=1;
        }
        prof=(double)sum/(double)theorem;
        if(prof<minprof) minprof=prof;
        if(prof>maxprof) maxprof=prof;
        //cout <<"prof" << prof << " " << minprof << " " << maxprof << endl;
    }
    for(int i=1;i<=n;i++){
        if(check[i]==1) cnt++;
    }
    vector <int> neww;
    if(n-cnt>=theorem&&cnt<k*theorem){
      for(int i=1;i<=n;i++){
        if(check[i]==0) neww.pb(arr[i-1]);
      }
      sum=0;
        sort(neww.begin(),neww.end());
        for(int i=0;i<theorem;i++){
            sum+=neww[i];
        }
        prof=sum/theorem;
        minprof=min(minprof,prof);
        maxprof=max(maxprof,prof);

      sum=0;
      for(int i=0;i<theorem;i++){
            sum+=neww[neww.size()-1-i];
        }
        prof=sum/theorem;
        minprof=min(minprof,prof);
        maxprof=max(maxprof,prof);

    }

    SP(10);
    cout << minprof << " " << maxprof;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,k,i,j;
    cin>>n>>k;
    vi v(n);
    read(v,0,n);
    int q;
    cin>>q;
    int tt=n/k;
    double mn=10000000.0,mx=0;
    vi query(tt);
    while(q--)
    {
        read(query,0,tt);
        double sum=0;
        for(auto it:query)
        {
            if(v[it-1]==-1)
                goto level;
            sum+=(double)(v[it-1]);
            v[it-1]=-1;
        }
        mn = min(mn,sum/tt);
        mx = max(mx,sum/tt);
        level:
            continue;
    }
    sort(all(v));
    while(v.size()>0&&v[0]==-1)
        v.erase(v.bg);
    double sum=0;
    for(i=0; i<tt; i++)
        sum+=(double)(v[i]);
    mn = min(mn,sum/tt);
    sum=0;
    for(i=v.size()-1,j=0; j<tt; j++,i--)
        sum+=v[i];
    mx = max(mx,sum/tt);
    cout<<fixed<<setprecision(10)<<mn<<' '<<mx<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,k,i,j;
    cin>>n>>k;
    vi v(n);
    read(v,0,n);
    int q;
    cin>>q;
    int tt=n/k;
    double mn=10000000.0,mx=0;
    vi query(tt);
    while(q--)
    {
        read(query,0,tt);
        double sum=0;
        for(auto it:query)
        {
            if(v[it-1]==-1)
                goto level;
            sum+=(double)(v[it-1]);
            v[it-1]=-1;
        }
        mn = min(mn,sum/tt);
        mx = max(mx,sum/tt);
        level:
            continue;
    }
    sort(all(v));
    while(v.size()>0&&v[0]==-1)
        v.erase(v.bg);
    if(v.size()){
    double sum=0;
    for(i=0; i<tt; i++)
        sum+=(double)(v[i]);
    mn = min(mn,sum/tt);
    sum=0;
    for(i=v.size()-1,j=0; j<tt; j++,i--)
        sum+=v[i];
    mx = max(mx,sum/tt);}
    cout<<fixed<<setprecision(10)<<mn<<' '<<mx<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,k,i,j;
    cin>>n>>k;
    vi v(n);
    read(v,0,n);
    int q;
    cin>>q;
    int tt=n/k;
    double mn=10000000.0,mx=0;
    vi query(tt);
    while(q--)
    {
        read(query,0,tt);
        double sum=0;
        for(auto it:query)
        {
            if(v[it-1]==-1)
                goto level;
            sum+=(double)(v[it-1]);
            v[it-1]=-1;
        }
        mn = min(mn,sum/tt);
        mx = max(mx,sum/tt);
        level:
            continue;
    }
    sort(all(v));
    while(v.size()>0&&v[0]==-1)
        v.erase(v.bg);
    if(v.size()+k*tt!=n){
    double sum=0;
    for(i=0; i<tt; i++)
        sum+=(double)(v[i]);
    mn = min(mn,sum/tt);
    sum=0;
    for(i=v.size()-1,j=0; j<tt; j++,i--)
        sum+=v[i];
    mx = max(mx,sum/tt);}
    cout<<fixed<<setprecision(10)<<mn<<' '<<mx<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///
int main()
{
    FIO;
    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,k,i,j;
    cin>>n>>k;
    vi v(n);
    read(v,0,n);
    int q;
    cin>>q;
    int tt=n/k;
    double mn=10000000.0,mx=0;
    vi query(tt);
    while(q--)
    {
        read(query,0,tt);
        double sum=0;
        for(auto it:query)
        {
            if(v[it-1]==-1)
                goto level;
            sum+=(double)(v[it-1]);
            v[it-1]=-1;
        }
        mn = min(mn,sum/tt);
        mx = max(mx,sum/tt);
        level:
            continue;
    }
    sort(all(v));
    while(v.size()>0&&v[0]==-1)
        v.erase(v.bg);
    if(v.size()>=tt){
    double sum=0;
    for(i=0; i<tt; i++)
        sum+=(double)(v[i]);
    mn = min(mn,sum/tt);
    sum=0;
    for(i=v.size()-1,j=0; j<tt; j++,i--)
        sum+=v[i];
    mx = max(mx,sum/tt);}
    cout<<fixed<<setprecision(10)<<mn<<' '<<mx<<endl;
    return 0;
}


// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > >
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	int n,k;
	cin>>n>>k;
	vip a(n);
	rep(i,n){
		cin>>a[i].fi;
		a[i].sec = i;
	}
	int q;
	cin>>q;
	int m = (n/k);
	// cout<<m<<'\n';
	ll minsum = INT_MAX;
	ll maxsum = INT_MIN;
	map<ll,ll> mp;
	int c = 0;
	map<vector<int>,int> d;
	while(q--){
		vi v(m);
		ll sum = 0;
		rep(i,m){
			cin>>v[i];
			mp[v[i]-1]++;
			sum += a[v[i]-1].fi;
		}
		sort(all(v));
		d[v]++;
		if(d[v] == 1){
			c++;
		}
		minsum = min(minsum,sum);
		maxsum = max(maxsum,sum);
	}
	// int c = 0;
	vi ans(0);
	rep(i,n){
		if(mp[i] == 0){
			ans.pb(a[i].fi);
		}
	}
	if(c < k && s(ans) >= m){
		sort(all(ans));
		ll max1=0,min1=0;
		rep(i,m){
			min1 += ans[i];
		}
		int sz = s(ans)-1;
		for(int i = sz;i>sz-m;i--){
			max1 += ans[i];
		}
		maxsum = max(maxsum,max1);
		minsum = min(minsum,min1);
	}
	double min1 = 1.0*minsum/m;
	double max1 = 1.0*maxsum/m;
	cout<<fixed<<setprecision(12)<<min1<<" "<<max1;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define MP make_pair

const int N = 110;
const int M = 26;
const double pi = acos(-1.0);
const double eps = 1e-10;

typedef long long ll;
typedef pair<int, int> PII;

int a[N], vis[N];

int main ()
{
	int n, k, m, T;
	scanf("%d %d", &n, &k);
	m = n / k;
	memset(vis, 0, sizeof(vis));
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	scanf("%d", &T);
	int mn = 1e9 + 10, mx = 0;
	while(T--){
		int sum = 0, t;
		for(int i = 0; i < m; i++){
			scanf("%d", &t);
			vis[t] = 1;
			sum += a[t];
		}
		mn = min(mn, sum);
		mx = max(mx, sum);
	}

	int top = 0;
	for(int i = 1; i <= n; i++)
		if(!vis[i]) a[top++] = a[i];

	if(top > n - m * k){
		sort(a, a+top);
		int sum = 0;
		for(int i = 0; i < m; i++)
			sum += a[i];
		mn = min(mn, sum);

		sum = 0;
		for(int i = top - m; i < top; i++)
			sum += a[i];
		mx = max(mx, sum);
	}

	printf("%.6lf %.6lf\n", 1.0 * mn / m, 1.0 * mx / m);

	return 0;
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class cf119b {
  public static void main(String[] args) {
    FastIO in = new FastIO(), out = in;
    int n = in.nextInt();
    int k = in.nextInt();
    int z = n/k;
    int min = 987654321, max = 0;
    int[] v = new int[n];
    for(int i=0; i<n; i++)
      v[i] = in.nextInt();
    boolean[] skip = new boolean[n];
    int q = in.nextInt();
    Set<ArrayList<Integer>> seen = new HashSet<ArrayList<Integer>>();
    for(int i=0; i<q; i++) {
      int tmp = 0;
      ArrayList<Integer> here = new ArrayList<Integer>();
      for(int j=0; j<z; j++) {
        int x = in.nextInt()-1;
        here.add(x);
        skip[x] = true;
        tmp += v[x];
      }
      Collections.sort(here);
      seen.add(here);
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
    }
    ArrayList<Integer> left = new ArrayList<Integer>();
    for(int i=0; i<n; i++)
      if(!skip[i])
        left.add(v[i]);
    Collections.sort(left);
    if(left.size() >= z && seen.size() < k) {
      int tmp = 0;
      for(int i=0; i<z; i++)
        tmp += left.get(i);
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
      tmp = 0;
      for(int i=0; i<z; i++)
        tmp += left.get(left.size()-1-i);
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
    }
    out.printf("%.10f %.10f%n", min*1./z, max*1./z);
    out.close();
  }
  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in,System.out);
    }
    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }
    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch(Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }
    public int numTokens() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }
    public String next() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }
    public double nextDouble() {
      return Double.parseDouble(next());
    }
    public long nextLong() {
      return Long.parseLong(next());
    }
    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class cf119b {
  public static void main(String[] args) {
    FastIO in = new FastIO(), out = in;
    int n = in.nextInt();
    int k = in.nextInt();
    int z = n/k;
    int min = 987654321, max = 0;
    int[] v = new int[n];
    for(int i=0; i<n; i++)
      v[i] = in.nextInt();
    boolean[] skip = new boolean[n];
    int q = in.nextInt();
    for(int i=0; i<q; i++) {
      int tmp = 0;
      for(int j=0; j<z; j++) {
        int x = in.nextInt()-1;
        skip[x] = true;
        tmp += v[x];
      }
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
    }
    ArrayList<Integer> left = new ArrayList<Integer>();
    for(int i=0; i<n; i++)
      if(!skip[i])
        left.add(v[i]);
    Collections.sort(left);
    if(left.size() >= z) {
      int tmp = 0;
      for(int i=0; i<z; i++)
        tmp += left.get(i);
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
      tmp = 0;
      for(int i=0; i<z; i++)
        tmp += left.get(left.size()-1-i);
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
    }
    out.printf("%.10f %.10f%n", min*1./z, max*1./z);
    out.close();
  }
  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in,System.out);
    }
    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }
    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch(Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }
    public int numTokens() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }
    public String next() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }
    public double nextDouble() {
      return Double.parseDouble(next());
    }
    public long nextLong() {
      return Long.parseLong(next());
    }
    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class cf119b {
  public static void main(String[] args) {
    FastIO in = new FastIO(), out = in;
    int n = in.nextInt();
    int k = in.nextInt();
    int z = n/k;
    int min = 987654321, max = 0;
    int[] v = new int[n];
    for(int i=0; i<n; i++)
      v[i] = in.nextInt();
    boolean[] skip = new boolean[n];
    int q = in.nextInt();
    for(int i=0; i<q; i++) {
      int tmp = 0;
      for(int j=0; j<z; j++) {
        int x = in.nextInt()-1;
        skip[x] = true;
        tmp += v[x];
      }
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
    }
    ArrayList<Integer> left = new ArrayList<Integer>();
    for(int i=0; i<n; i++)
      if(!skip[i])
        left.add(v[i]);
    Collections.sort(left);
    if(left.size() >= z && q < k) {
      int tmp = 0;
      for(int i=0; i<z; i++)
        tmp += left.get(i);
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
      tmp = 0;
      for(int i=0; i<z; i++)
        tmp += left.get(left.size()-1-i);
      min = Math.min(min,tmp);
      max = Math.max(max,tmp);
    }
    out.printf("%.10f %.10f%n", min*1./z, max*1./z);
    out.close();
  }
  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in,System.out);
    }
    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }
    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch(Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }
    public int numTokens() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }
    public String next() {
      if(!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }
    public double nextDouble() {
      return Double.parseDouble(next());
    }
    public long nextLong() {
      return Long.parseLong(next());
    }
    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}


import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.List;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Nguyen Trung Hieu - vuondenthanhcong11@yahoo.com
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        int theoremCount = in.readInt();
        int taskCount = in.readInt();
        int[] knowledge = IOUtils.readIntArray(in, theoremCount);
        boolean[] inTask = new boolean[theoremCount];
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        int knownTasks = in.readInt();
        int taskSize = theoremCount / taskCount;
        for (int i = 0; i < knownTasks; i++) {
            int currentScore = 0;
            for (int j = 0; j < taskSize; j++) {
                int index = in.readInt() - 1;
                currentScore += knowledge[index];
                inTask[index] = true;
            }
            min = Math.min(min, currentScore);
            max = Math.max(max, currentScore);
        }
        List<Integer> unknown = new ArrayList<Integer>();
        for (int i = 0; i < theoremCount; i++) {
            if (!inTask[i])
                unknown.add(knowledge[i]);
        }
        Collections.sort(unknown);
        if ((theoremCount - unknown.size()) / taskSize != taskCount) {
            int score = 0;
            for (int i = 0; i < taskSize; i++)
                score += unknown.get(i);
            min = Math.min(min, score);
            score = 0;
            for (int i = unknown.size() - taskSize; i < unknown.size(); i++)
                score += unknown.get(i);
            max = Math.max(max, score);
        }
        out.printFormat("%.8f %.8f\n", (double)min / taskSize, (double)max / taskSize);
    }
}

class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

    }

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void printFormat(String format, Object...objects) {
        writer.printf(format, objects);
    }

    public void close() {
        writer.close();
    }

}

class IOUtils {

    public static int[] readIntArray(InputReader in, int size) {
        int[] array = new int[size];
        for (int i = 0; i < size; i++)
            array[i] = in.readInt();
        return array;
    }

    }


import java.util.*;
import java.lang.*;
public class B119
	{
	public static void main(String[] args)
		{
		Scanner in =new Scanner(System.in);
		int n = in.nextInt();int k = in.nextInt();int counter1=0,check=0;
		int i=0,j=0;Data a[] = new Data[n];int m = n/k;double min=10000000.00,max=-1.00,avg=0.0;int sum=0;
		for(i=0;i<n;i++)
			{
			a[i]=new Data(in.nextInt(),i);
			}
		int q = in.nextInt();
		int b[][] = new int[q][m];int count[] = new int[n];
		for(i=0;i<q;i++)
			{check=0;
			sum=0;
			for(j=0;j<m;j++)
				{
				b[i][j] = in.nextInt();count[b[i][j]-1]++;
				sum+=a[b[i][j]-1].getValue();
				}
			Arrays.sort(b[i]);
			for(int l=0;l<i;l++)
				{
				if(Arrays.equals(b[i],b[l]))
					{
					check=1;break;
					}
				}
			if(check==0)
				{
				counter1++;
				}
			avg = sum/(double)m;
			if(avg<min)
				{
				min=avg;//System.out.println("min"+min);
				}
			if(avg>max)
				{
				max=avg;//System.out.println("max"+max);
				}
			}int counter=0;
		Data[] obj = new Data[n];
		for(i=0;i<n;i++)
			{
			if(count[i]==0)
				{
				obj[counter] = new Data(a[i].getValue(),a[i].getIndex());counter++;
				}
			}
		if(counter==0||counter<m||counter1>=k)
			{
			System.out.printf(min+" "+max);
			System.exit(0);
			}
		obj = MergeSort(obj,0,counter-1);sum=0;
		for(i=0;i<m;i++)
			{
			sum+=obj[i].getValue();
			}
		avg = sum/(double)m;sum=0;
		if(avg<min)
			{
			min=avg;
			}
		for(i=counter-1;i>=counter-m;i--)
			{
			sum+=obj[i].getValue();
			}
		avg = sum/(double)m;
		if(avg>max)
			{
			max=avg;
			}
		System.out.printf(min+" "+max);
		System.exit(0);
		}
	public static Data[] MergeSort(Data[] a,int low,int high)
		{
		if(low>=high)
			{
			return a;
			}
		else
			{
			int middle=(high+low)/2;
			Data[] left = new Data [middle-low+1];
			Data[] right = new Data [high-middle];
			int i=0,count=0;
			for(i=0;i<=middle-low;i++)
				{
				left[count]=a[i];count++;
				}
			count=0;
			for(i=middle+1-low;i<=high-low;i++)
				{
				right[count]=a[i];count++;
				}
			Data[] SortedLeft =MergeSort(left,low,middle);
			Data[] SortedRight =MergeSort(right,middle+1,high);
			return Merge(SortedLeft,SortedRight,low,high);
			}
		}
	public static Data[] Merge(Data[] sl,Data[] sr,int low,int high)
		{
		Data fina[]  = new Data[high-low+1];
		int i=0,middle =(high+low)/2;
		int a=0,b=0,alimit=middle-low+1,blimit=high-middle;
		int n=alimit+blimit;
		/*System.out.println("sl");
		for(i=0;i<alimit;i++)
			{
			int x = sl[i].getValue();
			int y = sl[i].getIndex();
			System.out.println(x+" "+y);
			}
		System.out.println("sr");
		for(i=0;i<blimit;i++)
			{
			int x = sr[i].getValue();
			int y = sr[i].getIndex();
			System.out.println(x+" "+y);
			}*/
		for(i=0;i<n;i++)
			{
			if(a!=alimit&&(b==blimit||(sl[a].getValue()<=sr[b].getValue()&&a<alimit)))
				{
				fina[i]=new Data(sl[a].getValue(),sl[a].getIndex());
				a++;
				}
			else
				{
				fina[i]=new Data(sr[b].getValue(),sr[b].getIndex());
				b++;
				}
			}
		return fina;
		}
	}
 class Data
	{
	private int val;
	private int index;
	public Data(int x,int y)
		{
		val=x;
		index=y;
		}
	public int getValue()
		{
		return this.val;
		}
	public int getIndex()
		{
		return this.index;
		}
	}