Consider the following:

A string, $\boldsymbol{\mathrm{~S~}}$, of length $n$ where $s=c_0c_1\ldots c_{n-1}$.
An integer, $\boldsymbol{\mbox{k}}$, where $\boldsymbol{\mbox{k}}$ is a factor of $n$.

We can split $\boldsymbol{\mathrm{~S~}}$ into $\frac{n}{k}$ substrings where each subtring, $t_i$, consists of a contiguous block of $\boldsymbol{\mbox{k}}$ characters in $\boldsymbol{\mathrm{~S~}}$. Then, use each $t_i$ to create string $u_i$ such that:

The characters in $u_i$ are a subsequence of the characters in $t_i$. 
Any repeat occurrence of a character is removed from the string such that each character in $u_i$ occurs exactly once. In other words, if the character at some index $j$ in $t_i$ occurs at a previous index $\lt j$ in $t_i$, then do not include the character in string $u_i$.

Given $\boldsymbol{\mathrm{~S~}}$ and $\boldsymbol{\mbox{k}}$, print $\frac{n}{k}$ lines where each line $\boldsymbol{i}$ denotes string $u_i$.  

Example 

$s=\text{'AAABCADDE'}$ 

$k=3$  

There are three substrings of length $3$ to consider: 'AAA', 'BCA' and 'DDE'.  The first substring is all 'A' characters, so $u_1=\text{'A'}$.  The second substring has all distinct characters, so $u_2=\text{'BCA'}$.  The third substring has $2$ different characters, so $u_3=\text{'DE'}$.  Note that a subsequence maintains the original order of characters encountered.  The order of characters in each subsequence shown is important.  

Function Description  

Complete the merge_the_tools function in the editor below.  

merge_the_tools has the following parameters:  

string s: the string to analyze  
int k: the size of substrings to analyze  

Prints  

Print each subsequence on a new line.  There will be $\frac{n}{k}$ of them.  No return value is expected.  

Input Format

The first line contains a single string, $\boldsymbol{\mathrm{~S~}}$. 

The second line contains an integer, $\boldsymbol{\mbox{k}}$, the length of each substring.

Constraints

$1\leq n\leq10^4$, where $n$ is the length of $\boldsymbol{\mathrm{~S~}}$
$1\leq k\leq n$ 
It is guaranteed that $n$ is a multiple of $\boldsymbol{\mbox{k}}$. 

Sample Input
STDIN       Function
-----       --------
AABCAAADA   s = 'AABCAAADA'
3           k = 3

Sample Output
AB
CA
AD

Explanation

Split $\boldsymbol{\mathrm{~S~}}$ into $\frac{n}{k}=\frac{9}{3}=3$ equal parts of length $k=3$. Convert each $t_i$ to $u_i$ by removing any subsequent occurrences of non-distinct characters in $t_i$:

$t_0=\textsf{"AAB"}\to u_0=\textsf{"AB"}$
$t_1=\text{"CAA}\rightarrow u_1=\text{"CA}\text{"}$
$t_2=\text{"ADA}\text{"}\rightarrow u_2=\text{"AD}\text{"}$

Print each $u_i$ on a new line.

Difficulty: MEDIUM

Solutions:
s = input()
k = int(input())
i = 0
(map, to_print) = ({}, '')
while i < len(s):
	if i % k == 0 and i != 0:
		print(to_print)
		(map, to_print) = ({}, '')
	if s[i] not in map.keys():
		map[s[i]] = 0
		to_print += s[i]
	i += 1
print(to_print)


import string
S = input()
N = len(S)
K = int(input())
for i in range(N // K):
	Ti = [S[K * (i + 1) - j - 1] for j in range(K)]
	for c in string.ascii_uppercase:
		cnt = Ti.count(c)
		for j in range(cnt - 1):
			Ti.remove(c)
	print(''.join(Ti[::-1]))


def f(x):
	a = ''
	for i in x:
		if i not in a:
			a = a + i
	return a
a = input()
K = int(input())
for i in range(len(a) // K):
	print(f(a[K * i:K * (i + 1)]))


from collections import OrderedDict
line = input()
n = int(input())
split = [line[i:i + n] for i in range(0, len(line), n)]
for i in split:
	print(''.join(OrderedDict.fromkeys(i)))


s = input()
n = int(input())
s = list(s)
l = []
op = ''
for i in range(0, len(s), n):
	for j in range(i, i + n):
		op += s[j]
	l.append(op)
	op = ''
from collections import OrderedDict
for c in l:
	foo = c
	print(''.join(OrderedDict.fromkeys(foo)))


S = input()
N = len(S)
K = int(input())
beg = 0
while beg < len(S):
	l = []
	for i in range(26):
		l.append(0)
	for i in range(beg, beg + K):
		if i >= N:
			break
		if l[ord(S[i]) - ord('A')] == 0:
			l[ord(S[i]) - ord('A')] += 1
			print(S[i], end='')
	beg += K
	print()


def nodups(s):
	seen = set()
	anslist = []
	for c in s:
		if c not in seen:
			seen.add(c)
			anslist.append(c)
	return ''.join(anslist)
line = input()
k = int(input())
for start in range(0, len(line), k):
	print(nodups(line[start:start + k]))


a = input()
K = int(input())
for n in range(len(a) // K):
	s = set([])
	out = ''
	for i in range(K * n, K * (n + 1)):
		if a[i] not in s:
			s.add(a[i])
			out += a[i]
	print(out)


S = input()
N = len(S)
K = int(input())
for i in range(0, N, K):
	modified = []
	sub = S[i:i + K]
	for s in sub:
		if not s in modified:
			modified.append(s)
	print(''.join(modified))


__author__ = 'Shivani'

def merge_the_tools(s, k):
	i = 0
	while i < len(s):
		se = set()
		te = ''
		for a in s[i:i + k]:
			if a not in se:
				te += a
				se.add(a)
		print(te)
		i += k

def main():
	s = input()
	k = int(input())
	merge_the_tools(s, k)
main()


from collections import OrderedDict
s = input()
k = int(input())
a = list(map(''.join, zip(*[iter(s)] * k)))
for i in a:
	print(''.join(OrderedDict.fromkeys(i).keys()))


from collections import OrderedDict as order
string = input()
length = len(string)
part = int(input())
parts = []
for i in range(0, length - part + 1, part):
	parts.append(''.join(order.fromkeys(string[i:i + part])))
for p in parts:
	print(p)


s = input()
k = int(input())
n = len(s)
for t in range(n // k):
	res = ''
	seen = {}
	for i in range(k):
		ind = t * k + i
		ch = s[ind]
		if ch not in seen:
			seen[ch] = 1
			res += ch
	print(res)


from collections import defaultdict
s = input()
k = int(input())
a = []
pos = 0
for i in range(len(s) // k):
	a.append(s[pos:pos + k])
	pos = pos + k
for x in a:
	d = defaultdict(int)
	for y in x:
		d[y] = 1
	for y in x:
		if d[y] != 0:
			print(y, end='')
			d[y] = 0
	print()


import collections
s = input()
k = int(input())
ss = [s[i:i + k] for i in range(0, len(s), k)]
for s in ss:
	print(''.join(collections.OrderedDict(((x, 1) for x in s)).keys()))


S = input()
K = int(input())
N = len(S)
i = 0
p = []
while i < N:
	p.append(S[i:i + K])
	i += K
for tmp in p:
	d = {}
	for c in tmp:
		d[c] = 0
	for c in tmp:
		d[c] += 1
	for c in tmp:
		if d[c] > 0:
			print(c, end='')
		d[c] = 0
	print('\n', end='')


from collections import OrderedDict
letters = input()
num = int(input())
groups = [letters[i:i + num] for i in range(0, len(letters), num)]
for item in groups:
	print(''.join(OrderedDict.fromkeys(item)))


stdin = input()
slice_size = int(input())

def new_string(string_slice):
	new_str = ''
	for letter in string_slice:
		if letter not in new_str:
			new_str += letter
	print(new_str)
for i in range(len(stdin) // slice_size):
	index = i * slice_size
	new_string(stdin[index:index + slice_size])


s = input()
n = len(s)
k = int(input())
m = int(n / k)
string = [''] * m
ans = [''] * m
for i in range(0, m):
	string[i] = s[i * k:k * (i + 1)]
for i in range(0, m):
	ldict = {}
	for letter in string[i]:
		ldict[letter] = 0
	for letter in string[i]:
		if ldict[letter] == 0:
			ldict[letter] += 1
			ans[i] = ans[i] + letter
		ldict[letter] += 1
for i in range(0, m):
	print(ans[i])


from collections import OrderedDict
s = input()
n = int(input())
x = [s[i:i + n] for i in range(0, len(s), n)]
for i in x:
	print(''.join(OrderedDict.fromkeys(i)))


import sys

def grouper(data, length):
	for i in range(0, len(data), length):
		yield data[i:i + length]

def run():
	inp = sys.stdin.readlines()
	data = inp[0].strip()
	length = int(inp[1])
	for line in grouper(data, length):
		uniq = set(line)
		res = []
		for i in line:
			if i in uniq:
				res.append(i)
				uniq.remove(i)
		print(''.join(res))
run()


s = input()
k = int(input())

def f7(seq):
	seen = set()
	seen_add = seen.add
	return [x for x in seq if not (x in seen or seen_add(x))]
for i in range(0, len(s), k):
	t = s[i:i + k]
	print(''.join(f7(t)))


s = input()
k = int(input())
l = len(s)
i = 0
while i < l:
	dict = {}
	j = i
	i += k
	while j < i:
		try:
			dict[s[j]] += 1
		except:
			print(s[j], end='')
			dict[s[j]] = 1
		j += 1
	print()


import collections
s = input()
k = int(input())
l = len(s)
i = 0
while i < l:
	dic = {}
	dic = collections.OrderedDict()
	j = i + k
	if not j <= l:
		q = s[i:]
	else:
		q = s[i:j]
	for o in range(len(q)):
		if not dic.get(q[o]):
			dic[q[o]] = True
	ans = ''
	for t in dic.keys():
		ans = ans + t
	print(ans)
	i = i + k


words = list(input())
subs = []
n = int(input())
for i in range(0, len(words), n):
	subs.append(''.join(words[i:i + n]))
for i in range(len(subs)):
	tmp = list(subs[i])
	uniq = []
	while tmp:
		j = tmp[0]
		uniq.append(j)
		tmp1 = [x for x in tmp if x != j]
		tmp = tmp1
	subs[i] = ''.join(uniq)
for i in subs:
	print(i)


s = input()
k = int(input())
a = []
for i in range(0, len(s), k):
	a += [s[i:i + k]]
for i in range(len(a)):
	d = ''
	c = a[i]
	j = 0
	while len(c) != 0:
		d += c[j]
		c = c.replace(c[j], '')
	print(d)


s = input()
k = int(input())
n = len(s) // k
strings = [s[i * k:i * k + k] for i in range(0, n)]
for st in strings:
	for i in range(0, k):
		if len(st) > i:
			st = st[0:i + 1] + st[i + 1:].replace(st[i], '')
	print(st)


from collections import OrderedDict

def splitter(s, N):
	lst = [s[i:i + N] for i in range(0, len(s), N)]
	for part in lst:
		bucket = set()
		arr = []
		for letter in part:
			size = len(bucket)
			bucket.add(letter)
			if size != len(bucket):
				arr.append(letter)
		print(''.join(arr))
s = input()
N = int(input())
splitter(s, N)


import textwrap
S = input()
K = int(input())
l = textwrap.wrap(S, K)
res = []
for t in l:
	found = {}
	t_ = ''
	for c in t:
		if not c in found:
			found[c] = 1
			t_ += c
	res.append(t_)
print('\n'.join(res))


import fileinput
inputs = []
for line in fileinput.input():
	inputs.append(line)
k = int(inputs[1])
count = 0
str = ''
for ch in inputs[0]:
	if ch == ' ' or ch == '\n':
		continue
	if count % k == 0 and count != 0:
		print(str)
		str = ''
	if ch not in str:
		str += ch
	count += 1
print(str)


import collections
s = input()
s_l = [e for e in s]
k = int(input())
count = 0
for i in range(int(len(s_l) / k)):
	mini_st = s_l[count * k:(count + 1) * k]
	while len(mini_st) > 0:
		print(mini_st[0], end='')
		mini_st = list(filter(mini_st[0].__ne__, mini_st))
	print()
	count += 1


p = input()
s = list(p)
new = []
old = []
j = 0
i = 0
noDupes = []
count = 0

def f3(seq):
	noDupes = []
	[noDupes.append(i) for i in seq if not noDupes.count(i)]
	return noDupes
k = int(input())
while i < len(s):
	old.append(s[i])
	count += 1
	i = i + 1
	if count == k:
		count = 0
		new = f3(old)
		print(''.join(new))
		del new[:]
		del old[:]


s = input()
k = int(input())
for i in range(len(s) // k):
	T = s[i * k:(i + 1) * k]
	U = set(T)
	S = ''
	for x in T:
		if x in U:
			S += x
			U.remove(x)
	print(S)


st = input()
k = int(input())
n = len(st)
l = ['' for i in range(n // k)]
start = 0
i = 0
while start != n:
	l[i] = st[start:start + k]
	start += k
	i += 1
for s in l:
	d = {}
	res = ''
	for i in s:
		if i not in d.keys():
			res += i
			d[i] = 1
		else:
			continue
	print(res)


S = input()
K = int(input())
index = 0
subs = []
while index < len(S):
	subs.append(S[index:index + K])
	index += K
for sub in subs:
	d = {}
	uniq = []
	for c in sub:
		if c not in d:
			uniq.append(c)
			d[c] = 1
	print(''.join(uniq))


def main():
	st = input()
	k = int(input())
	for x in [st[i:i + k] for i in range(0, len(st), k)]:
		ans = []
		for i in x:
			if i not in ans:
				ans += [i]
		print(''.join(ans))
main()


import sys
import math
import time
import random
import functools
import fractions
s = input()
k = int(input())
n = len(s)
for i in range(n // k):
	news = ''
	for j in range(k):
		news += s[i * k + j]
	array = []
	ress = ''
	for j in range(len(news)):
		if not news[j] in array:
			array.append(news[j])
			ress += news[j]
	print(ress)


def divstring(string, k):
	ls = len(string) // k
	return [string[index * k:index * k + k] for index in range(ls)]

def removedups(string):
	(ls, s) = (set(), [])
	for l in string:
		if l not in ls:
			s.append(l)
			ls.update([l])
	return ''.join(s)
string = input()
k = int(input())
strings = divstring(string, k)
mstrings = map(removedups, strings)
for word in mstrings:
	print(word)


import re
(inString, N) = (input(), int(input()))
parts = re.findall('.' * N, inString)
finalParts = []
for each in parts:
	letterDict = {}
	readyPortion = ''
	for letter in each:
		if letter not in letterDict:
			letterDict[letter] = True
			readyPortion += letter
	finalParts.append(readyPortion)
for each in finalParts:
	print(each)


import sys
str = sys.stdin.readline()[:-1]
k = int(input())
n = int(len(str) / k)
parts = []
for i in range(n):
	parts.append(str[i * k:(i + 1) * k])

def del_dupes(x):
	leset = set()
	out = []
	for c in x:
		if not c in leset:
			leset.add(c)
			out += c
	return out
parts = list(map(lambda x: ''.join(del_dupes(list(x))), parts))
for p in parts:
	print(p)


__author__ = 'Sak'
from operator import itemgetter
from collections import defaultdict
from collections import OrderedDict
import collections
S = str(input())
K = int(input())
L = [S[i:i + K] for i in range(0, len(S), K)]
for l in L:
	print(''.join(OrderedDict.fromkeys(l).keys()))


def merge_the_tools(text, no):
	i = 0
	while i < len(text):
		temp = ''
		temp_result = ''
		for j in range(no):
			temp += text[i]
			i += 1
		for k in temp:
			if k not in temp_result:
				temp_result += k
		print(temp_result)
text = input()
no = int(input())
merge_the_tools(text, no)


s = input()
k = int(input())
a = len(s) // k
count = 0
for i in range(a):
	seen = {}
	new_word = ''
	for y in range(k):
		if not s[count] in seen:
			seen[s[count]] = None
			new_word += s[count]
		count += 1
	print(new_word)


string = input()
k = int(input())
div = []
i = 0
while i <= len(string) - k:
	s = string[i:i + k]
	minlist = []
	for j in s:
		if j not in minlist:
			minlist.append(j)
	div.append(minlist)
	i = i + k
for i in div:
	st = ''
	for j in i:
		st += j
	print(st)


N = input()
K = int(input())
start = 0
end = K
for i in range(len(N) // K):
	sub = N[start:end]
	d = dict()
	out = ''
	for letter in sub:
		if letter not in d:
			out += letter
			d[letter] = 0
	print(out)
	start += K
	end += K


inp = input()
k = int(input())
for i in range(int(len(inp) / k)):
	tempStr = inp[i * k:(i + 1) * k]
	dict = {}
	ans = ''
	for char in tempStr:
		if not char in dict:
			dict[char] = True
			ans += char
	print(ans)


def modify(a):
	d = {}
	for i in a:
		d[i] = 0
	f = ''
	for i in a:
		if d[i] == 0:
			f += i
		d[i] += 1
	print(f)
s = input()
k = int(input())
i = 0
while i + k <= len(s):
	a = s[i:i + k]
	modify(a)
	i += k


import sys
input = sys.stdin.readline()
k = int(sys.stdin.readline())
for i in range(len(input) // k):
	word = input[i * k:(i + 1) * k]
	myset = set()
	output = ''
	for letter in word:
		if letter not in myset:
			output = output + letter
			myset.add(letter)
	print(output)


def unify(s):
	k = {}
	for (i, a) in enumerate(s):
		if a not in k:
			k[a] = i
	print(''.join(sorted(k, key=k.get)))
s = input()
n = int(input())
for i in range(int(len(s) / n)):
	unify(s[i * n:(i + 1) * n])


import textwrap
str1 = input()
n = int(input())
myList = textwrap.wrap(str1, n)
for item in myList:
	sample = ''
	for char in item:
		if char not in sample:
			sample += char
	print(sample)


from collections import OrderedDict as odict
S = list(input().strip())
step = int(input())

def uni(S):
	L = odict()
	for s in S:
		L[s] = ''
	print(''.join(L.keys()))
for i in range(0, len(S), step):
	uni(S[i:i + step])


def modify(s):
	ans = ''
	for c in s:
		if c not in ans:
			ans += c
	return ans
given = input()
n = int(input())
for i in range(int(len(given) / n)):
	s = given[:n]
	s = modify(s)
	print(s)
	given = given[n:]


s = input()
k = int(input())
i = 0
n = len(s)
while i < n:
	sr = s[i:i + k]
	ans = ''
	while len(sr):
		ans += str(sr[0])
		sr = sr.replace(sr[0], '')
	print(ans)
	i += k


a = input()
b = int(input())
c = []
d = 0
for i in range(0, len(a), b):
	c.append(a[i:b + i])
d = []
s = ''
for j in c:
	for k in j:
		if not s.__contains__(k):
			s = s + k
	d.append(s)
	s = ''
for i in d:
	print(i)


s = input()
l = int(input())
seg = list()
for i in range(0, len(s), l):
	seg.append(s[i:i + l])
merged = list()
for x in seg:
	checked = set()
	n = list()
	for y in x:
		if not y in checked:
			n.append(y)
			checked.add(y)
	merged.append(''.join(n))
for m in merged:
	print(m)


from collections import Counter
from collections import OrderedDict
import itertools

def unique_list(l):
	ulist = []
	[ulist.append(x) for x in l if x not in ulist]
	return ulist
d = OrderedDict()
lis = input().strip()
k = int(input())
cnt = Counter(lis)
res = []
for i in range(0, len(lis), k):
	v = lis[i:i + k]
	res.append(v)
cnt = Counter(res)
for w in res:
	print(''.join(unique_list(w)))


letters = input()
division_len = int(input())
divisions = len(letters) // division_len
index = 0
strings = []
for i in range(divisions):
	strings.append(letters[index:index + division_len])
	index += division_len
for s in strings:
	used = set()
	for ss in s:
		if ss in used:
			pass
		else:
			print(ss, end='')
			used.add(ss)
	print()


from collections import OrderedDict
text = input()
k = int(input())
n = []
m = len(text) // k
for i in range(m):
	n.append(text[i * k:i * k + k])
for s in n:
	print(''.join(OrderedDict.fromkeys(s)))


S = input()
K = int(input())
Ts = [S[i:i + K] for i in range(0, len(S), K)]
for T in Ts:
	Tu = []
	for t in T:
		if t not in Tu:
			Tu.append(t)
	print(''.join(Tu))


teststr = input().strip()
tlen = int(input().strip())
testcount = len(teststr) // tlen
for x in range(testcount):
	t = teststr[tlen * x:tlen * (x + 1)]
	newt = ''
	for cha in t:
		if cha not in newt:
			newt += cha
	print(newt)


s = input()
k = int(input())
for i in range(0, len(s), k):
	ans = ''
	s_list = list(s[i:i + k])
	ans += s_list[0]
	for j in range(1, len(s_list)):
		if s_list[j] not in ans:
			ans += s_list[j]
	print(ans)


s = input()
part_len = int(input())
k = len(s) // part_len

def compressed(s):
	new_s = ''
	alph = [0] * 26
	for c in s:
		ind = ord(c) - ord('A')
		if alph[ind] == 0:
			new_s += c
			alph[ind] += 1
	return new_s
for i in range(0, k):
	start = i * part_len
	part_s = compressed(s[start:start + part_len])
	print(part_s)


S = input()
K = int(input())
for i in range(0, len(S), K):
	T = S[i:i + K]
	s = set()
	L = []
	for c in T:
		if c not in s:
			L.append(c)
			s.add(c)
	print(''.join(L))


def modify(s):
	ret = ''
	letters = set()
	for c in s:
		if c not in letters:
			ret += c
			letters.add(c)
	return ret
s = input().strip()
K = int(input().strip())
for i in range(len(s) // K):
	ss = s[i * K:i * K + K]
	print(modify(ss))


s = input()
N = len(s)
K = int(input())
l = []
for i in range(int(N / K)):
	l.append(s[i * K:(i + 1) * K])
for word in l:
	(p, d) = ('', '')
	for c in word:
		if c not in d:
			p += c
		d += c
	print(p)


from collections import OrderedDict
string = input().strip()
K = int(input())
l = int(len(string) / K)
idx = 0
for i in range(l):
	print(''.join(OrderedDict.fromkeys(string[idx:idx + K])))
	idx += K


S = input()
i = int(input())
S = list(map(lambda x: S[x:x + i], range(0, len(S) - i + 1, i)))

def sorter(s):
	s = list(s)
	ms = ''
	while s:
		ms += s[0]
		i = s[0]
		while i in s:
			s.remove(i)
	return ms
list(map(lambda x: print(sorter(x)), S))


string = input()
k = int(input())
parts = [string[i:i + k] for i in range(0, len(string), k)]
for part in parts:
	(d, r) = ({}, [])
	for character in part:
		if character not in d:
			r.append(character)
			d[character] = True
	print(''.join(r))


a = list(input())
b = int(input())
c = len(a) // b
for i in range(c):
	text = ''
	d = a[b * i:b * (i + 1)]
	for j in range(len(d)):
		if d.count(d[-(j + 1)]) > 1:
			d[-(j + 1)] = '$'
	for k in range(d.count('$')):
		d.remove('$')
	for k2 in d:
		text += k2
	print(text)


from collections import OrderedDict
data = input()
n = int(input())
data = [data[i:i + n] for i in range(0, len(data), n)]
for word in data:
	print(''.join(OrderedDict.fromkeys(word)))


s = input()
k = int(input())
n = len(s)
step = int(n / k)
prevIndex = 0
currentIndex = k
for i in range(0, n, k):
	x = s[prevIndex:currentIndex]
	currentIndex += k
	prevIndex += k
	print(''.join(sorted(set(x), key=x.index)))


s = input()
k = int(input())
prevIndex = 0
currentIndex = k
for i in range(0, len(s), k):
	x = s[prevIndex:currentIndex]
	currentIndex += k
	prevIndex += k
	print(''.join(sorted(set(x), key=x.index)))


s = input()
k = int(input())
words = s
subs = []
n = k
for i in range(0, len(words), n):
	st = words[i:i + n]
	s = []
	tt = ''
	for j in range(len(st)):
		if not s.__contains__(st[j]):
			s.append(''.join(st[j]))
			tt = tt + st[j]
	print(tt)


from collections import OrderedDict
s = input()
k = int(input())
for i in range(0, len(s), k):
	print(''.join(OrderedDict.fromkeys(s[i:k + i])))


s = input()
k = eval(input())
for i in range(0, len(s), k):
	l = s[i:i + k]
	l1 = ''
	for i1 in l:
		if i1 not in l1:
			l1 = l1 + i1
	print(l1)


s = input()
k = int(input())
lines = []
for i in range(0, len(s), k):
	lines.append(s[i:i + k])
for i in range(len(lines)):
	str = lines[i]
	lines[i] = ''.join([j for (i, j) in enumerate(str) if j not in str[:i]])
for str in lines:
	print(str)


def main():
	lis = list(input())
	n = int(input())
	ans = []
	i = 0
	for x in range(0, len(lis), n):
		ans.append([])
		for x in lis[x:x + n]:
			if x not in ans[i]:
				ans[i].append(x)
		i += 1
	for x in ans:
		print(''.join(x))
main()


s = str(input())
k = int(input())
n = len(s)

def chk(a):
	f = a[0]
	for i in a:
		if i not in f:
			f += i
	return f
for i in range(0, n, k):
	t = chk(s[i:i + k])
	print(t)


s = input()
n = len(s)
k = int(input())
for i in range(0, n, k):
	l = s[i:i + k]
	str1 = ''
	while len(l) != 0:
		x = l[0]
		l = l.replace(x, '')
		str1 = str1 + x
	print(str1)


l = ''
s = input().strip().upper()
n = len(s)
k = int(input().strip())
for i in range(0, n, k):
	l = ''
	s1 = s[i:i + k]
	a = [0] * 26
	for c in s1:
		a[ord(c) - 65] = 1
	for c in s1:
		if a[ord(c) - 65] == 1:
			l += c
			a[ord(c) - 65] = 0
	print(l)


def k_split(arr, leng):
	assert len(arr) % leng == 0
	splits = []
	ind = 0
	while ind < len(arr):
		splits.append(arr[ind:ind + leng])
		ind += leng
	return splits

def uniq(seq):
	copy = []
	for elm in seq:
		if elm not in copy:
			copy.append(elm)
	return copy
phrase = input()
leng = int(input())
for split in k_split(phrase, leng):
	print(''.join(uniq(split)))


S = input()
K = int(input())
l = len(S)
L = []
for i in range(0, l, K):
	temp = S[i:i + K]
	s = ''
	for j in range(K):
		if not temp[j] in s:
			s += temp[j]
	print(s)


import sys

def cut(line, k):
	n = 0
	while n < len(line):
		yield line[n:n + k]
		n += k

def uniq(word):
	res = []
	seen = set()
	for c in word:
		if c not in seen:
			seen.add(c)
			res.append(c)
	return ''.join(res)
line = sys.stdin.readline()
k = int(sys.stdin.readline())
for word in cut(line, k):
	print(uniq(word))


S = input('')
K = int(input(''))
l = []
newL = []
for i in range(0, len(S), K):
	l.append(S[i:i + K])
for content in l:
	x = []
	for c in content:
		if c not in x:
			x.append(c)
	newL.append(x)
for i in newL:
	print(''.join(i), end='\n')


import collections as c
in_str = input()
k = int(input())
b_len = int(len(in_str) / k)
start = 0
end = k
for i in range(b_len):
	print(''.join(c.OrderedDict.fromkeys(in_str[start:end])))
	start += k
	end += k


s = input()
l = int(input())
splits = []
ratio = int(len(s) / l)
for i in range(ratio):
	splits.append(s[i * l:i * l + l])
for i in splits:
	builder = ''
	for j in i:
		if not j in builder:
			builder += j
	print(builder)


string = input()
sub_string_length = int(input())
total_strings = len(string) // sub_string_length
start = 0
end = sub_string_length
list = []
for i in range(0, total_strings):
	list.append(string[start:end])
	start = end
	end = end + sub_string_length
for item in list:
	seen = set()
	result = []
	for c in item:
		if c not in seen:
			result.append(c)
			seen.add(c)
	result = ''.join(result)
	print(result)


s = input()
k = int(input())
n = len(s)
i = 0
while i < n:
	out_str = ''
	for _ in range(k):
		if s[i] not in out_str:
			out_str += s[i]
		i += 1
	print(out_str)


def nubBy(f, lst):
	m = dict()
	out = []
	for i in range(len(lst)):
		v = lst[i]
		fv = f(v)
		if fv not in m:
			m[fv] = True
			out.append(v)
	return out

def chunksOf(n, lst):
	out = []
	c = []
	for i in range(len(lst)):
		if i > 0 and i % n == 0:
			out.append(c)
			c = []
		c.append(lst[i])
	out.append(c)
	return out
s0 = input()
k = int(input())
s1 = chunksOf(k, s0)
s2 = list(map(lambda lst: nubBy(lambda x: x, lst), s1))
for i in range(len(s2)):
	print(''.join(s2[i]))


from collections import OrderedDict
s = input()
k = int(input())
lenn = len(s)
r = ''
for i in range(0, lenn, k):
	r = s[i:i + k]
	print(''.join(OrderedDict.fromkeys(r)))


import sys
s = next(sys.stdin)
K = int(next(sys.stdin))
r = int(len(s) / K)
for i in range(r):
	part = s[0:K]
	s = s[K:]
	chars = list(part)
	p = 1
	seen = set()
	ret = ''
	for c in chars:
		if c not in seen:
			seen.add(c)
			ret += c
	print(ret)


import textwrap
string = str(input())
k = int(input())
ourList = textwrap.wrap(string, k)
solution = list()
index = 0
for st in ourList:
	tester = set()
	solution.append('')
	for i in st:
		if i not in tester:
			solution[-1] = ''.join([solution[-1], i])
			tester.add(i)
	print(solution[-1])


s = input()
k = int(input())
for i in range(0, len(s), k):
	used = set()
	for c in s[i:i + k]:
		if c not in used:
			print(c, end='')
			used.add(c)
	print()


from collections import OrderedDict
s = input()
n = int(input())
arr = []
l = len(s)
for i in range(n, l + 1, n):
	arr.append(s[i - n:i])
for i in range(len(arr)):
	print(''.join(OrderedDict.fromkeys(arr[i])))


s = input()
k = int(input())
n = len(s)
l = [s[i:i + k] for i in range(0, n, k)]
for part in l:
	pl = list(part)
	pl.reverse()
	chars = set(pl)
	for ch in chars:
		count = pl.count(ch)
		if count > 1:
			[pl.remove(ch) for _ in range(count - 1)]
	pl.reverse()
	print(''.join(pl))


def func():
	data = input()
	k = int(input())
	length = len(data)
	dict1 = {}
	for i in range(length):
		if i != 0 and i % k == 0:
			print()
			dict1 = {}
		if data[i] not in dict1:
			print(data[i], end='')
			dict1[data[i]] = 1
func()


def main():
	S = input()
	K = int(input())
	lst = [S[i:i + K] for i in range(0, len(S), K)]
	for s in lst:
		visit = {}
		res = []
		for ch in s:
			if not visit.get(ch, False):
				visit.setdefault(ch, True)
				res += [ch]
		print(''.join(res))
main()


s = input()
k = int(input())
n = int(len(s) / k)
a = 0
b = k
lista = []

def getword(a, b):
	temp = []
	for i in range(a, b):
		if s[i] not in temp:
			temp.append(s[i])
	return ''.join(temp)
for i in range(n):
	print(getword(a, b))
	a = a + k
	b = b + k


inStr = input()
divBy = int(input())

def divStr(s, n):
	ary = []
	start = 0
	for i in range(len(s) // n):
		stop = start + n
		ary.append(s[start:stop])
		start = stop
	return ary

def modStr(s):
	ret = ''
	for i in range(len(s)):
		if s[i] not in ret:
			ret += s[i]
	return ret
inStr = divStr(inStr, divBy)
for i in range(len(inStr)):
	inStr[i] = modStr(inStr[i])
	print(inStr[i])


s = input()
i = int(input())
a = []
b = []
for j in range(0, len(s), i):
	b = []
	x1 = s[j:j + i]
	for x2 in x1:
		if x2 not in b:
			b.append(x2)
	a.append(''.join(b))
print('\n'.join(a))