Chef recently learned about concept of periodicity of strings. A string is said to have a period P, if P divides N and for each i, the i-th of character of the string is same as i-Pth character (provided it exists), e.g. "abab" has a period P = 2, It also has a period of P = 4, but it doesn't have a period of 1 or 3.
Chef wants to construct a string of length N that is a palindrome and has a period P. It's guaranteed that N is divisible by P. This string can only contain character 'a' or 'b'. Chef doesn't like the strings that contain all a's or all b's.
Given the values of N, P, can you construct one such palindromic string that Chef likes? If it's impossible to do so, output "impossible" (without quotes)

-----Input-----
The first line of the input contains an integer T denoting the number of test cases.
The only line of each test case contains two space separated integers N, P.

-----Output-----
For each test case, output a single line containing the answer of the problem, i.e. the valid string if it exists otherwise "impossible"  (without quotes). If there are more than possible answers, you can output any.

-----Constraints-----
- 1 ≤ T ≤ 20
- 1 ≤ P, N ≤ 105

-----Subtasks-----
- Subtask #1 (25 points) : P = N
- Subtask #2 (75 points) : No additional constraints

-----Example-----
Input
5
3 1
2 2
3 3
4 4
6 3

Output
impossible
impossible
aba
abba
abaaba

-----Explanation-----
Example 1: The only strings possible are either aaa or bbb, which Chef doesn't like. So, the answer is impossible.
Example 2: There are four possible strings, aa, ab, ba, bb. Only aa and bb are palindromic, but Chef doesn't like these strings. Hence, the answer is impossible.
Example 4: The string abba is a palindrome and has a period of 4.
Example 5: The string abaaba is a palindrome and has a period of length 3.

Difficulty: MEDIUM
Tags: String algorithms

Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
t = int(input())
for i in range(t):
	(n, p) = input().split()
	l = ''
	l = l + 'a'
	for i in range(1, int(p) - 1):
		l = l + 'b'
	l = l + 'a'
	if int(p) > 2:
		m = int(n) / int(p)
		print(l * int(m))
	else:
		print('impossible')


t = int(input())
for x in range(t):
	(n, p) = map(int, input().split())
	if p < 3:
		print('impossible')
	else:
		d = n // p
		if p % 2 == 0:
			st = 'a' * (p // 2 - 1) + 'b'
			st = st + st[::-1]
		else:
			st = 'a' * (p // 2)
			st = st + 'b' + st
		print(st * d)


t = int(input().strip())
for j in range(0, t):
	(n, p) = input().strip().split(' ')
	(n, p) = [int(n), int(p)]
	s = ''
	if p == 1:
		s = s + 'a'
	if p == 2:
		s = s + 'ab'
	if p == 3:
		s = s + 'aba'
	if p >= 4:
		for k in range(0, p - 4):
			s = s + 'a'
		s = 'ab' + s + 'ba'
	t = s
	for i in range(1, int(n / p)):
		t = t + s
	if t == t[::-1] and n != t.count('a'):
		print(t)
	else:
		print('impossible')


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	if n <= 2:
		print('impossible')
	elif p == 1 or p == 2:
		print('impossible')
	elif n % p != 0:
		print('impossible')
	else:
		m = n // p
		if p % 2 == 1:
			s = 'a'
			p -= 1
			p //= 2
			s += 'ba' * p
			print(s * m)
		else:
			s = 'a'
			p -= 2
			s += 'b' * p
			s += 'a'
			print(s * m)


case = int(input())
while case > 0:
	l = input().split(' ')
	n = int(l[0])
	p = int(l[1])
	ps = ''
	fs = 'impossible'
	if n % p == 0 and p > 2 and (n >= 0) and (p >= 0):
		if p % 2 == 0:
			ps = (p // 2 - 1) * 'a' + 'bb' + (p // 2 - 1) * 'a'
		else:
			ps = p // 2 * 'a' + 'b' + p // 2 * 'a'
		fs = n // p * ps
	print(fs)
	case -= 1


w = int(input())
for i1 in range(0, w):
	(N, P) = map(int, input().split())
	if P == 1:
		print('impossible')
		continue
	elif P == 2:
		print('impossible')
		continue
	elif N < P:
		print('impossible')
		continue
	else:
		S = ''
		if P % 2 != 0:
			X = ''
			for I4 in range(P // 2):
				X += 'a'
			S = X + 'b' + X
		else:
			X = ''
			for I3 in range(P // 2 - 1):
				X += 'a'
			S = X + 'bb' + X
		Z = N // P
		X = S
		for i2 in range(Z - 1):
			S += X
		print(S)


t = int(input())
A = ['a']
B = ['b']
C = ['a']
n = [[int(i) for i in input().split()] for i in range(t)]
for i in n:
	x = i[0]
	y = i[1]
	if x % y == 0 and y != 1 and (y != 2):
		w = ''.join((A + B * (y - 2) + C) * int(x / y))
		print(w)
	else:
		print('impossible')


try:
	t = int(input())
	while t > 0:
		(n, p) = [int(i) for i in input().split()]
		if p <= 2:
			print('impossible')
		else:
			s = ''
			for i in range(1, n // p + 1):
				s += 'a'
				for j in range(2, p):
					s += 'b'
				s += 'a'
			print(s)
		t = t - 1
except:
	pass


import sys

def fx():
	(n, p) = map(int, sys.stdin.readline().split())
	if p == 1 or p == 2:
		print('impossible')
	else:
		s = []
		s.append('a')
		m = p - 2
		while m:
			s.append('b')
			m -= 1
		s.append('a')
		l = int(n / p)
		for j in range(l):
			for k in range(len(s)):
				sys.stdout.write(s[k])
		print()
t = int(sys.stdin.readline())
for _ in range(t):
	fx()


t = int(input())
for z in range(t):
	(size, hemant) = map(int, input().split())
	if hemant == 1 or size % hemant != 0 or hemant > size or (size == 2) or (hemant == 2):
		print('impossible')
	else:
		final = size * [0]
		if size == hemant:
			final[size - 1] = 'a'
			final[0] = 'a'
			for j in range(1, size - 1):
				final[j] = 'b'
		else:
			factor = int(size / hemant)
			phla = 0
			second = hemant - 1
			for j in range(factor):
				final[second] = 'a'
				final[phla] = 'a'
				phla += hemant
				second += hemant
			for i in range(size):
				if final[i] == 0:
					final[i] = 'b'
		str = ''.join(final)
		print(str)


T = int(input())
for i in range(T):
	(N, P) = [int(t) for t in input().split()]
	if P == 1 or P == 2 or N % P != 0:
		print('impossible')
	else:
		print(('a' + 'b' * (P - 2) + 'a') * (N // P))


import math

def palin(n, p):
	if p == 1 or n == 2:
		return (False, '?')
	if p % 2 != 0:
		f = math.ceil(p / 2)
		g = 'ab' * int(f)
		g = g[:-1]
		h = int(n / p) * g
		if 'a' not in h or 'b' not in h:
			return (False, '?')
		else:
			return (True, h)
	else:
		f = p - 2
		o = 'a' + 'b' * int(f) + 'a'
		l = int(n / p) * o
		if 'a' not in l or 'b' not in l:
			return (False, '?')
		else:
			return (True, l)
t = int(input())
while t > 0:
	(n, p) = input().split()
	n = int(n)
	p = int(p)
	(b, x) = palin(n, p)
	if b:
		print(x)
	else:
		print('impossible')
	t = t - 1


t = int(input())
for i in range(t):
	(n, p) = map(int, input().split(' '))
	if p == 1 or n == 1 or n == 2 or (p == 2):
		print('impossible')
		continue
	string = 'a' * p
	if p % 2 == 0:
		idx = int(p / 2)
		string = string[0:idx - 1] + 'bb' + string[idx + 1:]
	else:
		idx = int(p / 2)
		string = string[0:idx] + 'b' + string[idx + 1:]
	string2 = string * int(n / p)
	print(string2)


n = int(input())
for i in range(n):
	x = [int(j) for j in input().split()]
	if int(x[1]) != 1 and int(x[1]) != 2:
		print(('a' + 'b' * (int(x[1]) - 2) + 'a') * (int(x[0]) // int(x[1])))
	else:
		print('impossible')


def genPal(n):
	if n % 2 == 0:
		return 'a' * (n // 2 - 1) + 'bb' + 'a' * (n // 2 - 1)
	else:
		return 'a' * (n // 2) + 'b' + 'a' * (n // 2)

def palindrome(num):
	if num[::-1] == num:
		return True
	else:
		return False
for _ in range(int(input())):
	(n, p) = map(int, input().split())
	if p == 1 or p == 2:
		print('impossible')
		continue
	s = genPal(p) * (n // p)
	if palindrome(s):
		print(s)
	else:
		print('impossible')


z = []
t = int(input())
for i in range(t):
	x = [int(s) for s in input().split()]
	I = x[0] // x[1]
	if (x[1] <= 2 or x[0] <= 2) or x[0] % x[1] != 0:
		o = 'impossible'
		z.append(o)
	elif x[0] % 2 != 0 and x[1] % 2 != 0:
		o = ('a' + 'b' * (x[1] - 2) + 'a') * I
		z.append(o)
	elif x[0] == x[1] and (x[0] > 2 and x[1] > 2):
		w = 'a' + 'b' * (x[0] - 2) + 'a'
		z.append(w)
	elif x[0] != x[1] and x[0] % 2 != 0:
		print('impossible')
	elif x[0] % 2 == 0 and x[1] > x[0] / 2:
		o = 'impossible'
		z.append(o)
	elif x[0] % 2 == 0 and x[1] == x[0] / 2:
		o = ('a' + 'b' * (x[1] - 2) + 'a') * I
		z.append(o)
	elif x[0] % 2 == 0 and x[1] % 2 != 0:
		if x[0] % x[1] == 0:
			o = ('a' + 'b' * (x[1] - 2) + 'a') * (x[0] // x[1])
			z.append(o)
		elif x[0] % x[1] != 0:
			o = 'impossible'
			z.append(o)
	elif x[0] % 2 == 0 and x[1] % 2 == 0 and (x[1] < x[0] / 2):
		if I > 2:
			e = ('a' + 'b' * (x[1] - 2) + 'a') * I
			z.append(e)
		elif I == 2:
			o = 'impossible'
			z.append(o)
for i in z:
	print(i)


for _ in range(0, int(input())):
	(n, p) = map(int, input().split())
	strr = 'aba'
	x = n // p
	if n < 3 or p <= 2:
		print('impossible')
	elif n == p:
		while n - 3 > 0:
			strr = strr[:2] + 'b' + strr[2:]
			n -= 1
		print(strr)
	else:
		sttr = ''
		while p - 3 > 0:
			strr = strr[:2] + 'b' + strr[2:]
			p -= 1
		while x > 0:
			sttr = sttr[0:len(sttr)] + strr[0:len(strr)]
			x -= 1
		print(sttr)


cases = int(input())
for t in range(cases):
	(n, p) = list(map(int, input().split()))
	gen3 = 'aba'
	gen2 = 'ab'

	def getans():
		if n == 1 or p == 1 or p == 2:
			return 'impossible'
		return generate(p) * (n // p)

	def generate(p):
		if p == 2:
			return gen2
		if p == 3:
			return gen3
		s = generate(p // 2)
		if p % 2:
			s = s + 'a' + s[::-1]
		else:
			s = s + s[::-1]
		return s
	print(getans())


t = int(input())
for i in range(t):
	x = input().split()
	n = int(x[0])
	p = int(x[1])
	if p == 1 or p == 2:
		print('impossible')
	elif n == 1 or n == 2:
		print('impossible')
	else:
		if p % 2 == 0:
			s = 'a' * ((p - 2) // 2) + 'bb' + 'a' * ((p - 2) // 2)
			s = s * (n // p)
		else:
			s = 'a' * ((p - 1) // 2) + 'b' + 'a' * ((p - 1) // 2)
			s = s * (n // p)
		print(s)


for _ in range(int(input())):
	(N, P) = map(int, input().split())
	if P < 3 or N < 3:
		print('impossible')
		continue
	print(('a' + (P - 2) * 'b' + 'a') * (N // P))


T = int(input())
for i in range(T):
	N = [int(x) for x in input().split()]
	if N[0] % N[1] != 0:
		print('impossible')
	if N[1] == 1 or N[1] == 2:
		print('impossible')
	else:
		k = ('a' + 'b' * (N[1] - 2) + 'a') * (N[0] // N[1])
		print(k)


t = int(input())
while t > 0:
	t -= 1
	(n, p) = [int(x) for x in input().split()]
	if p <= 2:
		print('impossible')
		continue
	else:
		s = 'a' + 'b' * (p - 2) + 'a'
		s = s * int(n / p)
		print(s)


T = int(input())

def pattern(period):
	out = ['a', 'a']
	for i in range(1, int(period / 2)):
		if out[i - 1] == 'a':
			current = 'b'
		else:
			current = 'a'
		out.insert(i, current)
		out.insert(len(out) - i, current)
	if period % 2 != 0:
		x = int(period / 2)
		out.insert(x, 'a' if out[x - 1] == 'b' else 'b')
	return ''.join(out)
for i in range(0, T):
	(N, P) = map(int, input().split(' '))
	if P == 1:
		print('impossible', end='')
	elif P == 2:
		print('impossible', end='')
	else:
		for j in range(0, int(N / P)):
			print(pattern(P), end='')
	print('')


T = int(input())
for k in range(T):
	(N, P) = [int(s) for s in input().split()]
	if P <= 2:
		print('impossible')
	else:
		lis = ['a']
		for i in range(1, P - 1):
			lis.append('b')
		lis.append('a')
		s = ''.join(lis)
		s_full = str(s * int(N / P))
		if s_full[:] == s_full[::-1]:
			print(s_full)
		else:
			print('impossible')
		lis[:] = []


for t in range(int(input())):
	list1 = input().split()
	N = int(list1[0])
	P = int(list1[1])
	if P == 1 or P == 2:
		print('impossible')
	elif P % 2 == 0:
		k = (int(P / 2) - 1) * 'a' + 'bb' + (int(P / 2) - 1) * 'a'
		g = int(N / P) * k
		print(g)
	elif P % 2 == 1:
		k = int((P - 1) / 2) * 'a' + 'b' + int((P - 1) / 2) * 'a'
		g = int(N / P) * k
		print(g)


T = int(input())
for i in range(T):
	NP = [int(x) for x in input().split()]
	N = NP[0]
	P = NP[1]
	if N % P == 0:
		if P >= 3:
			print(('a' + 'b' * (P - 2) + 'a') * (N // P))
		else:
			print('impossible')
	else:
		print('impossible')


def R_omar_(Length_Str, Period):
	if Period <= 2:
		print('impossible')
	elif Length_Str % Period != 0:
		print('impossible')
	else:
		print(('a' + 'b' * (Period - 2) + 'a') * (Length_Str // Period))
T = int(input())
for i in range(T):
	s = [int(x) for x in input().split()]
	Length_Str = s[0]
	Period = s[1]
	R_omar_(Length_Str, Period)


def perpalin(n, p):
	if p == 1 or p == 2:
		return 'impossible'
	if n % p != 0:
		return 'impossible'
	s = [0] * p
	if p % 2 == 0:
		iter = p // 2
	else:
		iter = p // 2 + 1
	for i in range(iter):
		if i % 2 == 0:
			s[i] = 'a'
			s[p - i - 1] = 'a'
		else:
			s[i] = 'b'
			s[p - i - 1] = 'b'
	return s * (n // p)
t = input().strip()
t = int(t)
res = []
for x in range(t):
	(n, p) = map(int, input().strip().split())
	res.append(perpalin(n, p))
for k in res:
	print(''.join((str(i) for i in k)))


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	if p == 1 or p == 2:
		print('impossible')
		continue
	if p % 3 == 0:
		print(n // 3 * 'aba')
	if p % 3 == 1:
		if p // 3 % 2 == 0:
			print(n // p * (p // 3 // 2 * 'aba' + 'a' + p // 3 // 2 * 'aba'))
		else:
			print(n // p * (p // 3 // 2 * 'aba' + 'abba' + p // 3 // 2 * 'aba'))
	if p % 3 == 2:
		if p // 3 % 2 == 0:
			print(n // p * (p // 3 // 2 * 'aba' + 'bb' + p // 3 // 2 * 'aba'))
		else:
			print(n // p * (p // 3 // 2 * 'aba' + 'abbba' + p // 3 // 2 * 'aba'))


t = input()
for i in range(int(t)):
	(n, p) = input().split()
	n = int(n)
	p = int(p)
	s = []
	if n - p <= 1 and p % 2 == 0:
		for i in range(1, int(n / 2 + 1), 1):
			if i % 2 != 0:
				s.append('a')
			else:
				s.append('b')
		s = ''.join(s)
		d = s[::-1]
		s = s + d
	elif n - p <= 1 and p % 2 != 0:
		for i in range(1, n + 1, 1):
			if i % 2 != 0:
				s.append('a')
			else:
				s.append('b')
		s = ''.join(s)
	elif p % 2 == 0:
		l = int(n / p)
		for i in range(1, int(p / 2 + 1), 1):
			if i % 2 != 0:
				s.append('a')
			else:
				s.append('b')
		s = ''.join(s)
		x = s[::-1]
		s = s + x
		s = s * l
	else:
		for i in range(1, p + 1, 1):
			if i % 2 != 0:
				s.append('a')
			else:
				s.append('b')
		for i in range(p, n, 1):
			s.append(s[i - p])
		s = ''.join(s)
	if s[::-1] == s and n % p == 0 and (len(set(s)) != 1):
		print(s)
	else:
		print('impossible')


t = int(input())
while t > 0:
	t = t - 1
	(n, p) = map(int, input().split())
	str = ''
	if p == 1:
		str = 'impossible'
	elif n == p:
		if n == p == 2:
			str = 'impossible'
		else:
			b = n - 2
			str = 'a' + 'b' * b + 'a'
	else:
		x = n // p
		if p % 2 != 0:
			flag = 0
			while len(str) < p:
				if flag == 0:
					str = str + 'a'
					flag = 1
				elif flag == 1:
					str = str + 'b'
					flag = 0
			str = str * x
		if p % 2 == 0:
			if p == 2:
				str = 'impossible'
			else:
				str_four = 'abba'
				str = str_four
				flag = 1
				while len(str) < p:
					if flag == 0:
						str = str[:len(str) // 2] + 'bb' + str[len(str) // 2:]
						flag = 1
					elif flag == 1:
						str = str[:len(str) // 2] + 'aa' + str[len(str) // 2:]
						flag = 0
				str = str * x
	print(str)


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	a = []
	ans = 0
	if n % p != 0 or p == 1 or p == 2:
		ans += 1
	if n == p:
		a = ['a'] * n
		if n % 2 == 0:
			a[n // 2] = 'b'
			a[n // 2 - 1] = 'b'
		else:
			a[n // 2] = 'b'
	elif p % 3 == 0:
		k = n // 3
		for i in range(k):
			a.append('aba')
	elif p % 4 == 0:
		k = n // 4
		for i in range(k):
			a.append('abba')
	else:
		a = ['a'] * n
		if p % 2 == 0:
			for i in range(n // p):
				a[p // 2 + i * p] = 'b'
				a[p // 2 + i * p - 1] = 'b'
		else:
			for i in range(n // p):
				a[p // 2 + i * p] = 'b'
	if ans > 0:
		print('impossible')
	else:
		print(''.join(a))


for i in range(int(input())):
	a = input().split()
	l = []
	if int(a[1]) == 1 or int(a[1]) == 2:
		print('impossible')
	if int(a[1]) % 2 == 1 and int(a[1]) > 2:
		for i in range(int(a[1])):
			l.append('a')
		for i in range(1, int(a[1]), 2):
			l[i] = 'b'
		s = ''.join(l)
		print(s * (int(a[0]) // int(a[1])))
	if int(a[1]) % 2 == 0 and int(a[1]) > 2:
		for i in range(int(a[1])):
			l.append('a')
		l[int(a[1]) // 2 - 1] = 'b'
		l[int(a[1]) // 2] = 'b'
		s = ''.join(l)
		print(s * (int(a[0]) // int(a[1])))


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	if p == 1 or p == 2 or n % p != 0:
		print('impossible')
	else:
		s = ['0'] * p
		l = 0
		r = p - 1
		c = 'a'
		while l <= r:
			s[l] = s[r] = c
			l += 1
			r -= 1
			c = 'a' if c == 'b' else 'b'
		s = ''.join(s)
		print(s * (n // p))


testcase = int(input())
answer = []
for i in range(testcase):
	t = [int(s) for s in input().split()]
	pat = ''
	if t[1] == 1 or t[1] == 2:
		answer.append('impossible')
	elif t[1] > 2:
		for j in range(t[1]):
			if j == 0 or j == t[1] - 1:
				pat += 'a'
			else:
				pat += 'b'
		pat *= int(t[0] / t[1])
		if pat == pat[::-1]:
			answer.append(pat)
		else:
			answer.append('impossible')
for i in range(testcase):
	print(answer[i])


T = int(input())
k = []
for i in range(T):
	k.append(input())
for i in range(len(k)):
	s = k[i].split()
	a = int(s[0])
	b = int(s[1])
	if b == 1 or b == 2:
		print('impossible')
	else:
		c = 'a' + 'b' * (b - 2) + 'a'
		print(c * (a // b))


a = int(input())
k = ''
for i in range(a):
	b = [int(i) for i in input().split()]
	if b[1] == 1 and b[0] > 1:
		print('impossible')
	elif b[1] == 1 and b[0] == 1:
		print('impossible')
	elif b[1] == 2:
		print('impossible')
	elif b[0] == b[1] and b[0] != 2 and (b[1] != 2):
		s = 'a'
		for i in range(b[0] - 2):
			s = s + 'b'
		s = s + 'a'
		print(s)
	elif b[0] != b[1] and b[0] % b[1] == 0 and (b[1] > 2):
		s = 'a'
		for i in range(b[1] - 2):
			s = s + 'b'
		s = s + 'a'
		for i in range(b[0] // b[1]):
			k = k + s
		print(k)
		k = ''


t = int(input())
for i in range(t):
	(n, p) = map(int, input().split())
	if p == 1 or p == 2:
		print('impossible')
	else:
		s = ''
		if p % 2 == 0:
			s = 'a' + 'b' * (p - 2) + 'a'
			s = s * (n // p)
		else:
			s = 'a' * (p // 2) + 'b' + 'a' * (p // 2)
			s = s * (n // p)
		print(s)


for i in range(int(input())):
	(n, p) = [int(x) for x in input().split()]
	if p == 1 or (n == 2 and p == 2) or p == 2 or (n % p != 0):
		print('impossible')
	elif n == p:
		print('a' + 'b' * (n - 2) + 'a')
	else:
		print(('a' + 'b' * (p - 2) + 'a') * (n // p))


t = int(input())
for i in range(t):
	(n, p) = map(int, input().split(' ', 2))
	if n % p != 0:
		print('impossible')
	elif p % 2 != 0:
		if p == 1 and n >= 1:
			print('impossible')
			continue
		s = ''
		for j in range(p):
			if j % 2 == 0:
				s += 'a'
			else:
				s += 'b'
		for j in range(n // p):
			print(s, end='')
		print()
	else:
		l = p
		if p == 2:
			print('impossible')
		elif l // 2 % 2 == 0:
			s = 'a'
			for j in range(p - 2):
				s += 'b'
			s += 'a'
			for j in range(n // p):
				print(s, end='')
			print()
		elif l // 2 % 2 != 0:
			s = 'a'
			for j in range(p - 2):
				s += 'b'
			s += 'a'
			for j in range(n // p):
				print(s, end='')
			print()
		elif p == n:
			s = ''
			for j in range(p // 2):
				if j % 2 == 0:
					s += 'a'
				else:
					s += 'b'
			for j in range(2):
				print(s, end='')
			print()


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	answer = ''
	if n == 1 or n == 2 or p == 1:
		print('impossible')
	elif n == p:
		answer += 'a'
		for i in range(n - 2):
			answer += 'b'
		answer += 'a'
		print(answer)
	elif p != n and p > 2:
		a = int(n / p)
		answer += 'a'
		for i in range(p - 2):
			answer += 'b'
		answer += 'a'
		t = answer
		for i in range(a - 1):
			answer += t
		print(answer)
	else:
		print('impossible')


Number_of_test_cases = int(input())
for s in range(Number_of_test_cases):
	X = []
	Y = []
	(N, P) = input().split()
	m = int(N) // int(P)
	if int(P) == 2 or int(P) == 1:
		print('impossible')
	elif int(P) == 3:
		Y = Y + ['a', 'b', 'a'] * m
		print(''.join(Y))
	else:
		X = X + ['a', 'b']
		X = X + ['a'] * (int(P) - 4)
		X = X + ['b', 'a']
		Y = Y + X * m
		print(''.join(Y))


def solve():
	(n, p) = map(int, input().split())
	s = str()
	s += 'a'
	s += 'b' * (p - 2)
	s += 'a'
	print(s * (n // p) if p > 2 else 'impossible')
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	if n <= 2 or p <= 2:
		print('impossible')
	elif p >= n:
		print('a' + 'b' * (n - 2) + 'a')
	else:
		print(('a' + 'b' * (p - 2) + 'a') * (n // p))


t = int(input())
for i in range(t):
	(n, p) = map(int, input().split())
	s = 'aba'
	x = n // p
	if n < 3 or p <= 2:
		print('impossible')
	elif n == p:
		while n - 3 > 0:
			s = s[:2] + 'b' + s[2:]
			n -= 1
		print(s)
	else:
		s2 = ''
		while p - 3 > 0:
			s = s[:2] + 'b' + s[2:]
			p -= 1
		while x > 0:
			s2 = s2[0:len(s2)] + s[0:len(s)]
			x -= 1
		print(s2)


import sys
from sys import stdin
t = int(stdin.readline())
while t > 0:
	(n, p) = [int(x) for x in stdin.readline().split()]
	if n % p == 0:
		if p < 3:
			print('impossible', end='')
		else:
			ls = []
			ls.append('a')
			for i in range(1, p - 1):
				ls.append('b')
			ls.append('a')
			for j in range(n // p):
				for elem in ls:
					print(elem, end='')
		print()
	else:
		print('impossible', end='')
	t -= 1


n = int(input())
q = []
w = 2
for i in range(n):
	x = [int(s) for s in input().split()]
	c = int(x[0] / x[1])
	d = (int(x[1]) - 1) / int(w)
	r = int(x[1]) - 2
	if x[1] == 1:
		p = 'impossible'
		q.append(p)
	elif x[1] == 2:
		p = 'impossible'
		q.append(p)
	elif x[1] % 2 == 0 and x[0] % x[1] == 0:
		e = 'a' + 'b' * r + 'a'
		p = e * c
		q.append(p)
	elif x[1] % 2 != 0 and x[0] % x[1] == 0:
		f = 'ab' * int(d) + 'a'
		p = f * c
		q.append(p)
	else:
		p = 'impossible'
		q.append(p)
for i in q:
	print(i)


a = int(input())
for i in range(a):
	s = input().split()
	t = str('')
	c = 0
	if int(s[1]) == 1 or int(s[1]) == 2:
		c = 1
	elif int(s[1]) > 2:
		if int(s[1]) % 4 == 0:
			t1 = 'ab' * (int(s[1]) // 4)
			t2 = t1[::-1]
			t = t1 + t2
		elif int(s[1]) % 2 == 0:
			t1 = 'ab' * ((int(s[1]) - 2) // 4) + 'a'
			t2 = t1[::-1]
			t = t1 + t2
		elif int(s[1]) % 2 == 1:
			t1 = 'ab' * ((int(s[1]) - 1) // 2)
			t = t1 + 'a'
	if c == 0:
		print(t * (int(s[0]) // int(s[1])))
	else:
		print('impossible')


a = int(input())
b = []
for i in range(a):
	n = [int(s) for s in input().split()]
	if n[1] == 1 or n[1] == 2:
		print('impossible')
	else:
		for t in range(int(n[0] / n[1])):
			b.append('a')
			for j in range(n[1] - 2):
				b.append('b')
			b.append('a')
		m = ''.join(b)
		b = []
		if m[::-1] == m:
			print(m)
		else:
			print('impossible')


T = int(input())
N = []
for i in range(T):
	N = [int(s) for s in input().split()]
	if N[1] == 1 or N[1] == 2:
		print('impossible')
	elif N[0] % N[1] != 0:
		print('impossible')
	else:
		print(('a' + 'b' * (N[1] - 2) + 'a') * (N[0] // N[1]))


def NP(N):
	s = [0] * N
	s[0] = 'a'
	s[-1] = 'a'
	for i in range(1, N - 1):
		s[i] = 'b'
	string = ''.join(s)
	return string
T = int(input())
a = [0] * T
for i in range(T):
	(N, P) = map(int, input().split())
	if N == 1 or N == 2 or P == 1 or (P == 2):
		a[i] = 'impossible'
	else:
		m = N // P
		ans = NP(P)
		a[i] = ans * m
for i in range(T):
	print(a[i])


for i in range(int(input())):
	(n, p) = map(int, input().split())
	if p > 2:
		lst = ['a']
		for j in range(p - 2):
			lst.append('b')
		lst.append('a')
		print(''.join(lst) * (n // p))
	else:
		print('impossible')


for _ in range(int(input())):
	(N, P) = map(int, input().split())
	if P < 3 or N < 3 or (P == 2 and N % 4 != 0) or (N % P != 0):
		print('impossible')
		continue
	pattern = 'a' + (P - 2) * 'b' + 'a'
	s = ''
	for i in range(N // P):
		s += pattern
	print(s)


n = int(input())
a = [[int(j) for j in input().split()] for i in range(n)]
for i in range(n):
	c = a[i][0] // a[i][1]
	if a[i][1] <= 2:
		print('impossible')
	elif a[i][1] > 2:
		print(c * ('a' + (a[i][1] - 2) * 'b' + 'a'))


for _ in range(int(input())):
	(y, x) = [int(s) for s in input().split()]
	st = ''
	if x > 2:
		st += 'a'
		for j in range(1, x - 1):
			st += 'b'
		st += 'a'
		if int(y / x) != 1:
			b = int(y / x)
			print(st * b)
		else:
			print(st)
	else:
		print('impossible')


t = int(input())
for i in range(t):
	n = [int(x) for x in input().split()]
	s = ''
	temp = ''
	if n[1] == 1 or n[1] == 2:
		print('impossible')
	elif n[1] % 2 == 0:
		for j in range(n[1] // 2):
			if j % 2 == 0:
				s += 'a'
			else:
				s += 'b'
		s += s[::-1]
		for j in range(n[0] // n[1]):
			temp += s
		print(temp)
	else:
		for j in range(n[0] // n[1]):
			for k in range(n[1]):
				if k % 2 == 0:
					s += 'a'
				else:
					s += 'b'
		if s == s[::-1]:
			print(s)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = ''
	c += 'a'
	c += 'b' * (b - 2)
	c += 'a'
	if b > 2:
		print(c * (a // b))
	else:
		print('impossible')


T = int(input())
for i in range(T):
	(n, m) = map(int, input().split())
	if m <= 2:
		print('impossible')
	else:
		l = [0] * m
		if m % 2 == 0:
			a = m // 2
		else:
			a = m // 2 + 1
		for j in range(a):
			if j % 2 == 0:
				l[j] = 'a'
				l[m - j - 1] = 'a'
			else:
				l[j] = 'b'
				l[m - j - 1] = 'b'
		r = ''
		s = n // m
		for e in l:
			r = r + e
		print(r * s)


for _ in range(int(input())):
	(n, p) = map(int, input().split())
	if p == 1 or p == 2:
		print('impossible')
		continue
	l = ['a' for i in range(p)]
	if p % 2 == 1:
		l[p // 2] = 'b'
	else:
		l[p // 2] = 'b'
		l[p // 2 - 1] = 'b'
	l = l * (n // p)
	print(''.join(l))


def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		if k < 3 or n < 3 or (n == 4 and k == 2):
			print('impossible')
			continue
		if k % 2 == 0:
			sub = 'a' * (k // 2 - 1) + 'bb' + 'a' * (k // 2 - 1)
		else:
			sub = 'a' * (k // 2) + 'b' + 'a' * (k // 2)
		print(sub * (n // k))
main()


T = int(input())
for tj in range(T):
	(n, p) = map(int, input().split())
	if n % p == 0 and p > 2:
		div = n // 3
		k = ['a'] * p
		m = p // 2
		if p % 2 == 1:
			k[m] = 'b'
		else:
			k[m - 1] = 'b'
			k[m] = 'b'
		k1 = k * (n // p)
		fin = ''.join(k1)
		if fin == fin[::-1]:
			print(fin)
	else:
		print('impossible')


for t in range(int(input())):
	(N, P) = map(int, input().split())
	ans = 'impossible'
	if N % P == 0 and P >= 3:
		s = 'a' * ((P - 1) // 2)
		s = s + 'b' + s if P % 2 == 1 else s + 'bb' + s
		ans = s * (N // P)
	print(ans)


def genPal(n):
	s = ''
	for i in range(n // 2):
		s += 'ab'
	if n % 2 == 1:
		return s + 'a'
	else:
		return s
t = int(input())
for _ in range(t):
	(n, p) = map(int, input().split())
	s = ''
	if n == 2 or p == 1 or p == 2:
		print('impossible')
		continue
	elif p % 2 == 0:
		s = genPal(p // 2)
		s = s + s[::-1]
	elif p % 2 == 1:
		s = genPal(p)
	s = s * (n // p)
	print(s)


T = int(input())
for _ in range(T):
	(N, P) = map(int, input().split()[:2])
	if P > 2:
		print(('a' + 'b' * (P - 2) + 'a') * (N // P))
	else:
		print('impossible')