It is the hard version of the problem. The only difference is that in this version $3 \le k \le n$.

You are given a positive integer $n$. Find $k$ positive integers $a_1, a_2, \ldots, a_k$, such that:

$a_1 + a_2 + \ldots + a_k = n$

$LCM(a_1, a_2, \ldots, a_k) \le \frac{n}{2}$

Here $LCM$ is the least common multiple of numbers $a_1, a_2, \ldots, a_k$.

We can show that for given constraints the answer always exists.


-----Input-----

The first line contains a single integer $t$ $(1 \le t \le 10^4)$  — the number of test cases.

The only line of each test case contains two integers $n$, $k$ ($3 \le n \le 10^9$, $3 \le k \le n$).

It is guaranteed that the sum of $k$ over all test cases does not exceed $10^5$.


-----Output-----

For each test case print $k$ positive integers $a_1, a_2, \ldots, a_k$, for which all conditions are satisfied.


-----Examples-----

Input
2
6 4
9 5
Output
1 2 2 1 
1 3 3 1 1


-----Note-----

None

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Mathematics

Constructive algorithms


Solutions:
t = int(input())
out = []
for _ in range(t):
	(n, k) = map(int, input().split())
	res = [1] * (k - 3)
	n = n - k + 3
	if n % 2 == 0:
		if n % 4 == 0:
			res = res + [n // 2, n // 4, n // 4]
		else:
			res = res + [n // 2 - 1, n // 2 - 1, 2]
	else:
		res = res + [n // 2, n // 2, 1]
	out.append(res)
for i in out:
	print(*i)


import math
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def print_num(n):
	if n % 2 == 1:
		print(1, (n - 1) // 2, (n - 1) // 2)
	elif n % 4 == 0:
		print(n // 2, n // 4, n // 4)
	elif n % 2 == 0:
		print(2, (n - 2) // 2, (n - 2) // 2)
for i in range(inp()):
	(n, k) = invr()
	s = 0
	while k > 3:
		k -= 1
		s += 1
		print(1, end=' ')
	print_num(n - s)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	for i in range(k - 3):
		print(1, end=' ')
	n = n - (k - 3)
	if n == 0:
		print()
		continue
	if n % 2:
		print(n // 2, n // 2, 1)
	elif n % 4:
		print(n // 2 - 1, n // 2 - 1, 2)
	else:
		print(n // 2, n // 4, n // 4)
	print()


for u in range(int(input())):
	(n, k) = map(int, input().split())
	x = [1] * (k - 3)
	n -= k - 3
	a = n // 2
	if n % 2:
		x.append(1)
		x.append(a)
		x.append(a)
	elif a % 2:
		x.append(2)
		x.append(a - 1)
		x.append(a - 1)
	else:
		x.append(a // 2)
		x.append(a // 2)
		x.append(a)
	print(*x)


import sys
input = sys.stdin.readline
from collections import defaultdict
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	while m > 3:
		print(1, end=' ')
		m -= 1
		n -= 1
	if n % 2:
		print(n // 2, n // 2, 1)
	elif n % 4 == 0:
		print(n // 2, n // 4, n // 4)
	else:
		print(n // 2 - 1, 2, n // 2 - 1)


import sys
input = sys.stdin.readline
for f in range(int(input())):
	(n, k) = map(int, input().split())
	n -= k - 3
	for i in range(k - 3):
		print(end='1 ')
	if n % 4 == 0:
		print(n // 2, n // 4, n // 4)
	if n % 4 == 1 or n % 4 == 3:
		print(n // 2, n // 2, 1)
	if n % 4 == 2:
		print(n // 2 - 1, n // 2 - 1, 2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = []
	n -= k - 3
	if n < 3:
		ans = [n]
	elif n % 3 == 0:
		ans = [n // 3] * 3
	elif n % 2 == 1:
		ans = [1]
		ans.extend([(n - 1) // 2] * 2)
	elif (n - 2) // 2 % 2 == 0:
		ans = [2]
		ans.extend([(n - 2) // 2] * 2)
	else:
		ans = [n // 4, n // 4, n // 2]
	ans.extend([1] * (k - 3))
	print(*ans)


import sys
input = sys.stdin.readline
from collections import Counter
import math
t = int(input())
for _ in range(t):
	(n, K) = map(int, input().split())
	n -= K - 3
	if n % 4 == 0:
		ans = [n // 2, n // 4, n // 4]
	elif n % 2 == 0:
		ans = [(n - 2) // 2, (n - 2) // 2, 2]
	else:
		ans = [(n - 1) // 2, (n - 1) // 2, 1]
	ans += [1] * (K - 3)
	print(*ans)


for _ in range(int(input())):
	(num, k) = map(int, input().split())
	k -= 3
	num -= k
	print('1 ' * k, end='')
	print(f'1 {(num - 1) // 2} {(num - 1) // 2}' if num % 2 else f'2 {num // 2 - 1} {num // 2 - 1}' if num % 4 else f'{num // 4} {num // 4} {num // 2}')


from math import floor
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = []
	if k > 3:
		kn = k - 3
		nn = n - kn
	else:
		nn = n
	if nn % 2 == 0:
		if nn / 2 % 2 == 0:
			x.append(int(nn / 2))
			x.append(int(nn / 2 / 2))
			x.append(int(nn / 2 / 2))
		else:
			x.append(2)
			x.append(int(nn / 2 - 1))
			x.append(int(nn / 2 - 1))
	else:
		x.append(1)
		x.append(floor(nn / 2))
		x.append(floor(nn / 2))
	if k > 3:
		for ii in range(kn):
			x.append(1)
	print(' '.join(map(str, x)))


def count(n):
	if n % 2 == 1:
		return str(n // 2) + ' ' + str(n // 2) + ' 1'
	else:
		if n == 4:
			return '2 1 1'
		elif n == 6:
			return '2 2 2'
		elif n == 8:
			return '4 2 2'
		if n % 4 == 2:
			return str(n // 2 - 1) + ' ' + str(n // 2 - 1) + ' 2'
		return str(n // 2) + ' ' + str(n // 4) + ' ' + str(n // 4)

def main():
	(n, k) = map(int, input().split())
	print(count(n - (k - 3)) + ' 1' * (k - 3))
for _ in range(int(input())):
	main()


t = eval(input())
for i in range(t):
	(n, k) = map(int, input().split())
	for i in range(k - 3):
		print(1, end=' ')
	n = n - k + 3
	if n % 2 != 0:
		print(1, int(n // 2), int(n // 2))
	else:
		x = n // 2
		if x % 2 != 0:
			print(2, int(n // 2 - 1), int(n // 2 - 1))
		else:
			print(int(x // 2), int(x // 2), int(x))


from sys import stdin
input = stdin.readline

def A():
	from collections import defaultdict
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		l = []
		seen = defaultdict()
		for i in range(n):
			if seen.get(a[i], 0) == 0:
				seen[a[i]] = 1
			else:
				l.append(a[i])
		print(*sorted(list(set(a))) + l)

def B():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		l = [0] * m
		a = list(map(int, input().split()))
		for i in range(n):
			a[i] %= m
			l[a[i]] += 1
		groups = 0
		for i in range(1, (m + 1) // 2):
			(hi, lo) = (max(l[i], l[m - i]), min(l[i], l[m - i]))
			if hi == lo and hi >= 1:
				groups += 1
			else:
				groups += hi - lo
		if m % 2 == 0:
			if l[m // 2] > 0:
				groups += 1
		if l[0] > 0:
			groups += 1
		print(groups)

def C():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		n -= k - 3
		if n % 4 == 0:
			arr = [n // 2, n // 4, n // 4]
		elif n % 4 == 1:
			arr = [1, n // 2, n // 2]
		elif n % 4 == 2:
			arr = [2, n // 2 - 1, n // 2 - 1]
		else:
			arr = [1, n // 2, n // 2]
		print(*arr + [1] * (k - 3))

def D():
	pass
C()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ans = [1] * (m - 3)
	n -= m - 3
	if n % 3 == 0:
		p = [n // 3, n // 3, n // 3]
	elif n % 2 == 1:
		p = [1, n // 2, n // 2]
	else:
		ta = n // 2
		if ta % 2 == 0:
			p = [ta, ta // 2, ta // 2]
		else:
			p = [ta - 1, ta - 1, 2]
	ans += p
	print(*ans)


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
testcases = int(input())
for testcase in range(testcases):
	temparr = get_ints()
	a = temparr[0]
	b = temparr[1]
	ans = []
	if b > 3:
		diff = b - 3
		for i in range(diff):
			a -= 1
			ans.append(str(1))
	if a & 1:
		ans.append(str(1))
		a -= 1
		diff = a >> 1
		ans.append(str(diff))
		ans.append(str(diff))
		print(' '.join(ans))
	else:
		diff = a >> 1
		if diff & 1:
			ans.append(str(2))
			ans.append(str(diff - 1))
			ans.append(str(diff - 1))
			print(' '.join(ans))
		else:
			halfhalf = diff >> 1
			ans.append(str(diff))
			ans.append(str(halfhalf))
			ans.append(str(halfhalf))
			print(' '.join(ans))


def solve(n):
	if n % 3 == 0:
		print(n // 3, n // 3, n // 3)
	elif n % 3 == 1:
		if n & 1:
			print(1, (n - 1) // 2, (n - 1) // 2)
		elif n % 4 == 0:
			n //= 2
			print(n, n // 2, n // 2)
		else:
			n -= 2
			print(2, n // 2, n // 2)
	elif n & 1:
		n -= 1
		print(1, n // 2, n // 2)
	elif n % 4 == 0:
		n //= 2
		print(n, n // 2, n // 2)
	else:
		n -= 2
		print(2, n // 2, n // 2)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [1] * (k - 3)
	if k - 3 != 0:
		print(*l, end=' ')
	n -= k - 3
	solve(n)


import sys
import bisect
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7

def giver(n):
	if n % 2:
		return [1, n // 2, n // 2]
	elif int(log(n, 2)) == log(n, 2):
		return [n // 2, n // 4, n // 4]
	else:
		x = list(bin(n)[2:])
		t = 0
		s = len(x)
		for i in range(len(x) - 1, -1, -1):
			if x[i] == '1':
				break
			t += 1
		abe = t
		while abe >= 0:
			x.pop()
			abe -= 1
		x = x + ['0'] * t
		x = ''.join(x)
		return [int(x, 2), int(x, 2), pow(2, t)]

def hnbhai():
	(n, k) = sd()
	ans = [1] * (k - 3) + giver(n - (k - 3))
	print(*ans)
for _ in range(sb()):
	hnbhai()


t = int(input())
for i in range(t):
	(n, k) = [int(j) for j in input().split()]
	for i in range(k - 3):
		print(1, end=' ')
	n = n - (k - 3)
	if n % 2 == 0:
		if (n - 2) / 2 % 2 != 0:
			print(n // 2, n // 4, n // 4)
		else:
			print(2, (n - 2) // 2, (n - 2) // 2)
	else:
		print(1, (n - 1) // 2, (n - 1) // 2)


for __ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	n -= k - 3
	ans = [1] * (k - 3)
	if n % 4 == 1:
		ans += [1, n // 2, n // 2]
	elif n % 4 == 2:
		ans += [2, n // 2 - 1, n // 2 - 1]
	elif n % 4 == 3:
		ans += [1, n // 2, n // 2]
	else:
		num = 2
		while True:
			if (n - num) % 2 == 0 and ((n - num) // 2 % num == 0 or num % ((n - num) // 2) == 0):
				ans += [num, (n - num) // 2, (n - num) // 2]
				break
			num *= 2
	print(*ans)


def getk3(n):
	if n & 1:
		return (1, (n - 1) // 2, (n - 1) // 2)
	elif n % 4 == 0:
		return (n // 4, n // 4, n // 2)
	else:
		return (2, n // 2 - 1, n // 2 - 1)
for _ in range(int(input())):
	(n, k) = map(int, input().strip().split())
	(a, b, c) = getk3(n - k + 3)
	sol = ['1'] * (k - 3) + [str(a), str(b), str(c)]
	print(' '.join(sol))


def gcd(a, b):
	x = max(a, b)
	y = min(a, b)
	c = x % y
	while c != 0:
		(x, y) = (y, c)
		c = x % y
	return y

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	res = []
	for i in range(k - 3):
		res.append(1)
	n = n - k + 3
	if n % 2 == 1:
		res.append(1)
		res.append((n - 1) // 2)
		res.append((n - 1) // 2)
	elif n % 4 == 2:
		res.append(2)
		res.append((n - 2) // 2)
		res.append((n - 2) // 2)
	else:
		res.append(n // 2)
		res.append(n // 4)
		res.append(n // 4)
	print(*res)


def find():
	(n, k) = map(int, input().split())
	print('1 ' * (k - 3), end='')
	n = n - k + 3
	if n % 2 != 0:
		print((n - 1) // 2, (n - 1) // 2, 1)
	elif n // 2 % 2 == 0:
		print(n // 2, n // 4, n // 4)
	else:
		print(n // 2 - 1, n // 2 - 1, 2)
for i in range(int(input())):
	find()


cases = int(input())
while cases:
	cases -= 1
	(a, b) = map(int, input().split())
	ans = []
	while b > 3:
		ans.append(1)
		b -= 1
		a -= 1
	if b == 3:
		if a % 2 != 0:
			print(a // 2, a // 2, 1, *ans)
		elif a % 4 == 0:
			print(a // 4, a // 4, a // 2, *ans)
		else:
			print(a // 2 - 1, a // 2 - 1, 2, *ans)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	while t:
		t -= 1
		(n, k) = map(int, input().split())
		ans = []
		while k > 3:
			(k, n) = (k - 1, n - 1)
			ans.append(1)
		if n % 2 == 1:
			ans.append(1)
			ans.append((n - 1) // 2)
			ans.append((n - 1) // 2)
		elif n % 4 == 0:
			ans.append(n // 2)
			ans.append(n // 4)
			ans.append(n // 4)
		elif n % 2 == 0:
			ans.append(2)
			ans.append((n - 2) // 2)
			ans.append((n - 2) // 2)
		sys.stdout.write(' '.join(map(str, ans)) + '\n')
main()


Test = int(input())
Ans = ''

def solve(n, k):
	ans = '1 ' * (k - 3)
	n = n - (k - 3)
	if n % 3 == 0:
		return ans + str(n // 3) + ' ' + str(n // 3) + ' ' + str(n // 3) + '\n'
	if n & n - 1 == 0:
		return ans + str(n // 2) + ' ' + str(n // 4) + ' ' + str(n // 4) + '\n'
	if n % 2 != 0:
		return ans + str(n // 2) + ' ' + str(n // 2) + ' 1\n'
	bound = n // 2
	if bound % 2 == 0:
		return ans + str(n // 2) + ' ' + str(n // 4) + ' ' + str(n // 4) + '\n'
	return ans + str(bound - 1) + ' ' + str(bound - 1) + ' ' + str(n - 2 * (bound - 1)) + '\n'
for i in range(Test):
	(n, k) = [int(i) for i in input().split()]
	Ans = Ans + solve(n, k)
print(Ans)


def three(n):
	if n % 2 == 0:
		a = n // 2
		b = a // 2
		if a % 2 == 1:
			b = 2
			a -= 1
			return (a, a, b)
		return (a, b, b)
	else:
		a = n // 2
		return (a, a, 1)
for tt in range(int(input())):
	(n, k) = map(int, input().split())
	print(*three(n - k + 3), end=' ')
	for i in range(k - 3):
		print(1, end=' ')
	print()


import sys, math
sys.setrecursionlimit(10 ** 8)
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	n = n - m + 3
	ans = []
	if n % 3 == 0:
		ans.append(n // 3)
		ans.append(n // 3)
		ans.append(n // 3)
	elif n % 4 == 0:
		ans.append(n // 2)
		ans.append(n // 4)
		ans.append(n // 4)
	elif n % 2 == 0:
		print(n // 2 - 1, n // 2 - 1, 2)
	else:
		ans.append(n // 2)
		ans.append(n // 2)
		ans.append(1)
	for i in range(m - 3):
		ans.append(1)
	print(' '.join(map(str, ans)))


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	for i in range(4, k + 1):
		print('1', end=' ')
		n -= 1
	if n % 2:
		print(1, (n - 1) // 2, (n - 1) // 2)
	elif n % 4:
		print(2, (n - 2) // 2, (n - 2) // 2)
	else:
		print(n // 2, n // 4, n // 4)


t = int(input())

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def sea(n):
	a = [0, 1, 2, 1]
	i = n // 2 if n % 4 == 0 else a[n % 4]
	a = (n - i) // 2
	return [i, a, a]

def get(n, k):
	res = [1] * k
	tmp = sea(n - k + 3)
	for i in range(3):
		res[i] = tmp[i]
	return res
for _ in range(t):
	(n, k) = list(map(int, input().split(' ')))
	res = get(n, k)
	print(' '.join(map(str, res)))


from sys import stdin, stdout
from collections import defaultdict as dd
import math
input = stdin.readline
flush = stdout.flush
tc = 1
tc = int(input())
for _ in range(tc):
	(n, k) = map(int, input().split())
	for i in range(k - 3):
		print(1, end=' ')
	n = n - k + 3
	if n % 4 == 0:
		print(n // 2, n // 4, n // 4)
	elif n % 2 == 0:
		print(2, n // 2 - 1, n // 2 - 1)
	else:
		print(1, n // 2, n // 2)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	n -= k - 3
	if n % 2:
		print(n // 2, n // 2, 1, *[1 for i in range(k - 3)])
	elif n % 4:
		print(n // 2 - 1, n // 2 - 1, 2, *[1 for i in range(k - 3)])
	else:
		print(n // 2, n // 4, n // 4, *[1 for i in range(k - 3)])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	for i in range(k - 3):
		print(1, end=' ')
		n = n - 1
	if n == 3:
		print(1, 1, 1)
	elif n % 2 != 0:
		a = n // 2
		b = a
		c = 1
		print(a, b, c)
	else:
		if n // 2 % 2 != 0:
			a = n // 2 - 1
			b = a
			c = 2
		else:
			a = n // 2
			b = a // 2
			c = b
		print(a, b, c)


from math import floor
t = int(input())

def func(n):
	if n % 2 == 1:
		print(1, floor(n / 2), floor(n / 2))
	elif n % 4 == 0:
		print(n // 2, n // 4, n // 4)
	else:
		print(2, n // 2 - 1, n // 2 - 1)
while t:
	t -= 1
	(n, k) = map(int, input().split())
	n -= k - 3
	while k > 3:
		print('1', end=' ')
		k -= 1
	func(n)


def check(n):
	if n % 2 == 1:
		return [1, (n - 1) // 2, (n - 1) // 2]
	elif n // 2 % 2 == 0:
		return [n // 2, n // 4, n // 4]
	else:
		return [2, n // 2 - 1, n // 2 - 1]
t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	ans = [1] * (k - 3)
	n -= k - 3
	y = check(n)
	ans = ans + y
	print(*ans)


import sys
import collections
from copy import copy, deepcopy
from typing import OrderedDict
import heapq

class Solution:

	def trim(self):
		return input()

	def rInt(self):
		return int(self.trim())

	def rStr(self):
		return str(self.trim())

	def rCharList(self):
		s = self.trim()
		return list(s[:len(s) - 1])

	def rIntMap(self):
		return map(int, self.trim().split())

	def rIntList(self):
		return list(self.rIntMap())

	def rStrList(self):
		return list(map(str, self.trim().split()))

	def process(self, tc, n, k):
		res = []
		while k > 3:
			res.append(1)
			n -= 1
			k -= 1

		def last(n):
			if n & n - 1 == 0:
				return [n // 4, n // 4, n // 2]
			x = n & -n
			return [x, (n - x) // 2, (n - x) // 2]
		res += last(n)
		print(' '.join(map(str, res)))

def main():
	s = Solution()
	tcs = s.rInt()
	for tc in range(tcs):
		(n, k) = s.rIntList()
		s.process(tc + 1, n, k)
main()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007
for _ in range(stdint()):
	(n, k) = stdmap()
	res = []
	for i in range(k - 3):
		res.append(1)
	n -= k - 3
	if n & 1 == 1:
		res.extend([1, (n - 1) // 2, (n - 1) // 2])
	elif n % 4 == 0:
		res.extend([n // 4, n // 4, n // 2])
	else:
		res.extend([2, (n - 2) // 2, (n - 2) // 2])
	print(*res)


import math
import sys
import collections
import bisect
import time

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	(n, k) = get_ints()
	ans = []
	while k > 3:
		ans.append(1)
		k -= 1
		n -= 1
	if n % 2 == 0:
		if n % 4 == 0:
			ans.append(n // 2)
			ans.append(n // 4)
			ans.append(n // 4)
		else:
			ans.append(n // 2 - 1)
			ans.append(n // 2 - 1)
			ans.append(2)
	else:
		ans.append(1)
		ans.append((n - 1) // 2)
		ans.append((n - 1) // 2)
	print(*ans)


from collections import defaultdict
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k = k - 3
	n = n - k
	while k:
		print(1, end=' ')
		k -= 1
	if n % 2 != 0:
		print(1, n // 2, n // 2)
	elif n % 4 == 0:
		print(n // 2, n // 4, n // 4)
	elif n % 2 == 0:
		print(2, n // 2 - 1, n // 2 - 1)


t = int(input())
for p in range(t):
	(n, m) = map(int, input().split())
	n -= m - 3
	if n % 2 == 1:
		print(1, (n - 1) // 2, (n - 1) // 2, end=' ')
	elif n % 4 == 0:
		c = n // 4
		print(c * 2, c, c, end=' ')
	else:
		print(2, (n - 2) // 2, (n - 2) // 2, end=' ')
	for k in range(m - 3):
		print(1, end=' ')
	print()


from math import floor

def easy_k_lcm(n):
	if n % 2 != 0:
		return (1, floor(n / 2), floor(n / 2))
	elif n % 4 == 0:
		return (n // 2, n // 4, n // 4)
	else:
		return (int(n / 2 - 1), int(n / 2 - 1), 2)
test = int(input())
for t in range(test):
	(n, k) = list(map(int, input().split()))
	ans = ''
	ones = '1 ' * (k - 3)
	ans += ones
	(a, b, c) = easy_k_lcm(n - k + 3)
	ans += str(a) + ' ' + str(b) + ' ' + str(c)
	print(ans)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	ans = [1] * (k - 3)
	n = n - k + 3
	if n % 2 == 1:
		print(*ans, 1, n // 2, n // 2)
	elif n % 4 == 0:
		print(*ans, n // 2, n // 4, n // 4)
	else:
		print(*ans, n // 2 - 1, n // 2 - 1, 2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	n -= k - 3
	if n % 2 == 1:
		print(1, n // 2, n // 2, end=' ')
	elif n % 4 == 0:
		print(n // 2, n // 4, n // 4, end=' ')
	else:
		n -= 2
		print(2, n // 2, n // 2, end=' ')
	k -= 3
	while k > 0:
		print(1, end=' ')
		k -= 1
	print()


import math

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		s = ''
		n = n - (k - 3)
		s = '1 ' * (k - 3)
		if n % 2 == 1:
			s += '1 '
			s += str(n // 2) + ' '
			s += str(n // 2) + ' '
		elif n % 4 == 0:
			s += str(2 * (n // 4)) + ' '
			s += str(n // 4) + ' '
			s += str(n // 4) + ' '
		else:
			s += '2 '
			s += str((n - 2) // 2) + ' '
			s += str((n - 2) // 2) + ' '
		print(s)
main()


t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split()))
	oneCount = k - 3
	ans = [1] * oneCount
	n -= oneCount
	k = 3
	if n % 2 == 0:
		if n % 4 == 0:
			ans.extend([n // 2, n // 4, n // 4])
		else:
			ans.extend([n // 2 - 1, n // 2 - 1, 2])
	else:
		ans.extend([(n - 1) // 2, (n - 1) // 2, 1])
	print(*ans)


import sys
from math import log

def solve(n, k):
	ones = [str(1)] * (k - 3)
	n -= k - 3
	if 2 ** int(log(n, 2)) == n:
		return ' '.join(ones + [str(n // 2), str(n // 4), str(n // 4)])
	else:
		if n % 2 == 1:
			c = 1
			a = (n - 1) // 2
			b = a
			return ' '.join(ones + [str(a), str(b), str(c)])
		counter = 2
		while counter < n:
			if n % counter == 0:
				if n // counter % 2 == 1:
					a = counter
					b = counter * (n // counter - 1) // 2
					c = b
					return ' '.join(ones + [str(a), str(b), str(c)])
			counter += 2
	return None
t = int(sys.stdin.readline().strip())
ans = 0
for _ in range(t):
	line = sys.stdin.readline().strip()
	(n, k) = list(map(int, line.split()))
	print(solve(n, k))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print((b - 3) * '1 ', end='')
	a -= b - 3
	if a % 4 == 0:
		print(a // 2, a // 4, a // 4)
	elif a % 2 == 0:
		print(a // 2 - 1, a // 2 - 1, 2)
	else:
		print(a // 2, a // 2, 1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def intArr():
	return map(int, input().split())

def In():
	return int(input())

def func(n, k):
	if k > 3:
		return [1] * (k - 3) + func(n - k + 3, 3)
	if n % k == 0:
		return [n // k] * k
	if n % 4 == 0:
		return [n // 4, n // 2, n // 4]
	elif n % 2 == 0:
		return [2, n // 2 - 1, n // 2 - 1]
	else:
		return [1, n // 2, n // 2]

def main():
	for _ in range(In()):
		(n, k) = intArr()
		print(*func(n, k))
	return
main()


def answer():
	if n & 1:
		return [1] * (k - 3) + [n // 2, n // 2, 1]
	elif n // 2 & 1 == 0:
		return [1] * (k - 3) + [n // 2, n // 4, n // 4]
	else:
		return [1] * (k - 3) + [2, n // 2 - 1, n // 2 - 1]
for T in range(int(input())):
	(n, k) = map(int, input().split())
	n -= k - 3
	print(*answer())


import os, sys, math
from io import BytesIO, IOBase
read = lambda : map(int, input().split(' '))

def solve(n):
	if n % 2 == 1:
		a = int(n / 2 - 1 / 2)
		arr = [1, a, a]
	elif n % 4 == 0:
		a = int(n / 4)
		arr = [a, a, 2 * a]
	else:
		i = 1
		while n % 2 ** i == 0:
			i += 1
		i -= 1
		base = int(n / 2 ** i)
		mul = 2 ** i
		y = int(base / 2 - 1 / 2)
		arr = [mul, mul * y, mul * y]
	return arr

def pri(arr, n):
	for i in range(n):
		print(arr[i], end=' ')
	print()

def main():
	from math import log2
	for _ in range(int(input())):
		(n, k) = read()
		arr = solve(n - k + 3)
		ab = [1] * k
		(ab[0], ab[1], ab[2]) = (arr[0], arr[1], arr[2])
		pri(ab, k)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	n -= k - 3
	k = k - 3
	l = [1] * k
	if n % 2 == 0:
		n1 = n // 2
		if n1 % 2 != 0:
			re = [2, n1 - 1, n1 - 1]
		else:
			re = [n1 // 2, n1, n1 // 2]
	elif n % 2 != 0:
		n1 = n // 2
		re = [n // 2, n // 2, 1]
	print(*l, *re)


def func(n):
	if n % 2 != 0:
		lst = [1, n // 2, n // 2]
	elif n % 2 == 0 and n % 4 != 0:
		lst = [n // 2 - 1, n // 2 - 1, 2]
	else:
		lst = [n // 2, n // 4, n // 4]
	return lst

def func2():
	lst = func(n - k + 3)
	rem = k - 3
	lst += [1] * rem
	print(*lst)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	func2()


import sys

def input():
	return sys.stdin.readline().rstrip()

def input():
	return sys.stdin.readline().rstrip()

def slv_case3(n):
	p = n // 4
	if n % 4 == 0:
		return (p, p, 2 * p)
	elif n % 4 == 1:
		return (2 * p, 2 * p, 1)
	elif n % 4 == 2:
		return (2 * p, 2 * p, 2)
	else:
		return (2 * p + 1, 2 * p + 1, 1)
	return

def slv():
	(n, k) = map(int, input().split())
	if n % 2 == k % 2:
		ans = [1] * (k - 2) + [(n - k + 2) // 2] * 2
		print(*ans)
		return
	else:
		(a, b, c) = slv_case3(n - k + 3)
		ans = [1] * (k - 3) + [a, b, c]
		print(*ans)
		return

def main():
	t = int(input())
	for i in range(t):
		slv()
	return
main()


import sys
from random import *
from bisect import *
from heapq import *
pl = 1
from math import gcd, sqrt, ceil
from copy import *
sys.setrecursionlimit(10 ** 5)
if pl:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('outpt.txt', 'w')

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())
t = fi()

def lcm(a):
	g = a[0]
	for i in range(1, len(a)):
		g = g * a[i] // gcd(g, a[i])
	print(a, g)
	return g
while t > 0:
	t -= 1
	(n, k) = mi()
	for i in range(k - 3):
		print(1, end=' ')
	n -= k - 3
	for i in range(30):
		if n - 2 ** i > 0 and (n - 2 ** i) % 2 == 0:
			if (n - 2 ** i) // 2 % 2 ** i == 0:
				print((n - 2 ** i) // 2, (n - 2 ** i) // 2, 2 ** i)
				break
	else:
		print(n // 2, n // 4, n // 4)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	out = []
	for i in range(m - 3):
		out.append(1)
		n -= 1
	if n % 2 == 1:
		out.append(1)
		out.append(n // 2)
		out.append(n // 2)
		print(*out)
	elif n % 4 == 0:
		out.append(n // 2)
		out.append(n // 4)
		out.append(n // 4)
		print(*out)
	else:
		out.append(2)
		out.append(n // 2 - 1)
		out.append(n // 2 - 1)
		print(*out)


import sys
import math
import collections
input = sys.stdin.readline

def fn(n):
	if n % 2 == 1:
		return [n // 2, n // 2, 1]
	elif n // 2 % 2 == 1:
		return [n // 2 - 1, n // 2 - 1, 2]
	else:
		return [n // 2, n // 4, n // 4]
t = int(input())
for w in range(t):
	(n, k) = (int(i) for i in input().split())
	l = [1] * (k - 3) + fn(n - (k - 3))
	print(*l)


import sys
for _ in range(int(sys.stdin.readline())):
	(n, a) = map(int, sys.stdin.readline().split())
	ans = [1] * (a - 3)
	num = n - (a - 3)
	temp = []
	if num == 3:
		temp = [1, 1, 1]
	else:
		k = num // 4
		if num % 4 == 0:
			temp = [k, k, 2 * k]
		elif num % 4 == 1:
			temp = [2 * k, 2 * k, 1]
		elif num % 4 == 2:
			temp = [2 * k, 2 * k, 2]
		else:
			temp = [2 * k + 1, 2 * k + 1, 1]
	ans += temp
	print(*ans)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	ans = [1] * (k - 3)
	print(*ans, end=' ')
	n = n - (k - 3)
	l = n // 2
	if n % 2 != 0:
		print(1, n // 2, n // 2, end=' ')
	else:
		p = n // 2
		if p % 2 == 0:
			print(n // 2, n // 4, n // 4, end=' ')
		else:
			print(2, n // 2 - 1, n // 2 - 1, end=' ')
	print('')
	t = t - 1


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	(n, k) = INL()
	ANS = []
	for _ in range(k - 3):
		ANS.append(1)
	n = n - k + 3
	if n % 4 == 0:
		OPL(ANS + [n // 2, n // 4, n // 4])
	elif n % 4 == 1 or n % 4 == 3:
		OPL(ANS + [1, (n - 1) // 2, (n - 1) // 2])
	else:
		OPL(ANS + [2, (n - 2) // 2, (n - 2) // 2])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	n = n - (k - 3)
	rep = []
	if n % 2:
		rep = [(n - 1) // 2, (n - 1) // 2, 1]
	elif n == 4:
		rep = [1, 1, 2]
	else:
		v = n // 2 - 1
		if v % 2:
			rep = [n // 2, n // 4, n // 4]
		else:
			rep = [v, v, 2]
	rep += [1] * (k - 3)
	print(*rep)


def nr():
	return int(input())

def nrs():
	return [int(item) for item in input().split()]

def p(s):
	print(s, end='')
for _ in range(nr()):
	(n, k) = nrs()
	if k > 3:
		p('1 ' * (k - 3))
		n -= k - 3
	h = n // 2
	if n % 2 == 1:
		p(f'{h} {h} 1')
	elif h % 2 == 0:
		p(f'{h} {h // 2} {h // 2}')
	else:
		p(f'{h - 1} {h - 1} 2')
	print('')


def solve(n):
	if n % 2 == 1:
		return [1, n // 2, n // 2]
	if n % 4 == 0:
		return [n // 2, n // 4, n // 4]
	if n % 2 == 0:
		return [2, n // 2 - 1, n // 2 - 1]
t = int(input())
while t != 0:
	(n, k) = map(int, input().split(' '))
	print((k - 3) * '1 ', *solve(n - k + 3), sep=' ')
	t -= 1


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
for _ in range(L()[0]):
	(n, k) = L()
	A = [1] * (k - 3)
	n -= k - 3
	if n % 4 == 0:
		A += [n // 2, n // 4, n // 4]
	elif n % 2 == 0:
		A += [2, (n - 2) // 2, (n - 2) // 2]
	else:
		A += [1, (n - 1) // 2, (n - 1) // 2]
	print(*A)
endtime = time.time()


t = int(input())
while t > 0:
	t -= 1
	ip = input()
	(n, k) = (int(ip.split()[0]), int(ip.split()[1]))
	ans = []
	if k > 3:
		while k - 3 > 0:
			ans.append(1)
			k -= 1
			n -= 1
	if n % 2 == 1:
		temp = [n // 2, n // 2, 1]
		ans += temp
	elif n % 4 == 0:
		temp = [n // 2, n // 4, n // 4]
		ans += temp
	else:
		temp = [n // 2 - 1, n // 2 - 1, 2]
		ans += temp
	print(*ans)


t = int(input())
for T in range(t):
	(n, k) = list(map(int, input().split()))
	a = []
	x = k - 3
	for j in range(k - 3):
		print(1, end=' ')
	n = n - k + 3
	if n % 2 == 0 and n % 4 != 0:
		print(n // 2 - 1, n // 2 - 1, 2)
	if n % 4 == 0 and n % 2 == 0:
		print(n // 2, n // 4, n // 4)
	if n % 2 != 0:
		print(n // 2, n // 2, 1)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split())

def split_three(n):
	if n % 2 == 1:
		return [1, n // 2, n // 2]
	elif n % 4 == 2:
		return [2, n // 2 - 1, n // 2 - 1]
	else:
		return [n // 4, n // 4, n // 2]
t = read_int()
for case_num in range(t):
	(n, k) = read_ints()
	ans = [1] * (k - 3) + split_three(n - (k - 3))
	print(' '.join(map(str, ans)))


def find3(n):
	if n % 2 == 1:
		return (1, n // 2, n // 2)
	elif n % 4 == 2:
		return (2, n // 2 - 1, n // 2 - 1)
	else:
		return (n // 4, n // 4, n // 2)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(*[1] * (k - 3), *find3(n - k + 3))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	n -= m - 3
	if n % 2 == 1:
		print(n // 2, n // 2, 1, end=' ')
	elif n % 4 == 2:
		print(n // 2 - 1, n // 2 - 1, 2, end=' ')
	else:
		print(n // 2, n // 4, n // 4, end=' ')
	for i in range(m - 3):
		print(1, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [1] * (k - 3)
	n -= k - 3
	res = []
	if n & 1:
		res = [1, (n - 1) // 2, (n - 1) // 2]
	elif n % 4 == 0:
		res = [n // 4, n // 4, n // 2]
	else:
		res = [2, (n - 2) // 2, (n - 2) // 2]
	l = l + res
	print(*l)


def prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return True
	return False
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = []
	while k > 3:
		arr.append(1)
		n -= 1
		k -= 1
	if n % 3 == 0:
		arr += [n // 3, n // 3, n // 3]
		print(*arr)
	elif n % 3 == 1:
		if n % 2 == 1:
			arr += [n // 2, n // 2, 1]
			print(*arr)
		elif n // 2 % 2 == 0:
			val = n // 2
			arr += [val, val // 2, val // 2]
			print(*arr)
		else:
			val = n // 2 - 1
			arr += [val, val, n - (val + val)]
			print(*arr)
	elif n % 2 == 1:
		arr += [n // 2, n // 2, n - (n // 2 + n // 2)]
		print(*arr)
	elif n // 2 % 2 == 0:
		val = n // 2
		arr += [val, val // 2, val // 2]
		print(*arr)
	else:
		val = n // 2 - 1
		arr += [val, val, n - (val + val)]
		print(*arr)


n = int(input())
r = []
for i in range(n):
	t = input().split()
	r.append([int(t[0]), int(t[1])])
for i in r:
	if i[1] > 3:
		res = ''
		n = 0
		res = '1 ' * (i[1] - 3)
		t = i[0] - (i[1] - 3)
		if t % 4 == 0:
			print(f'{res}{int(t / 2)} {int(t / 4)} {int(t / 4)}')
		elif t % 2 == 0:
			print(f'{res}2 {int((t - 2) / 2)} {int((t - 2) / 2)}')
		else:
			print(f'{res}1 {int(t / 2)} {int(t / 2)}')
	else:
		t = i[0]
		if t % 4 == 0:
			print(f'{int(t / 2)} {int(t / 4)} {int(t / 4)}')
		elif t % 2 == 0:
			print(f'2 {int((t - 2) / 2)} {int((t - 2) / 2)}')
		else:
			print(f'1 {int(t / 2)} {int(t / 2)}')


def solve(n):
	if n % 3 == 0:
		return [n // 3] * 3
	if n % 2 == 1:
		return [1] + [(n - 1) // 2] * 2
	if n % 4 == 2:
		return [2] + [(n - 2) // 2] * 2
	assert n % 4 == 0
	return [n // 4] * 2 + [n // 2]
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	c = k - 3
	print(*[1] * c + solve(n - c))


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from bisect import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def AI():
	return map(int, open(0).read().split())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	n = random.randint(1, N)
	a = RLI(n, 0, n - 1)
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]
show_flg = False
show_flg = True
ans = 0

def sol3(n):
	if n % 4 == 0:
		p = n // 4
		ans = [p, p, 2 * p]
	elif n % 2 == 0:
		p = (n - 2) // 4
		ans = [2, 2 * p, 2 * p]
	else:
		ans = [1, n // 2, n // 2]
	return ans
for _ in range(I()):
	ans = 0
	(n, k) = LI()
	if k == 3:
		ans = sol3(n)
	else:
		x = k - 3
		ans = sol3(n - x) + [1] * x
	print(*ans)


def sol(n):
	if n % 2 == 0:
		if n // 2 % 2 == 0:
			print(n // 4, n // 4, n // 2)
		else:
			print(2, 2 * (n // 4), 2 * (n // 4))
	else:
		print(1, n // 2, n // 2)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print('1 ' * (k - 3), end='')
	sol(n - k + 3)


from sys import stdin
input = lambda : stdin.readline().strip()
lin = lambda : list(map(int, input().split()))
iin = lambda : int(input())
main = lambda : map(int, input().split())
from math import ceil, sqrt, factorial, log
from collections import deque
from bisect import bisect_left
mod = 998244353
mod = 1000000007

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	while a % b != 0:
		(a, b) = (b, a % b)
	return b

def moduloinverse(a):
	return pow(a, mod - 2, mod)

def solve(we):
	(n, k) = main()
	d = []
	for i in range(k - 3):
		d.append(1)
	n = n - sum(d)
	z = []
	if n == 3:
		z = [1, 1, 1]
	elif n == 4:
		z = [1, 1, 2]
	elif n % 2 != 0:
		z = [n // 2, n // 2, 1]
	else:
		t = n // 2
		if t % 2 == 0:
			if n % 3 == 0:
				z = [n // 3, n // 3, n // 3]
			elif n % 4 == 0:
				z = [n // 2, t // 2, t // 2]
		else:
			z = [t - 1, t - 1, 2]
	print(*d, *z)
qwe = iin()
for _ in range(qwe):
	solve(_ + 1)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
from math import log10, log2, ceil, factorial as f, gcd

def f(n):
	if n % 2:
		l = [1, n // 2, n // 2]
	elif n % 4 == 0:
		l = [n // 2, n // 4, n // 4]
	else:
		l = [(n - 1) // 2, (n - 1) // 2, 2]
	return l
for _ in range(t()):
	(n, k) = ll()
	p = (k - 3) * [1] + f(n - (k - 3))
	print(*p)


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	n -= k - 3
	ans = []
	if n == 4:
		ans = [1, 1, 2]
	elif n % 2 == 0:
		if n // 2 % 2 == 0:
			ans = [n // 2, n // 4, n // 4]
		else:
			ans = [n // 2 - 1, n // 2 - 1, 2]
	else:
		ans = [1, n // 2, n // 2]
	ans.extend([1 for i in range(k - 3)])
	print(' '.join((str(i) for i in ans)))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [1] * (k - 3)
	n -= k - 3
	if not n % 4:
		print(*a, n // 2, n // 4, n // 4)
	elif not n % 2:
		print(*a, n // 2 - 1, n // 2 - 1, 2)
	else:
		print(*a, n // 2, n // 2, 1)


def new(x):
	if x % 2:
		res = [x // 2, x // 2, 1]
	elif (x - 2) % 4 == 0:
		res = [(x - 2) // 2, (x - 2) // 2, 2]
	else:
		res = [x // 2, x // 4, x // 4]
	return res
t = int(input())
for i in range(t):
	(n, k) = [int(j) for j in input().split()]
	z = n - (k - 3)
	print(' '.join((str(j) for j in new(z) + [1 for q in range(k - 3)])))


def process(n):
	d = 1
	while n % 2 == 0:
		d *= 2
		n = n // 2
	if n > 1:
		return [d, d * (n - 1) // 2, d * (n - 1) // 2]
	elif d >= 2:
		return [d // 2, d // 4, d // 4]
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	if k == 3:
		answer = process(n)
		print(' '.join(map(str, answer)))
	else:
		answer = []
		while k > 3:
			answer.append(1)
			n -= 1
			k -= 1
		answer = answer + process(n)
		print(' '.join(map(str, answer)))


from collections import Counter
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	for i in range(k - 3):
		print(1, end=' ')
	n = n - (k - 3)
	k = 3
	if n % 2 == 0:
		q = n // 2
		if q % 2 != 0:
			print(2, q - 1, q - 1)
		else:
			print(q // 2, q // 2, q)
	else:
		q = n // 2
		w = n - q * 2
		print(w, q, q)


import os, sys, heapq as h, time
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import bisect_left, bisect_right
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def getInt():
	return int(input())

def getStrs():
	return input().split()

def getInts():
	return list(map(int, input().split()))

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 10 ** 9 + 7

def solve():
	(N, K) = getInts()
	ans = [1] * (K - 3)
	N -= K - 3
	if N % 2 == 1:
		ans2 = [1, N // 2, N // 2]
	elif N % 4 == 0:
		ans2 = [N // 4, N // 4, N // 2]
	else:
		ans2 = [(N - 2) // 2, (N - 2) // 2, 2]
	print(*ans + ans2)
	return
for _ in range(getInt()):
	solve()


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	(n, k) = rns()

	def solve(n):
		if n == 4:
			return [1, 1, 2]
		elif n % 2 == 1:
			return [1, n // 2, n // 2]
		return list(map(lambda x: 2 * x, solve(n // 2)))
	ans = (k - 3) * [1] + solve(n - k + 3)
	print(*ans)


def ss(n):
	for i in range(1, 1 + n ** 0.5):
		if n % i == 0:
			return n // i
	return 1
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = [1 for _ in range(k)]
	n -= k - 3
	if n % 2 == 0:
		if n % 4 == 0:
			ans[0] = n // 2
			ans[1] = n // 4
			ans[2] = n // 4
		else:
			ans[0] = 2
			ans[1] = n // 2 - 1
			ans[2] = n // 2 - 1
	else:
		ans[0] = n // 2
		ans[1] = n // 2
	print(*ans)


import sys, os.path
if os.path.exists('amz42.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
test_cases = int(input())
for _ in range(test_cases):
	(n, k) = [int(x) for x in input().split(' ')]
	for i in range(k - 3):
		print(1, end=' ')
		n -= 1
	if n & 1:
		print(1, n // 2, n // 2)
	elif n // 2 & 1:
		print(n // 2 - 1, n // 2 - 1, 2)
	else:
		print(n // 2, n // 4, n // 4)


def func(n):
	rem = n % 2
	if rem == 1:
		ans = [n // 2, n // 2, 1]
	elif n % 4 == 0:
		ans = [n // 2, n // 4, n // 4]
	else:
		a = n // 2 - 1
		ans = [a, a, n - 2 * a]
	return ans
t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	ans = [1] * k
	n -= k - 3
	(ans[0], ans[1], ans[2]) = func(n)
	print(*ans)


def solve():
	(n, k) = map(int, input().split(' '))
	ones = k - 3
	for i in range(ones):
		print(1, end=' ')
	n -= ones
	if n % 3 == 0:
		print(n // 3, n // 3, n // 3)
	elif n == 4:
		print(1, 1, 2)
	elif n & 1 == 1:
		print(n >> 1, n >> 1, 1)
	elif n & 3 == 0:
		print(n >> 1, n >> 2, n >> 2)
	elif n & 1 == 0:
		test = n - 2 >> 1
		if test & 1 == 0:
			print(test, test, 2)
		else:
			print(n - 4 >> 1, n - 4 >> 1, 4)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k > 3:
		for i in range(k - 3):
			print(1, end=' ')
		n = n - k + 3
		if n % 2 != 0:
			print(str(n // 2) + ' ' + str(n // 2) + ' ' + str(1))
		elif n % 2 == 0 and n % 4 == 0:
			print(str(n // 2) + ' ' + str(n // 4) + ' ' + str(n // 4))
		else:
			print(str(n // 2 - 1) + ' ' + str(n // 2 - 1) + ' ' + str(2))
	elif n % 2 != 0:
		print(str(n // 2) + ' ' + str(n // 2) + ' ' + str(1))
	elif n % 2 == 0 and n % 4 == 0:
		print(str(n // 2) + ' ' + str(n // 4) + ' ' + str(n // 4))
	else:
		print(str(n // 2 - 1) + ' ' + str(n // 2 - 1) + ' ' + str(2))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = []
	k -= 3
	n -= k
	if n == 4:
		print(1, 1, 2)
	else:
		if n % 2 == 1:
			print(1, n // 2, n // 2, end=' ')
		else:
			p = n // 2
			if p % 2 == 1:
				p -= 1
				print(p, p, 2, end=' ')
			else:
				print(p, p // 2, p // 2, end=' ')
		while k > 0:
			k -= 1
			print(1, end=' ')
		print()


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ans = [1] * (k - 3)
	n -= k - 3
	if n % 2 == 0:
		d = n // 2
		if d & 1:
			ans.extend([d - 1, d - 1, 2])
		else:
			ans.extend([d, d // 2, d // 2])
	else:
		ans.extend([n // 2, n // 2, 1])
	print(*ans)


import sys
input = sys.stdin.buffer.readline

def solve_3(N):
	for i in range(32):
		if 1 << i == N:
			return [1 << i - 2, 1 << i - 2, 1 << i - 1]
	for i in range(32):
		if N & 1 << i:
			N -= 1 << i
			return [1 << i, N >> 1, N >> 1]
for t in range(int(input())):
	(N, K) = map(int, input().split())
	ANS = []
	if K > 3:
		ANS = [1] * (K - 3)
		N -= K - 3
		K = 3
	if N == 3:
		ANS.append(1)
		ANS.append(1)
		ANS.append(1)
	elif N == 4:
		ANS.append(1)
		ANS.append(1)
		ANS.append(2)
	elif N == 5:
		ANS.append(1)
		ANS.append(2)
		ANS.append(2)
	else:
		X = solve_3(N)
		for i in range(3):
			ANS.append(X[i])
	print(*ANS)


import collections
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())

	def dfs(n):
		if n == 4:
			return (1, 1, 2)
		if n % 2 == 1:
			return (1, n // 2, n // 2)
		else:
			(r1, r2, r3) = dfs(n // 2)
			return (r1 * 2, r2 * 2, r3 * 2)
	(r1, r2, r3) = dfs(n - (k - 3))
	res = [1 for _ in range(k - 3)]
	res.append(r1)
	res.append(r2)
	res.append(r3)
	print(*res, sep=' ')


import math

def easy_version(n, k):
	if k == 3:
		if n % 2 == 1:
			q = n // 2
			return [1, q, q]
		else:
			q = n // 4
			if n % 4 == 0:
				return [q, q, 2 * q]
			else:
				return [2, 2 * q, 2 * q]
	elif n == k:
		return [1 for _ in range(n)]

def general_version(n, k):
	if n == k or k == 3:
		return easy_version(n, k)
	else:
		(q, r) = (n // k, n % k)
		if (q + 1) * q <= n / 2:
			ans = [q for _ in range(k)]
			for i in range(r):
				ans[i] += 1
			return ans
		elif n % 2 == 1:
			ans = general_version(n - 1, k - 1)
			ans.append(1)
			return ans
		else:
			ans = general_version(n // 2, k)
			return [2 * ai for ai in ans]
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	print(*general_version(n, k))


import sys

def solve(n):
	if n % 2 == 1:
		return (1, n // 2, n // 2)
	s = 0
	t = n
	while not t % 2:
		t //= 2
		s += 1
	if t == 1:
		return (2 ** (s - 1), 2 ** (s - 2), 2 ** (s - 2))
	return (2 ** s, 2 ** s * (t // 2), 2 ** s * (t // 2))
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = list(solve(n - k + 3)) + [1] * (k - 3)
	print(' '.join((str(x) for x in ans)))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ns = n
	n = n - k + 3
	if n % 2 == 1:
		ans = [1, (n - 1) // 2, (n - 1) // 2]
	elif n % 2 == 0 and n % 4 != 0:
		ans = [2, (n - 2) // 2, (n - 2) // 2]
	elif n % 4 == 0:
		ans = [n // 2, n // 4, n // 4]
	ins = ans
	for i in range(k - 3):
		ans.append(1)
	for i in range(k):
		print(int(ans[i]), end=' ')


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data

def calc(s, a, b, c):
	bq = []
	for i in range(len(s)):
		if s[i] == 'A':
			bq.append(a)
		elif s[i] == 'B':
			bq.append(b)
		else:
			bq.append(c)
	c = 0
	for i in range(len(bq)):
		if bq[i] == '(':
			c += 1
		else:
			c -= 1
		if c < 0:
			return [False, []]
	if c == 0:
		return [True, bq]
	else:
		return [False, []]

def main():
	t = int(input())
	for _ in range(t):
		(n, pp) = map(int, input().split())
		pp -= 3
		n -= pp
		if n == 4:
			print(1, 1, 2)
		else:
			if n % 2 != 0:
				print(1, n // 2, n // 2, end=' ')
			else:
				p = n // 2
				if p % 2 != 0:
					p -= 1
					print(p, p, 2, end=' ')
				else:
					print(p, p // 2, p // 2, end=' ')
			while pp > 0:
				print(1, end=' ')
				pp -= 1
			print()
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	c = []
	while k > 3:
		c.append(1)
		k -= 1
		n -= 1
	if n % 2 != 0:
		for i in range(2):
			c.append(n // 2)
		c.append(1)
	elif n % 4 == 0:
		for i in range(2):
			c.append(n // 4)
		c.append(n // 2)
	else:
		for i in range(2):
			c.append((n - 1) // 2)
		c.append(2)
	print(*c, sep=' ')


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	(n, k) = ip()
	n = n - k + 3
	if n & 1:
		x = [1, n // 2, n // 2]
	elif n % 4 == 0:
		x = [n // 2, n // 4, n // 4]
	else:
		x = [2, (n - 2) // 2, (n - 2) // 2]
	x += [1] * (k - 3)
	print(*x)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = [1] * (k - 3)
	n -= k - 3
	if n % 2 != 0:
		x.append(1)
		x.append(n // 2)
		x.append(n // 2)
	elif n % 4 == 0:
		x.append(n // 2)
		x.append(n // 4)
		x.append(n // 4)
	else:
		x.append(n // 2 - 1)
		x.append(n // 2 - 1)
		x.append(2)
	print(*x)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = []
	if (n - k + 3) % 2 == 0:
		ans.append((n - k + 3) // 2)
		ans.append((n - k + 3) // 2)
		if (n - k + 3) % 4 == 0:
			ans.append(ans[0] // 2)
			ans.append(ans[0] // 2)
			ans = ans[1:]
		else:
			ans[0] -= 1
			ans[1] -= 1
			ans.append(2)
	else:
		ans.append(1)
		ans.append((n - k + 2) // 2)
		ans.append((n - k + 2) // 2)
	ans2 = [1] * (k - 3) + ans
	print(*ans2, sep=' ')


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000000 + 7
mod2 = 998244353
for _ in range(I()):
	(n, k) = M()

	def solve(n):
		a = []
		if n % 2 == 1:
			a = [n // 2, n // 2, 1]
		elif n % 4 != 0:
			a = [n // 2 - 1, n // 2 - 1, 2]
		else:
			a = [n // 4, n // 4, n // 2]
		return a
	print(*[1] * (k - 3) + solve(n - k + 3))


def LCM(n):
	result = []
	if n % 4 == 0:
		result.append(n // 2)
		result.append(n // 4)
		result.append(n // 4)
	elif n % 4 == 2:
		n = n - 2
		result.append(2)
		result.append(n // 2)
		result.append(n // 2)
	elif n % 4 == 1 or n % 4 == 3:
		n = n - 1
		result.append(1)
		result.append(n // 2)
		result.append(n // 2)
	return result
for i in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	out = []
	if k == 3:
		out = LCM(n)
		print(*out)
	else:
		for i in range(k - 3):
			out.append(1)
			n -= 1
		out = out + LCM(n)
		print(*out)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	n -= k - 3
	c = 1
	while n % 2 == 0 and n > 4:
		c *= 2
		n //= 2
	x = n // 2 * c
	if n == 4:
		x = c
	print(n // 2 * c, x, c, *[1] * (k - 3))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ans = []
	if k > 3:
		for i in range(k - 3):
			ans.append(1)
		n -= k - 3
	if n % 2 == 0:
		if n / 2 % 2 == 0:
			ans.append(n // 2)
			ans.append(n // 4)
			ans.append(n // 4)
		else:
			ans.append(n // 2 - 1)
			ans.append(n // 2 - 1)
			ans.append(2)
	if n % 2 == 1:
		ans.append((n - 1) // 2)
		ans.append((n - 1) // 2)
		ans.append(1)
	print(*ans)


ans = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = k - 3
	n -= k - 3
	if n % 4 == 0:
		(a, b, c) = (n // 2, n // 4, n // 4)
	elif n % 2 == 0:
		(a, b, c) = ((n - 2) // 2, (n - 2) // 2, 2)
	else:
		(a, b, c) = (n // 2, n // 2, 1)
	ans.append(str(a) + ' ' + str(b) + ' ' + str(c) + ' ' + '1 ' * x)
print('\n'.join(ans))


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def gcd(a, b):
	if b <= 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(input())):
	(n, k) = aj()
	Ans = []
	n = n - (k - 3)
	for i in range(k - 3):
		print(1, end=' ')
	l = n // 2
	if n % 3 == 0:
		print(n // 3, n // 3, n // 3)
	else:
		for i in range(l, 0, -1):
			a = i
			b = i
			c = n - 2 * i
			if c > a:
				break
			if c != 0 and lcm(a, c) <= l:
				print(a, b, c)
				break
			if i % 2 == 0:
				a = i
				b = i // 2
				c = n - (a + b)
				if c != 0 and lcm(b, lcm(a, c)) <= l:
					print(a, b, c)
					break
			if i % 3 == 0:
				a = i
				b = i // 3
				c = n - (a + b)
				if c != 0 and lcm(b, lcm(a, c)) <= l:
					print(a, b, c)
					break


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	loop = max(0, k - 3)
	for i in range(loop):
		print(1, end=' ')
		n -= 1
	if int(n / 2) == n / 2:
		half = int(n / 2)
		if half % 2 == 0:
			print(half, int(half / 2), int(half / 2))
		else:
			print(half - 1, half - 1, 2)
	else:
		print(int(n / 2), int(n / 2), 1)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	ans = []
	if n % 2 != 0 and n // 2 % 2 == 0:
		if k == 3:
			ans = [n // 2, n // 2, 1]
		elif k == 4:
			ans = [n // 2, n // 2 // 2, n // 2 // 2, 1]
		elif k == 5:
			ans = [n // 2 // 2, n // 2 // 2, n // 2 // 2, n // 2 // 2, 1]
		else:
			ans = [n // 2 - 2, n // 2 - 2, 1, 2, 2]
			for i in range(6, k + 1):
				if ans[-3] == 2:
					ans[-3] = 1
					ans[-2] = 1
					ans.append(2)
				elif ans[-2] == 2:
					ans[-2] = 1
					ans[-1] = 1
					ans.append(2)
				elif ans[-1] == 2:
					ans[-1] = 1
					ans.append(1)
				elif ans[0] % 2 == 1:
					ans[0] -= 1
					ans[1] -= 1
					ans.append(2)
				else:
					ans[0] -= 2
					ans[1] -= 2
					ans.append(2)
					ans[-2] = 2
					ans[-3] = 2
	elif n % 2 == 0 and (n // 2 - 1) % 2 != 0:
		if k == 3:
			ans = [n // 2, n // 2 // 2, n // 2 // 2]
		elif k == 4:
			ans = [n // 2 // 2, n // 2 // 2, n // 2 // 2, n // 2 // 2]
		elif k == 5:
			ans = [n // 2 - 2, n // 2 - 2, 1, 1, 2]
		else:
			ans = [n // 2 - 2, n // 2 - 2, 1, 1, 2]
			for i in range(6, k + 1):
				if ans[-3] == 2:
					ans[-3] = 1
					ans[-2] = 1
					ans.append(2)
				elif ans[-2] == 2:
					ans[-2] = 1
					ans[-1] = 1
					ans.append(2)
				elif ans[-1] == 2:
					ans[-1] = 1
					ans.append(1)
				elif ans[0] % 2 == 1:
					ans[0] -= 1
					ans[1] -= 1
					ans.append(2)
				else:
					ans[0] -= 2
					ans[1] -= 2
					ans.append(2)
					ans[-2] = 2
					ans[-3] = 2
	else:
		if n % 2 == 0:
			ans.append(n // 2 - 1)
			ans.append(n // 2 - 1)
			ans.append(2)
		else:
			ans.append(n // 2)
			ans.append(n // 2)
			ans.append(1)
		for i in range(4, k + 1):
			if ans[-3] == 2:
				ans[-3] = 1
				ans[-2] = 1
				ans.append(2)
			elif ans[-2] == 2:
				ans[-2] = 1
				ans[-1] = 1
				ans.append(2)
			elif ans[-1] == 2:
				ans[-1] = 1
				ans.append(1)
			elif ans[0] % 2 == 1:
				ans[0] -= 1
				ans[1] -= 1
				ans.append(2)
			else:
				ans[0] -= 2
				ans[1] -= 2
				ans.append(2)
				ans[-2] = 2
				ans[-3] = 2
	print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	b = [1] * (k - 3)
	n -= k - 3
	if n % 3 == 0:
		b.append(n // 3)
		b.append(n // 3)
		b.append(n // 3)
	elif n % 2 != 0:
		b.append(1)
		b.append((n - 1) // 2)
		b.append((n - 1) // 2)
	else:
		a = n // 2
		if a % 2 == 0:
			a -= 1
			while max(a, n - 2 * a) % min(a, n - 2 * a) != 0:
				a -= 1
		else:
			a -= 1
		b.append(a)
		b.append(a)
		b.append(n - 2 * a)
	print(*b)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192
from collections import defaultdict

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve(n):
	if n % 2:
		z = [1, (n - 1) // 2, (n - 1) // 2]
	elif n / 2 % 2:
		z = [2, (n - 2) // 2, (n - 2) // 2]
	else:
		z = [n // 2, n // 2 // 2, n // 2 // 2]
	return z
for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	ans = []
	for i in range(k - 3):
		ans.append(1)
	n = n - (k - 3)
	ans += solve(n)
	print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print('1 ' * n)
		continue
	n = n - (k - 3)
	if n % 2:
		a = (n - 1) // 2
		print(a, a, 1, end=' ')
	else:
		a = n // 2
		if a % 2:
			print(a - 1, a - 1, 2)
		else:
			h = a // 2
			print(h, h, a, end=' ')
	j = k - 3
	while j > 0:
		print(1, end=' ')
		j -= 1
	print()


n = int(input())
for i in range(0, n):
	o = input().rstrip().split(' ')
	N = int(o[0])
	K = int(o[1])
	if K > 3:
		A = K - 3
		for j in range(0, A):
			print(1, end=' ')
		N -= A
	if N % 2 == 0:
		A = N // 2
		if A % 2 == 0:
			print(A, A // 2, A // 2)
		else:
			print(A - 1, A - 1, 2)
	else:
		A = N // 2
		print(A, A, 1)


import math

def lcm(a):
	lcm = a[0]
	for i in range(1, len(a)):
		lcm = lcm * a[i] // math.gcd(lcm, a[i])
	return lcm
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	z = [1] * (k - 3)
	n = n - (k - 3)
	if n % 2 != 0:
		print(*z, 1, math.floor(n / 2), math.floor(n / 2))
	elif n % 2 == 0 and n % 4 == 0:
		print(*z, n // 2, n // 4, n // 4)
	elif n % 2 == 0 and n % 4 != 0:
		print(*z, 2, (n - 2) // 2, (n - 2) // 2)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	rest = k - 3
	newN = n - rest
	if newN % 2 == 1:
		print(1, newN // 2, newN // 2, ' '.join(map(str, [1] * rest)))
	elif newN % 2 == 0:
		print(newN // 2 - 1, newN // 2 - 1, 2, ' '.join(map(str, [1] * rest))) if newN % 4 != 0 else print(newN // 2, newN // 4, newN // 4, ' '.join(map(str, [1] * rest)))


import sys
input = sys.stdin.readline
t = int(input())
pow2 = [1]
for i in range(35):
	pow2.append(2 * pow2[-1])
for _ in range(t):
	(n, k) = map(int, input().split())
	x = k - 3
	n -= x
	if n % 2:
		ans = [1, n // 2, n // 2]
	elif not n % 4:
		ans = [n // 4, n // 4, n // 2]
	else:
		ans = [2, (n - 2) // 2, (n - 2) // 2]
	for _ in range(x):
		ans.append(1)
	print(*ans)


from io import BytesIO, IOBase
import sys, os
inpl = lambda : list(map(int, input().split()))
inpm = lambda : map(int, input().split())
inpi = lambda : int(input())
inp = lambda : input()
(rev, ra, l) = (reversed, range, len)
P = print
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys, operator, math, operator
from collections import Counter
tc = inpi()
while tc:
	(n, k) = inpm()
	for i in ra(k - 3):
		P(1, end=' ')
	n -= k - 3
	if n % 2 == 1:
		P(int(n // 2), int(n // 2), 1)
	else:
		n /= 2
		if n % 2 == 1:
			P(int(n - 1), int(n - 1), 2)
		else:
			P(int(n), int(n // 2), int(n // 2))
	tc -= 1


nn = int(input())
for _ in range(nn):
	(n, k) = [int(s) for s in input().split()]
	n1 = n - k + 3
	power = 0
	while n1 % 2 == 0:
		n1 /= 2
		power += 1
	n = n - k + 3
	if n1 == 1:
		print(' '.join(['1'] * (k - 3) + [str(n // 4), str(n // 4), str(n // 2)]))
	else:
		print(' '.join(['1'] * (k - 3) + [str(2 ** power), str((n - 2 ** power) // 2), str((n - 2 ** power) // 2)]))


for t in range(int(input())):
	(n, k) = list(map(int, input().split(' ')))
	op = []
	for i in range(0, k - 3):
		op.append(1)
	n = n - (k - 3)
	if n % 2 == 1:
		(op0, op1, op2) = (1, n // 2, n // 2)
	elif n % 2 == 0 and n % 4 != 0:
		(op0, op1, op2) = (2, n // 2 - 1, n // 2 - 1)
	elif n % 4 == 0:
		(op0, op1, op2) = (n // 4, n // 4, n // 2)
	print(*op, op0, op1, op2)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = k - 3
	n -= a
	res = []
	if n % 2 == 1:
		res.append(1)
		res.append((n - 1) // 2)
		res.append((n - 1) // 2)
	else:
		cnt = 0
		while n % 2 == 0 and n >= 3:
			n = n // 2
			cnt += 1
		if n == 2:
			cnt -= 1
			res.append(2 ** cnt * 1)
			res.append(2 ** cnt * 1)
			res.append(2 ** cnt * 2)
		else:
			res.append(2 ** cnt * 1)
			res.append(2 ** cnt * (n - 1) // 2)
			res.append(2 ** cnt * (n - 1) // 2)
	for i in range(a):
		res.append(1)
	print(*res)


import collections
t = int(input())

def solve():
	[n, k] = list(map(int, input().strip().split()))
	for x in range(k - 3):
		print(1, end=' ')
	n -= k - 3
	if n % 3 == 0:
		print(n // 3, n // 3, n // 3)
	elif n % 3 == 1:
		if n % 2 == 1:
			print(1, (n - 1) // 2, (n - 1) // 2)
		elif n % 2 == 0:
			if n % 4 == 0:
				print(n // 2, n // 4, n // 4)
			else:
				print(2, (n - 2) // 2, (n - 2) // 2)
	elif n % 2 == 0:
		if n % 4 == 0:
			print(n // 2, n // 4, n // 4)
		else:
			print(2, (n - 2) // 2, (n - 2) // 2)
	else:
		print(1, (n - 1) // 2, (n - 1) // 2)
for tokens in range(t):
	solve()


import math, sys
from collections import defaultdict, Counter, deque
from bisect import bisect_left, bisect_right
from itertools import permutations
INF = float('inf')
MOD = int(1000000000.0) + 7
MAX = int(1000000.0) + 5

def solve():
	(n, k) = vars()
	ans = [1] * (k - 3)
	n -= k - 3
	if n % 2:
		ans += [n // 2, n // 2, 1]
	else:
		d = n // 2
		if d % 2:
			ans += [d - 1, d - 1, 2]
		else:
			ans += [d, d // 2, d // 2]
	print(*ans)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)
primes = [1 for i in range(MAX)]

def sieve():
	global primes
	primes[0] = primes[1] = 0
	i = 2
	while i <= MAX ** 0.5:
		j = i * i
		while primes[i] and j < MAX:
			if j % i == 0:
				primes[j] = 0
			j += i
		i += 1

def vars():
	return map(int, input().split())

def array():
	return list(vars())
main()


import sys
r = sys.stdin.readline

def k3(x):
	k = 3
	if x % 2:
		return [1, (x - 1) // 2, (x - 1) // 2]
	elif x % 4 == 0:
		return [x // 2, x // 4, x // 4]
	else:
		return [2, (x - 2) // 2, (x - 2) // 2]
t = int(r())
for tests in range(t):
	(n, k) = map(int, r().split())
	arr = []
	for i in range(k - 3):
		arr.append(1)
	arr += k3(n - len(arr))
	print(*arr)


import sys

def getInput():
	return sys.stdin.readline().strip()

def getInt():
	return int(getInput())

def getInts():
	return map(int, getInput().split())

def getArray():
	return list(getInts())
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	li = [1] * (k - 3)
	sumv = sum(li)
	n -= sumv
	if n % 4 == 0:
		li.extend([n // 2, n // 4, n // 4])
	elif n % 2 == 0:
		li.extend([n // 2 - 1, n // 2 - 1, 2])
	else:
		li.extend([n // 2, n // 2, 1])
	print(*li)


t = int(input())

def solve(n):
	res = []
	if n % 2 == 1:
		res.append(1)
		res.append(n // 2)
		res.append(n // 2)
	elif n % 4 == 0:
		res.append(n // 4)
		res.append(n // 2)
		res.append(n // 4)
	else:
		res.append(2)
		res.append(n // 2 - 1)
		res.append(n // 2 - 1)
	return res
for i in range(t):
	(n, k) = map(int, input().split())
	res = []
	for j in range(k - 3):
		res.append('1')
		n -= 1
	for u in solve(n):
		res.append(str(u))
	print(' '.join(res))


import sys, functools, collections, bisect, math, heapq
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	n -= k
	n += 3
	ans = ['1'] * (k - 3)
	if n % 2:
		ans = ans + [str(n // 2), str(n // 2), '1']
	else:
		x = n // 2
		if x % 2:
			ans.append(str(x - 1))
			ans.append(str(x - 1))
			ans.append('2')
		else:
			ans.append(str(x))
			ans.append(str(x // 2))
			ans.append(str(x // 2))
	print(' '.join(ans))


import sys
from collections import *
from heapq import *
import math
import bisect

def input():
	return sys.stdin.readline()
for t in range(int(input())):
	(n, k) = map(int, input().split())
	for _ in range(k - 3):
		print(1, end=' ')
		n -= 1
		k -= 1
	if n % 2 == 1:
		print(1, n // 2, n // 2)
	elif n % 4 == 0:
		print(n // 2, n // 4, n // 4)
	else:
		print(2, n // 2 - 1, n // 2 - 1)


n = int(input())
for i in range(n):
	(num, k) = map(int, input().split())
	m = k - 3
	num = num - m
	if num % 2 == 0:
		if num % 4 == 0:
			print(num // 2, num // 4, num // 4, m * '1 ')
		else:
			print(2, (num - 2) // 2, (num - 2) // 2, m * '1 ')
	else:
		print(1, (num - 1) // 2, (num - 1) // 2, m * '1 ')


for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	oneCnt = k - 3
	ans = [1 for i in range(k - 3)]
	rem = n - k + 3
	if rem & 1:
		ans += [1, rem // 2, rem // 2]
	elif rem % 4:
		ans += [2, rem // 2 - 1, rem // 2 - 1]
	else:
		ans += [rem // 2, rem // 4, rem // 4]
	print(*ans)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	f = []
	for j in range(k - 3):
		n -= 1
		f.append(1)
	if n % 2 != 0:
		f += [1, n // 2, n // 2]
	elif n % 4 == 0:
		f += [n // 2, n // 4, n // 4]
	else:
		f += [(n - 2) // 2, (n - 2) // 2, 2]
	print(*f)


import sys
from collections import defaultdict as dd
input = sys.stdin.readline

def op(n):
	if n % 2:
		return [n // 2, n // 2, 1]
	elif n % 4 == 0:
		return [n // 2, n // 4, n // 4]
	else:
		return [n // 2 - 1, n // 2 - 1, 2]
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k == 3:
		b = op(n)
		print(*b)
	else:
		b = op(n - (k - 3))
		b += [1] * (k - 3)
		print(*b)


import sys
from math import gcd, ceil, sqrt
INF = float('inf')
MOD = 998244353
mod = 10 ** 9 + 7
from collections import Counter, defaultdict as df
from functools import reduce

def counter(l):
	return dict(Counter(l))

def so(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def rev(l):
	return list(reversed(l))

def ini():
	return int(sys.stdin.readline())

def inp():
	return map(int, sys.stdin.readline().strip().split())

def li():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()

def inputm(n, m):
	return [li() for i in range(m)]

def cc(n, k=3):
	if n % 3 == 0:
		print(*[int(n / 3)] * 3)
	elif n & 1:
		print(*[int(n / 2)] * 2, 1)
	elif n % 4 == 0:
		print(int(n / 2), int(n / 4), int(n / 4))
	else:
		print(*[int(n / 2) - 1] * 2, 2)
for i in range(ini()):
	(n, k) = inp()
	print(*[1] * (k - 3), end=' ')
	cc(n - k + 3)


def nr():
	return int(input())

def nrs():
	return [int(item) for item in input().split()]
for _ in range(nr()):
	(n, k) = nrs()
	r = []
	if k > 3:
		r = [1] * (k - 3)
		n -= k - 3
	h = n // 2
	if n % 2 == 1:
		r += [h, h, 1]
	elif h % 2 == 0:
		r += [h, h // 2, h // 2]
	else:
		r += [h - 1, h - 1, 2]
	print(*r)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = [1] * (k - 3)
	n = n - k + 3
	if n & n - 1:
		x = str(bin(n))[2:][::-1]
		m = 2 ** x.find('1')
		n = n // m
		l2 = [m, n // 2 * m, n // 2 * m]
	else:
		l2 = [n // 2, n // 4, n // 4]
	print(*l1 + l2)


import math
import sys
import collections
import bisect
import heapq

def lcm(a, b):
	return a * b // math.gcd(a, b)
testcases = int(sys.stdin.readline())
for _ in range(testcases):
	arr = list(map(int, sys.stdin.readline().strip().split()))
	n = arr[0]
	k = arr[1]
	res = []
	nn = n
	if k > 3:
		res = [1] * (k - 3)
		nn = n - (k - 3)
	d = nn // 2
	while 1:
		if d * 2 >= nn:
			d -= 1
		elif lcm(d, nn - 2 * d) <= n // 2:
			break
		else:
			d -= 1
	res.append(d)
	res.append(d)
	res.append(nn - 2 * d)
	for i in res:
		print(i, end=' ')
	print('')


T = int(input())

def solve(N, K):
	if K == 3:
		if N % 2 == 1:
			return [(N - 1) // 2, (N - 1) // 2, 1]
		elif N % 4 == 2:
			return [(N - 2) // 2, (N - 2) // 2, 2]
		elif N % 4 == 0:
			return [N // 2, N // 4, N // 4]
	return solve(N - (K - 3), 3) + [1] * (K - 3)
for _ in range(T):
	(N, K) = map(int, input().split())
	print(' '.join(map(str, solve(N, K))))


for _ in range(int(input())):
	(n, k) = tuple(map(int, input().split()))
	c = []
	for _ in range(k - 3):
		c += [1]
	n = n - (k - 3)
	if n % 2 != 0:
		c += [1, n // 2, n // 2]
	elif n % 2 == 0 and n % 4 != 0:
		c += [n // 2 - 1, n // 2 - 1, 2]
	elif n % 4 == 0:
		c += [n // 2, n // 2 // 2, n // 2 // 2]
	print(' '.join(map(str, c)))


def solve(n) -> list:
	if n & 1:
		return [1, n // 2, n // 2]
	elif n // 2 & 1:
		return [n // 2 - 1, n // 2 - 1, 2]
	else:
		return [n // 2, n // 4, n // 4]
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	a = [1] * (k - 3)
	n = n - (k - 3)
	print(*a, ' '.join((str(x) for x in solve(n))))


from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()

def solve(v):
	if v == 0:
		return ()
	if v & 1:
		return (1, v // 2, v // 2)
	elif v % 4 == 0:
		return (v // 2, v // 4, v // 4)
	else:
		return (2, (v - 2) // 2, (v - 2) // 2)
for _ in range(t):
	(n, k) = gil()
	ans = []
	for _ in range(k - 3):
		ans.append('1 ')
	for v in solve(n - k + 3):
		ans.append(str(v) + ' ')
	print(''.join(ans))


t = int(input())
for i in range(0, t):
	(n, m) = map(int, input().split())
	ans = [1] * (m - 3)
	n = n - (m - 3)
	if n % 3 == 0:
		p = [n // 3, n // 3, n // 3]
	elif n % 2 == 1:
		p = [1, n // 2, n // 2]
	elif n // 2 % 2 == 0:
		p = [n // 2, n // 4, n // 4]
	else:
		p = [n // 2 - 1, n // 2 - 1, 2]
	ans = ans + p
	print(*ans)


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	n = n - (k - 3)
	if n % 3 == 0:
		s = int(n / 3)
		ans = [s, s, s]
	if n % 3 != 0 and n % 4 == 0:
		ans = [int(n / 2), int(n / 4), int(n / 4)]
	if n % 3 != 0 and n % 4 != 0 and (n % 2 == 0):
		ans = [2, int((n - 2) / 2), int((n - 2) / 2)]
	if n % 3 != 0 and n % 2 != 0:
		ans = [1, int((n - 1) / 2), int((n - 1) / 2)]
	print(*ans + (k - 3) * [1])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	for i in range(k - 3):
		print(1, end=' ')
	n = n - (k - 3)
	p = n // 2
	if n % 2 == 0:
		if p % 2 == 0:
			print(p // 2, p // 2, p)
			continue
		print(2, p - 1, p - 1)
	else:
		print(1, p, p)


t = int(input())
result = []
for i in range(t):
	(n, k) = [int(x) for x in input().strip().split(' ')]
	res = ''
	if k > 3:
		res += ' '.join(['1'] * (k - 3)) + ' '
		n -= k - 3
	if n % 2 == 1:
		result.append(f'{res}{n // 2} {n // 2} 1')
	else:
		half = n // 2
		if half % 2 == 0:
			result.append(f'{res}{half} {half // 2} {half // 2}')
		else:
			result.append(f'{res}{half - 1} {half - 1} 2')
for line in result:
	print(line)


import math
t = int(input())
while t != 0:
	(n, k) = list(map(int, input().split()))
	ans = None
	t -= 1
	ans = [1] * (k - 3)
	n = n - (k - 3)
	if n % 2 == 1:
		ans.extend([n // 2, n // 2, 1])
	elif n / 2 % 2 == 1:
		ans.extend([(n - 1) // 2, (n - 1) // 2, 2])
	else:
		ans.extend([n // 2, n // 4, n // 4])
	print(' '.join(map(str, ans)))


from io import BytesIO, IOBase
import sys
import math
import os
from collections import defaultdict
from math import ceil
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def mint():
	return map(int, input().split())

def mfloat():
	return map(float, input().split())

def three(n):
	if n % 4 == 0:
		return [n // 2, n // 4, n // 4]
	if n % 2 == 0:
		return [n // 2 - 1, n // 2 - 1, 2]
	return [n // 2, n // 2, 1]

def solve():
	(n, k) = mint()
	arr = [1] * (k - 3)
	print(*arr + three(n - k + 3))

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


def processing():
	(n, k) = [int(x) for x in input().split()]
	if k > 3:
		for i in range(k - 3):
			print('1', end=' ')
		n = n - (k - 3)
		k = 3
	if n % 2 == 1:
		print(1, n // 2, n // 2, sep=' ', end='\n')
	elif n % 4 == 0:
		print(n // 2, n // 2 // 2, n // 2 // 2, sep=' ', end='\n')
	else:
		print(2, (n - 2) // 2, (n - 2) // 2, sep=' ', end='\n')
t = int(input())
for i in range(t):
	processing()


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_(n, k):
	tail = k - 3
	n -= tail
	if n % 3 == 0:
		return [n // 3, n // 3, n // 3] + [1] * tail
	if n % 2 == 1:
		return [n // 2, n // 2, 1] + [1] * tail
	if n % 4 == 0:
		return [n // 4, n // 4, n // 2] + [1] * tail
	factor = 1
	while n % 2 == 0:
		factor *= 2
		n = n // 2
	return [n // 2 * factor, n // 2 * factor, factor] + [1] * tail
for case_num in range(int(input())):
	(n, k) = list(map(int, input().split()))
	res = solve(n, k)
	print(*res)


import sys
from sys import stdout
import bisect as bi
import math
from collections import defaultdict as dd
from types import GeneratorType
import random
input = sys.stdin.readline
mo = 10 ** 9 + 7
MOD = 998244353

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input().strip()

def inin():
	return int(input())

def solve(n, k):
	if n % 2:
		return [n // 2, n // 2, 1]
	elif n % 4 == 0:
		return [n // 2, n // 4, n // 4]
	else:
		return [n // 2 - 1, n // 2 - 1, 2]
for _ in range(inin()):
	(n, k) = cin()
	ans = []
	(newn, newk) = (n - (k - 3), 3)
	print(*solve(newn, newk) + [1] * (k - 3))

def msb(n):
	n |= n >> 1
	n |= n >> 2
	n |= n >> 4
	n |= n >> 8
	n |= n >> 16
	n |= n >> 32
	n |= n >> 64
	return n - (n >> 1)

def pref(a, n, f):
	pre = [0] * n
	if f == 0:
		pre[0] = a[0]
		for i in range(1, n):
			pre[i] = a[i] + pre[i - 1]
	else:
		pre[-1] = a[-1]
		for i in range(n - 2, -1, -1):
			pre[i] = pre[i + 1] + a[i]
	return pre

def kadane(A):
	maxSoFar = maxEndingHere = start = end = beg = 0
	for i in range(len(A)):
		maxEndingHere = maxEndingHere + A[i]
		if maxEndingHere < 0:
			maxEndingHere = 0
			beg = i + 1
		if maxSoFar < maxEndingHere:
			maxSoFar = maxEndingHere
			start = beg
			end = i
	return (maxSoFar, start, end)

def modFact(n, p):
	if n < 0:
		return 0
	if n >= p:
		return 0
	result = 1
	for i in range(1, n + 1):
		result = result * i % p
	return result

def ncr(n, r, p):
	if n < r or n < 0:
		return 0
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc


from math import floor

def lcm(n, k):
	x = k - 3
	y = n - k + 3
	if y % 2 != 0:
		return [1, floor(y / 2), floor(y / 2)] + list([1] * x)
	elif y % 2 == 0 and y % 4 != 0:
		return [y // 2 - 1, y // 2 - 1, 2] + list([1] * x)
	else:
		return [y // 2, y // 4, y // 4] + list([1] * x)
t = int(input())
answer = []
for _ in range(t):
	(n, k) = map(int, input().split())
	answer.append(lcm(n, k))
for i in answer:
	print(*i)


import sys
import math
import bisect
import collections
input = sys.stdin.readline

def inp():
	return int(input())

def inplist():
	return list(map(int, input().split()))

def inpstrlist():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def printlist(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def solve(n):
	if n % 2 == 0:
		if n % 4 == 0:
			return [n // 2, n // 4, n // 4]
		else:
			x = n // 2 - 1
			return [x, x, 2]
	else:
		x = n // 2
		return [x, x, 1]
t = int(input())
for _ in range(t):
	(n, k) = invr()
	arr = solve(n - k + 3)
	for i in range(k):
		if i >= 3:
			arr.append(1)
	print(*arr)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [1] * (k - 3)
	n -= k - 3
	if n % 2 == 1:
		print(*a, n // 2, n // 2, 1)
	elif n % 4 == 0:
		print(*a, n // 2, n // 4, n // 4)
	else:
		print(*a, (n - 2) // 2, (n - 2) // 2, 2)


import sys
import math
import random
input = sys.stdin.readline
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	if (n - k + 2) % 2 == 0:
		for i in range(k - 2):
			print(1, end=' ')
		print((n - k + 2) // 2, (n - k + 2) // 2)
	elif (n - k + 1) // 2 % 2 == 0:
		for i in range(k - 3):
			print(1, end=' ')
		print(2, end=' ')
		print((n - k + 1) // 2, (n - k + 1) // 2)
	else:
		for i in range(k - 3):
			print(1, end=' ')
		print((n - k + 3) // 2, (n - k + 3) // 4, (n - k + 3) // 4)
	t -= 1


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = [1] * (k - 3)
	n = n - k + 3
	if n % 2 == 1:
		ans += [1] + [(n - 1) // 2] * 2
	elif n % 2 == 0 and n % 4 != 0:
		ans += [2] + [(n - 2) // 2] * 2
	else:
		ans += [n // 2] + [n // 4] * 2
	print(*ans)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	x = [1] * (m - 3)
	n = n - (m - 3)
	if n % 4 == 0:
		x.append(n // 2)
		x.append(n // 4)
		x.append(n // 4)
	elif n % 4 == 1 or n % 4 == 3:
		x.append(1)
		x.append((n - 1) // 2)
		x.append((n - 1) // 2)
	else:
		x.append(2)
		x.append((n - 2) // 2)
		x.append((n - 2) // 2)
	print(*x)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	carry = 0
	out = []
	if k > 3:
		out += [1] * (k - 3)
		n -= k - 3
	if n & 1:
		n -= 1
		carry = 1
		(a, b, c) = (n // 2, n // 2, 1)
		out += [a, b, c]
		print(*out)
		continue
	elif n % 4 != 0:
		n -= 2
		carry += 2
		(a, b, c) = (n // 2, n // 2, 2)
		out += [a, b, c]
		print(*out)
		continue
	a = n // 2
	n = a
	b = a // 2
	c = a // 2
	out += [a, b, c]
	print(*out)
	continue