Chouti and his classmates are going to the university soon. To say goodbye to each other, the class has planned a big farewell party in which classmates, teachers and parents sang and danced.

Chouti remembered that $n$ persons took part in that party. To make the party funnier, each person wore one hat among $n$ kinds of weird hats numbered $1, 2, \ldots n$. It is possible that several persons wore hats of the same kind. Some kinds of hats can remain unclaimed by anyone.

After the party, the $i$-th person said that there were $a_i$ persons wearing a hat differing from his own.

It has been some days, so Chouti forgot all about others' hats, but he is curious about that. Let $b_i$ be the number of hat type the $i$-th person was wearing, Chouti wants you to find any possible $b_1, b_2, \ldots, b_n$ that doesn't contradict with any person's statement. Because some persons might have a poor memory, there could be no solution at all.


-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 10^5$), the number of persons in the party.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le n-1$), the statements of people.


-----Output-----

If there is no solution, print a single line "Impossible".

Otherwise, print "Possible" and then $n$ integers $b_1, b_2, \ldots, b_n$ ($1 \le b_i \le n$).

If there are multiple answers, print any of them.


-----Examples-----
Input
3
0 0 0

Output
Possible
1 1 1 
Input
5
3 3 2 2 2

Output
Possible
1 1 2 2 2 
Input
4
0 1 2 3

Output
Impossible



-----Note-----

In the answer to the first example, all hats are the same, so every person will say that there were no persons wearing a hat different from kind $1$.

In the answer to the second example, the first and the second person wore the hat with type $1$ and all other wore a hat of type $2$.

So the first two persons will say there were three persons with hats differing from their own. Similarly, three last persons will say there were two persons wearing a hat different from their own.

In the third example, it can be shown that no solution exists.

In the first and the second example, other possible configurations are possible.

Difficulty: MEDIUM
Tags: Implementation

Constructive algorithms

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))
d = dict()
poses = dict()
ans = [0 for i in range(n)]
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 1
		poses[a[i]] = [i]
	else:
		d[a[i]] += 1
		poses[a[i]].append(i)
color = 1
for i in d.keys():
	while d[i]:
		if len(poses[i]) < n - i:
			print('Impossible')
			exit()
		d[i] -= n - i
		for j in range(n - i):
			ans[poses[i].pop()] = color
		color += 1
print('Possible')
print(*ans)


def customsort(t):
	return t[1]
n = int(input())
a = list(map(int, input().split()))
a_new = [(index, a[index]) for index in range(len(a))]
a_new.sort(key=lambda x: x[1])
b = []
cont = True
i = 0
k = 1
while i < n and cont:
	for j in range(n - a_new[i][1]):
		b.append(k)
	k += 1
	for j in range(len(a_new) - a_new[i][1]):
		if i + j >= n or a_new[i + j][1] != a_new[i][1]:
			print('Impossible')
			cont = False
			break
	i += n - a_new[i][1]
if cont:
	print('Possible')
	b_original = [0] * n
	for i in range(n):
		b_original[a_new[i][0]] = b[i]
	print(*b_original)


n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n):
	b[i] = n - a[i]
cnt = [[] for i in range(n + 1)]
for i in range(n):
	cnt[b[i]].append(i)
f = True
for i in range(1, n + 1):
	if len(cnt[i]) % i != 0:
		f = False
		break
if not f:
	print('Impossible')
else:
	t = 1
	ans = [0] * n
	for i in range(1, n + 1):
		x = cnt[i]
		if len(x) != 0:
			y = 0
			for j in x:
				ans[j] = t
				y += 1
				if y == i:
					t += 1
					y = 0
	print('Possible')
	print(*ans)


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')
n = int(input())
l = list(map(int, input().split()))
d = dict()
t = 1
d1 = dict()
f = 0
ans = [0] * n
for i in range(n):
	if l[i] in d:
		d[l[i]] += 1
		d1[l[i]].append(i)
	else:
		d.update({l[i]: 1})
		d1.update({l[i]: [i]})
	if d[l[i]] == n - l[i]:
		for k in d1[l[i]]:
			ans[k] = t
		t += 1
		d[l[i]] = 0
		d1[l[i]] = []
for j in d:
	if d[j] != 0:
		f = 1
		break
if f == 1:
	print('Impossible')
else:
	print('Possible')
	print(*ans, sep=' ')


n = int(input())
arr = list(map(int, input().split()))
ansarr = [0] * n
flag = 0
dict1 = {}
dict2 = {}
for i in range(n):
	try:
		dict1[arr[i]].append(i)
	except:
		KeyError
		dict1[arr[i]] = [i]
		dict2[arr[i]] = 0
tempcount = 0
for i in dict1.keys():
	count = 0
	while dict2[i] < len(dict1[i]):
		if dict2[i] + n - i > len(dict1[i]):
			flag = 1
			break
		else:
			tempcount += n - i
			dict2[i] += n - i
if tempcount != n:
	flag = 1
if flag == 1:
	print('Impossible')
else:
	count = 0
	val = 1
	for i in dict1.keys():
		for j in range(0, len(dict1[i]), n - i):
			for k in range(n - int(i)):
				ansarr[dict1[i][j + k]] = val
			val += 1
	print('Possible')
	print(*ansarr)


import sys
from math import *

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

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

def main():
	n = mint()
	a = [None] * n
	r = [None] * n
	j = 0
	for i in mints():
		a[j] = (n - i, j)
		j += 1
	a.sort()
	j = 1
	i = 0
	while i < n:
		cnt = a[i][0]
		for k in range(i, i + cnt):
			if k >= n or a[k][0] != cnt:
				print('Impossible')
				return
			r[a[k][1]] = j
		j += 1
		i += cnt
	print('Possible')
	print(*r)
main()


n = int(input())
k = 0
d = {}
i = 0
for x in map(int, input().split()):
	d.setdefault(n - x, []).append(i)
	i += 1
b = [0] * n
s = 'ossible'
g = 0
for x in d:
	l = d[x]
	g += 1
	j = 0
	for i in l:
		if j == x:
			j = 0
			g += 1
		b[i] = g
		j += 1
	if j != x:
		print('Imp' + s)
		exit()
print('P' + s, *b)


n = int(input())
a = list(map(int, input().split()))

def solve():
	b = sorted(((a[i], i) for i in range(n)))
	ret = [None] * n
	i = 0
	cur = 1
	while i < n:
		same = n - b[i][0]
		for j in range(i, i + same):
			if j >= n or b[i][0] != b[j][0]:
				print('Impossible')
				return
			ret[b[j][1]] = cur
		cur += 1
		i += same
	print('Possible')
	print(*ret)
solve()


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
n = rint()
m = [[] for _ in range(n)]
for (i, ai) in enumerate(rints()):
	m[n - 1 - ai].append(i)
res = [0] * n
c = 1
for i in range(n):
	if not m[i]:
		continue
	if len(m[i]) % (i + 1):
		print('Impossible')
		exit(0)
	for (j, idx) in enumerate(m[i]):
		res[idx] = c + j // (i + 1)
	c += len(m[i]) // (i + 1)
print('Possible')
print(*res)


read_int = lambda : int(input())
read_ints = lambda : list(map(int, input().split(' ')))

def solve(n, diffs):
	array = []
	for _ in range(n + 1):
		array.append(set())
	for (i, d) in enumerate(diffs):
		array[n - d].add(i)
	is_possible = True
	for (i, s) in enumerate(array[1:]):
		if len(s) % (i + 1) != 0:
			is_possible = False
	if is_possible:
		print('Possible')
		hats = [0] * n
		hat_kind = 1
		for (i, s) in enumerate(array):
			for (j, person) in enumerate(s):
				hats[person] = hat_kind
				if (j + 1) % i == 0:
					hat_kind += 1
		print(' '.join(map(str, hats)))
	else:
		print('Impossible')
n = read_int()
diffs = read_ints()
solve(n, diffs)


import collections
n = int(input())
b = list(map(int, input().split()))
num = 1
ret = 0
cnt = [0 for _ in range(n + 1)]
par = [collections.deque() for _ in range(n + 1)]
for i in b:
	if cnt[i] == 0:
		for j in range(n - i):
			ret += 1
			par[i].append(num)
		cnt[i] = n - i
		num += 1
	if cnt[i]:
		cnt[i] -= 1
	if ret > n:
		break
ans = []
if ret != n:
	print('Impossible')
else:
	print('Possible')
	for i in b:
		ans.append(par[i][0])
		par[i].popleft()
	for i in ans:
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline
for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	e = {}
	for i in range(n):
		x = l[i]
		if x in e:
			e[x].append(i)
		else:
			e[x] = [i]
	z = l.count(0)
	if z > 0:
		if z == n:
			print('Possible')
			ans = [1] * n
			print(*ans)
		else:
			print('Impossible')
	else:
		l.sort()
		ans = [0] * n
		d = {}
		ele = 1
		for i in l:
			w = n - i
			if i in d:
				d[i] -= 1
				if d[i] == 0:
					del d[i]
				continue
			c = 0
			d[i] = w - 1
			if d[i] == 0:
				del d[i]
			while c < w:
				if len(e[i]) == 0:
					print('Impossible')
					exit()
				r = e[i].pop()
				ans[r] = ele
				c += 1
			ele += 1
		if len(ans) > n or len(d) > 0:
			print('Impossible')
			continue
		print('Possible')
		print(*ans)


from collections import *
import os, sys
from io import BytesIO, IOBase

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')
BUFSIZE = 8192
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
rstr = lambda : input().strip()
rstrs = lambda : [str(x) for x in input().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rint = lambda : int(input())
rints = lambda : [int(x) for x in input().split()]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
(n, a) = (rint(), rints())
(mem, cur) = ([[] for _ in range(n)], 1)
for i in range(n):
	mem[a[i]].append(i)
for i in range(n):
	(div, mod) = divmod(len(mem[i]), n - i)
	if mem[i] and mod:
		exit(print('Impossible'))
	for j in range(div):
		for k in range(j * (n - i), (j + 1) * (n - i)):
			a[mem[i][k]] = cur
		cur += 1
print('Possible\n', *a)


n = int(input())
a = [n - int(x) for x in input().split()]
b = [0] * n
fh = 1
hd = dict()
for i in range(n):
	if a[i] == 1:
		b[i] = fh
		fh += 1
	elif a[i] in hd:
		b[i] = hd[a[i]][0]
		hd[a[i]][1] -= 1
		if hd[a[i]][1] == 0:
			del hd[a[i]]
	else:
		b[i] = fh
		hd[a[i]] = [fh, a[i] - 1]
		fh += 1
if len(hd) != 0:
	print('Impossible')
else:
	print('Possible')
	print(*b)


def p(l):
	return n - l - 1
n = int(input())
mas = list(map(p, list(map(int, input().split()))))
ne = [0 for i in range(n)]
q = set(mas)
fl = 1
sh_color = 1
l = 1
t = 1
mop = 0
if fl:
	for elem in q:
		l = 1
		mop = 0
		for z in range(n):
			if mas[z] == elem and l <= elem + 1:
				ne[z] = sh_color
				l += 1
				mop += 1
			elif l == elem + 2 and mas[z] == elem:
				sh_color += 1
				ne[z] = sh_color
				l = 2
				mop += 1
		if mop % (elem + 1) != 0:
			print('Impossible')
			t = 0
			break
		sh_color += 1
if t:
	print('Possible')
	print(' '.join(list(map(str, ne))))


x = int(input())
y = str(input())
y = y.split(' ')
y = [x for x in y if x != '']
ini = []
adder = 1
for i in range(x):
	ini.append([int(y[i]), i])
ini = sorted(ini, key=lambda s: s[0])
prev = ini[0][0]
a = y
furthermore = [x - ini[0][0], ini[0][0]]
value = ini[0][0]
for i in range(x):
	value = ini[i][0]
	if furthermore[0] != 0 and furthermore[1] == value:
		a[ini[i][1]] = adder
		furthermore[0] = furthermore[0] - 1
	elif furthermore[0] == 0:
		if i == x - 1:
			if 1 + ini[i][0] != x:
				a = -1
				break
		furthermore[1] = value
		furthermore[0] = x - 1 - ini[i][0]
		adder = adder + 1
		a[ini[i][1]] = adder
	else:
		a = -1
		break
if a == -1:
	print('Impossible')
elif a != -1:
	print('Possible')
	for i in range(x):
		print(a[i], end=' ')


n = int(input())
m = list(map(int, input().split()))
mr = [n - i for i in m]
from collections import Counter
co = dict(Counter(mr))
al = {}
fl = 1
for (k, v) in co.items():
	if v // k == v / k:
		al[k] = v // k
	else:
		fl = 0
		break
if fl == 0:
	print('Impossible')
else:
	print('Possible')
	c = 1
	num = {}
	for x in co:
		for i in range(al[x]):
			for z in range(co[x] // al[x]):
				if x in num:
					num[x].append(c + i)
				else:
					num[x] = [c + i]
		c += al[x]
	sol = []
	for m in num:
		sol += num[m]
	for x in mr:
		print(num[x][0], end=' ')
		del num[x][0]


n = int(input())
cl = list(map(int, input().split()))
pos = {}
color = 0
res = []
for x in cl:
	if x in pos.keys():
		if pos[x][0] != 0:
			res.append(pos[x][1])
			pos[x][0] -= 1
		else:
			color += 1
			res.append(color)
			pos[x] = [n - x - 1, color]
	else:
		color += 1
		res.append(color)
		pos.update({x: [n - x - 1, color]})
for x in pos.keys():
	if pos[x][0] != 0:
		print('Impossible')
		return
print('Possible')
print(*res)


n = int(input())
k = 0
d = {}
i = 0
for x in map(int, input().split()):
	d.setdefault(n - x, []).append(i)
	i += 1
b = [0] * n
s = 'ossible'
g = 0
for (x, l) in d.items():
	g += 1
	if len(l) % x:
		print('Imp' + s)
		break
	j = 0
	for i in l:
		j += 1
		if j > x:
			j = 1
			g += 1
		b[i] = g
else:
	print('P' + s, *b)


import sys
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append([a[i], i])
b.sort()
c = []
p = 1
i = 0
while i < n:
	k = n - b[i][0]
	for j in range(k):
		if i + j < n and b[i + j][0] == n - k:
			c.append([p, b[i + j][1]])
		else:
			print('Impossible')
			exit()
	p += 1
	i += k
d = [0 for i in range(n)]
for i in range(n):
	d[c[i][1]] = c[i][0]
print('Possible')
print(*d)


import math
import sys

def main():
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	groups = {}
	for (i, v) in enumerate(a):
		if n - v not in groups:
			groups[n - v] = []
		groups[n - v].append(i)
	nums = []
	for (k, v) in groups.items():
		if len(v) % k != 0:
			print('Impossible')
			return
		curs = [[] for i in range(len(v) // k)]
		for i in range(len(v)):
			curs[i % (len(v) // k)].append(v[i])
		nums += curs
	ans = [0 for i in range(n)]
	for (i, v) in enumerate(nums):
		for j in v:
			ans[j] = i + 1
	print('Possible')
	for i in range(n):
		print(ans[i], end=' ')
main()


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(len(a)):
	if n - a[i] in d:
		d[n - a[i]] += [i]
	else:
		d[n - a[i]] = [i]
possible = True
count = 1
output = [0 for i in range(n)]
for i in d.keys():
	if len(d[i]) % i != 0:
		possible = False
if not possible:
	print('Impossible')
else:
	count = 1
	for i in d.keys():
		j = 0
		for k in d[i]:
			output[k] = j // i + count
			j += 1
		count = output[d[i][-1]] + 1
	print('Possible')
	for i in output:
		print(i, end=' ')
	print('')


from collections import Counter
n = int(input())
a = tuple((n - int(x) for x in input().split()))
a1 = [[] for _ in range(n + 2)]
b = [1] * n
for i in range(n):
	a1[a[i]].append(i)
i = 1
m = 1
for k in range(1, n + 1):
	for j in a1[k]:
		b[j] = i
		if m == k:
			m = 1
			i += 1
		else:
			m += 1
	if m != 1:
		print('Impossible')
		break
else:
	print('Possible')
	print(*b)


n = int(input())
hats = list(map(int, input().split()))
index = [j for j in range(n)]
colors = [0 for j in range(n)]
z = list(map(list, zip(hats, index, colors)))
z.sort()
hnumber = 0
count = 0
false = 0
for j in range(n):
	if count == 0:
		count = n - z[j][0] - 1
		hnumber += 1
	elif z[j][0] == z[j - 1][0]:
		count -= 1
	else:
		false = 1
	z[j][2] = hnumber
if false == 1 or not count == 0:
	print('Impossible')
else:
	print('Possible')
	z.sort(key=lambda x: x[1])
	print(*[x[2] for x in z])


import sys
n = int(input())
a = [n - int(x) for x in input().split()]
d = {}
num = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 0
	d[a[i]] += 1
	num[i] = d[a[i]]
for i in d:
	if d[i] % i != 0:
		print('Impossible')
		sys.exit()
curr = 1
poss = {i: [] for i in d}
for i in d:
	j = d[i] / i
	it = 0
	while it < j:
		poss[i].append(curr)
		curr += 1
		it += 1
ans = []
for i in range(n):
	ans.append(poss[a[i]][(num[i] - 1) // a[i]])
for i in ans:
	if i > n:
		print('Impossible')
		sys.exit()
print('Possible')
print(' '.join(map(str, ans)))


N = int(input())
aN = list(map(int, input().split()))
for i in range(N):
	aN[i] = [N - aN[i], i + 1]
aN.sort()
b = 1
cnt = 0
for i in range(N):
	cnt += 1
	if aN[i][0] == cnt:
		for j in range(i + 1 - cnt, i + 1):
			if aN[j][0] != cnt:
				print('Impossible')
				exit()
			aN[j].append(b)
		b += 1
		cnt = 0
if len(aN[-1]) == 3:
	aN.sort(key=lambda x: x[1])
	print('Possible')
	for i in range(N):
		print(aN[i][2], end=' ')
else:
	print('Impossible')


n = int(input())
a = list(map(int, input().split()))
mark = [0 for i in range(n + 1)]
g = [0 for i in range(n + 1)]
l = set(a)
cur_gruop = 0
remove = 0
left = n - 1
idex = -1
ans = []
posible = 1
total = 0
for i in range(n):
	group = a[i]
	if group == 0 and len(l) > 1:
		posible = 0
		break
	if mark[group] > 0:
		ans.append(g[group])
		mark[group] -= 1
		remove -= 1
	else:
		cur_gruop += 1
		need = group - total
		if need < 0:
			posible = 0
			break
		elif need == 0:
			mark[group] = n - total - 1
			remove += mark[group]
			g[group] = cur_gruop
			idex = n - 1
			ans.append(cur_gruop)
		elif n - 1 - idex <= need:
			posible = 0
			break
		else:
			next = n - 1 - need - idex
			idex += next
			g[group] = cur_gruop
			ans.append(cur_gruop)
			mark[group] = next - 1
			total += next
			remove += next - 1
if posible and remove == 0:
	print('Possible')
	print(*ans)
else:
	print('Impossible')


n = int(input())
ch = {}
dif = [int(x) for x in input().split()]
same = []
ans = [0 for x in range(n)]
for x in dif:
	same.append(n - x)
for i in range(len(same)):
	if same[i] not in ch:
		ch[same[i]] = list()
	ch[same[i]].append(i)
cnt = 1
for (key, val) in ch.items():
	if len(val) % key:
		print('Impossible')
		quit()
	temp = key
	for x in val:
		if temp == 0:
			temp = key
			cnt += 1
		ans[x] = cnt
		temp -= 1
	cnt += 1
print('Possible')
for y in ans:
	print(y, end=' ')


from collections import Counter, defaultdict
input()
arr = list(map(int, input().split()))
counter = Counter(arr)
ans = [(x, counter[x]) for x in counter]
total = len(arr)
idx = 0
while idx < len(ans):
	value = ans[idx][0]
	occs = ans[idx][1]
	others = total - occs
	if others > value:
		print('Impossible')
		exit()
	elif others == value:
		idx += 1
		continue
	else:
		free = value - others
		if free >= occs:
			print('Impossible')
			exit()
		else:
			ans[idx] = (value, occs - free)
			ans.append((value, free))
			idx += 1
source = defaultdict(list)
color = 1
for (value, occ) in ans:
	source[value].extend([color] * occ)
	color += 1
result = list()
print('Possible')
for v in arr:
	result.append(source[v].pop())
print(*result)


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
if s.count(0) == n:
	print('Possible')
	print('1 ' * n)
	exit(0)
s1 = []
for i in range(n):
	s1.append((s[i], i))
s1.sort(reverse=True)
ans = [-1 for i in range(n)]
dif = 0
cur = 1
dp = [0 for i in range(n + 2)]
for i in range(n):
	ans[s1[i][1]] = cur
	dp[cur] += 1
	if n - (i + 1) == s1[i][0] - dif:
		dif = i + 1
		cur += 1
for i in range(n):
	if n - dp[ans[i]] != s[i]:
		print('Impossible')
		exit(0)
print('Possible')
print(*ans)


n = int(input())
a = [int(x) for x in input().split()]
total = []
counter = 0
for item in a:
	total.append(n - item)
tot = sorted(total)
tot.append(10 ** 10)
number = 1
forget = []
hats = 1
prev = tot[0]
for item in tot[1:]:
	if item == prev:
		hats += 1
	else:
		for i in range(hats // prev):
			for u in range(prev):
				forget.append(number)
			number += 1
		if hats % prev != 0:
			print('Impossible')
			break
		hats = 1
	prev = item
else:
	dic = {}
	i = 0
	for item in tot[:-1]:
		if item not in dic:
			dic[item] = [forget[i]]
		else:
			dic[item].append(forget[i])
		i += 1
	start = {}
	for item in dic:
		start[item] = 0
	answer = []
	for item in total:
		answer.append(dic[item][start[item]])
		start[item] += 1
	print('Possible')
	print(*answer)


input()
l = list(map(int, input().split()))
d = {}
d2 = {}
ans = []
n = 1
for i in l:
	i = len(l) - i
	if i not in d:
		d[i] = n
		n += 1
	if i not in d2:
		d2[i] = 0
	if d2[i] >= i:
		d[i] = n
		d2[i] = 0
		n += 1
	ans.append(d[i])
	d2[i] += 1
nums = {}
tot = 0
for i in ans:
	tot += 1
	if i not in nums:
		nums[i] = 0
	nums[i] += 1
for i in range(len(ans)):
	if tot - nums[ans[i]] != l[i]:
		print('Impossible')
		exit()
print('Possible')
print(' '.join(map(str, ans)))


n = int(input())
a = [int(x) for x in input().split()]
t = 0
d1 = {}
use1 = {}
use = {}
for x in a:
	if x in d1:
		if use1[x] == n - x:
			t += n - x
			use1[x] = 0
		use1[x] += 1
	else:
		d1[x] = 0
		t += n - x
		use1[x] = 1
if n != t:
	print('Impossible')
else:
	print('Possible')
	d = {}
	cv = 1
	for x in a:
		if x in d:
			if use[d[x]] == n - x:
				d[x] = cv
				cv += 1
				use[d[x]] = 0
			use[d[x]] += 1
			print(d[x], end=' ')
		else:
			d[x] = cv
			use[d[x]] = 1
			cv += 1
			print(d[x], end=' ')


n = int(input())
a = [int(element) for element in input().split(' ')]
b = dict()
for i in range(n):
	try:
		b[a[i]] += 1
	except:
		b[a[i]] = 1
c = [b[k] % (n - k) == 0 for k in list(b.keys())]
d = [b[k] for k in a]
if all(c):
	print('Possible')
	types = dict()
	hat = 1
	for k in list(b.keys()):
		pergroup = n - k
		groups = b[k] // pergroup
		hatsgroup = list()
		for i in range(groups):
			for j in range(pergroup):
				hatsgroup.append(hat)
			hat += 1
		types[k] = hatsgroup
	hats = list()
	for i in range(n):
		hats.append(types[a[i]].pop())
	print(' '.join((str(e) for e in hats)))
else:
	print('Impossible')


from collections import deque
adj = []
idx = []
res = []

def init(n):
	global adj
	global idx
	global res
	adj = [[] for _ in range(n + 1)]
	idx = [0 for _ in range(n + 1)]
	res = [-1 for _ in range(n + 1)]
n = int(input())
init(n)
arr = list(map(int, input().split()))
for i in range(n):
	adj[arr[i]].append(i)
ok = True
cur = 1
for i in range(n):
	if res[i] != -1:
		continue
	rem = n - arr[i]
	for _ in range(rem):
		if len(adj[arr[i]]) <= idx[arr[i]]:
			ok = False
			break
		res[adj[arr[i]][idx[arr[i]]]] = cur
		idx[arr[i]] += 1
	if not ok:
		break
	cur += 1
if ok:
	print('Possible')
	for i in range(n):
		print(res[i], end=' ')
else:
	print('Impossible')


n = int(input())
a = list(map(int, input().split()))
s = [0] * (n + 1)
v = [0] * (n + 1)
r = [0] * (n + 1)
b = [0] * n
m = 0
for i in range(n):
	a[i] = n - a[i]
	s[a[i]] += 1
for i in range(n):
	if r[a[i]] == 0:
		m += 1
		v[a[i]] = m
		r[a[i]] = a[i]
	b[i] = v[a[i]]
	r[a[i]] -= 1
if any((x for x in r)):
	print('Impossible')
	exit(0)
print('Possible')
print(*b)


import sys
n = int(input())
a = list(map(int, input().split()))
dik = {}
for _a in a:
	dik[n - _a] = dik.get(n - _a, 0) + 1
for k in dik:
	if dik[k] % k != 0:
		print('Impossible')
		sys.exit()
print('Possible')
arr = []
curr = 1
out_dik = {}
for k in dik:
	if n - k not in out_dik:
		out_dik[n - k] = []
	if dik[k] % k == 0:
		while dik[k] != 0:
			for _ in range(k):
				out_dik[n - k].append(curr)
			curr += 1
			dik[k] -= k
	else:
		for _ in range(dik[k]):
			out_dik[n - k].append(curr)
			curr += 1
for _a in a:
	print(out_dik[_a].pop(), end=' ')
print()


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
LIST = [[] for i in range(n + 1)]
for i in range(n):
	LIST[n - A[i]].append(i)
ANSLIST = [None] * (n + 1)
h = 1
for i in range(1, n + 1):
	if len(LIST[i]) % i != 0:
		print('Impossible')
		return
	else:
		j = 0
		while j < len(LIST[i]):
			ANSLIST[LIST[i][j]] = h
			j += 1
			if j % i == 0:
				h += 1
print('Possible')
for a in ANSLIST[:-1]:
	print(a, end=' ')


n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(n):
	s.append((n - a[i], i))
s.sort()
ans = []
t = 0
l = 0
for i in range(n):
	if l == 0:
		t += 1
		ans.append((s[i][1], t))
		l = s[i][0] - 1
	elif s[i][0] == s[i - 1][0]:
		l -= 1
		ans.append((s[i][1], t))
	else:
		print('Impossible')
		exit()
if t > n or l > 0:
	print('Impossible')
else:
	ans.sort()
	x = [ans[i][1] for i in range(n)]
	print('Possible')
	print(*x)


import sys
n = int(input())
a = {}
a_s = input().split()
for i in range(n):
	x = n - int(a_s[i])
	a[x] = a.get(x, 0) + 1
	a_s[i] = x
for i in a:
	if i < 1 or i > n:
		print('Impossible')
		sys.exit(0)
	if a[i] % i != 0:
		print('Impossible')
		sys.exit(0)
print('Possible')
used = 0
col = {}
num = {}
b = []
for x in a_s:
	if x not in col or num[x] == x:
		used += 1
		col[x] = used
		num[x] = 1
		b.append(used)
	else:
		num[x] += 1
		b.append(col[x])
print(' '.join(map(str, b)))


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(n):
	if arr[i] in d:
		d[arr[i]].append(i)
	else:
		d[arr[i]] = [i]
ans = [0] * n
e = 1
for i in d:
	k = n - i
	if len(d[i]) % k:
		print('Impossible')
		exit()
	else:
		m = d[i]
		l = 1
		flag = True
		for j in m:
			if l == k:
				ans[j] = e
				e += 1
				flag = True
				l = 1
			else:
				ans[j] = e
				l += 1
				flag = False
		if not flag:
			e += 1
print('Possible')
print(*ans)


def read(type=1):
	if type:
		file = open('input.dat', 'r')
		n = int(file.readline())
		a = list(map(int, file.readline().split()))
		file.close()
	else:
		n = int(input().strip())
		a = list(map(int, input().strip().split()))
	return (n, a)

def solve():
	sol = ''
	c = [0 for i in range(n)]
	val = [0 for i in range(n)]
	next = 1
	for i in range(n):
		v = n - a[i] - 1
		c[v] += 1
		if c[v] > v:
			c[v] = 0
			if val[v] == 0:
				val[v] = next
				next += 1
			sol += str(val[v]) + ' '
			val[v] = 0
		else:
			if val[v] == 0:
				val[v] = next
				next += 1
			sol += str(val[v]) + ' '
	if sum(c) == 0:
		print('Possible')
		return sol
	else:
		return 'Impossible'
(n, a) = read(0)
sol = solve()
print(sol)


from collections import Counter as C
n = int(input())
l = [*map(lambda x: n - int(x), input().split())]
c = C(l)
d = {}
try:
	for (k, v) in c.items():
		if v % k == 0:
			d[k] = v // k
		else:
			raise ValueError()
	print('Possible')
	d_ = {}
	curr = 0
	for e in l:
		if e in d_:
			if d_[e][1] >= e:
				curr += 1
				d_[e] = [curr, 1]
			else:
				d_[e][1] += 1
		else:
			curr += 1
			d_[e] = [curr, 1]
		print(d_[e][0], end=' ')
except:
	print('Impossible')


import math

def hats(n, arr):
	processed = [False] * n
	hats = [None] * n
	cur_hat = 0
	for (i, diff_count) in enumerate(arr):
		if processed[i]:
			continue
		cur_hat += 1
		hats[i] = cur_hat
		processed[i] = True
		same_count = n - diff_count - 1
		if not same_count:
			continue
		for j in range(i + 1, n):
			if arr[j] == diff_count:
				same_count -= 1
				processed[j] = True
				hats[j] = cur_hat
			if not same_count:
				break
		if same_count:
			print('Impossible')
			return
	print('Possible')
	print(' '.join(list(map(str, hats))))

def __starting_point():
	n = int(input())
	answers = list(map(int, input().strip().split()))
	hats(n, answers)
__starting_point()


n = int(input())
a = [int(s) for s in input().split(' ')]
b = [None] * n
c = {}
for (i, a_i) in enumerate(a):
	if a_i in c:
		c[a_i].append(i)
	else:
		c[a_i] = [i]
i = 1
while c:
	a_i = next(iter(c.keys()))
	needed = n - a_i
	for _ in range(needed):
		if not c[a_i]:
			print('Impossible')
			import sys
			sys.exit()
		b[c[a_i].pop()] = i
	if not c[a_i]:
		del c[a_i]
	i += 1
print('Possible')
print(' '.join((str(i) for i in b)))


n = int(input())
a = list(map(int, input().split()))
N = n + 1
c = [0] * N
b = [0] * n
e = {}
q = 0
z = 0
for i in range(N):
	e[i] = []
for i in range(n):
	c[n - a[i]] += 1
	e[n - a[i]] += [i]
for i in range(1, N):
	if c[i] % i > 0:
		print('Impossible')
		exit(0)
	elif c[i] > 0:
		z = i
		for x in e[i]:
			if z == i:
				q += 1
				z = 0
			z += 1
			b[x] = q
print('Possible')
for x in b:
	print(x, end=' ')


n = int(input())
a = list(map(int, input().split()))
c = 1
res = []
d = {}
v = {}
ok = True
for item in a:
	if d.get(item, 0) == 0:
		d[item] = n - item - 1
		v[item] = c
		c += 1
	else:
		d[item] -= 1
	res.append(v[item])
for (k, v) in d.items():
	if v != 0:
		ok = False
		break
if ok:
	print('Possible')
	print(' '.join(map(str, res)))
else:
	print('Impossible')


import math, sys
from fractions import *

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

def main():
	n = int(input())
	a = mp()
	cnt = [0] * (n + 1)
	for i in a:
		cnt[i] += 1
	k = 1
	ans = [[] for i in range(n + 1)]
	for i in range(n + 1):
		if cnt[i] == 0:
			continue
		while True:
			if cnt[i] + i >= n:
				ans[i].append([n - i, k])
				cnt[i] -= n - i
				k += 1
			elif cnt[i]:
				print('Impossible')
				return
			else:
				break
	print('Possible')
	for i in a:
		if ans[i][-1][0] == 0:
			ans[i].pop()
		print(ans[i][-1][1], end=' ')
		ans[i][-1][0] -= 1
deb = 0
if deb:
	file = open('input.txt', 'w')
else:
	input = sys.stdin.readline
main()


n = int(input())
k = 0
d = {}
i = 0
for x in map(int, input().split()):
	d.setdefault(n - x, []).append(i)
	i += 1
b = [0] * n
g = 0
for x in d:
	l = d[x]
	g += 1
	j = 0
	if len(l) % x:
		print('Impossible')
		break
	for i in l:
		if j == x:
			j = 0
			g += 1
		b[i] = g
		j += 1
else:
	print('Possible', *b)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	n = int(stdin.readline())
	a = [n] + [int(x) for x in stdin.readline().split()]
	c = [[]]
	for _ in range(n + 2):
		c.append([])
	b = [0]
	for i in range(1, 1 + n):
		x = a[i]
		c[n - x].append(i)
		b.append(i)
	for x in range(1, n + 1):
		if len(c[x]) > 0:
			m = len(c[x])
			if m % x > 0:
				stdout.write('Impossible')
				return 0
			for j in range(m):
				b[c[x][j]] = c[x][floor(j / x)]
	stdout.write('Possible\n' + ' '.join([str(x) for x in b[1:]]))
	return 0
main()


num = int(input())
nums = input()
statement = [int(i) for i in nums.split()]
log = {}
group_num = {}
anchor = 1
total = num
status = 'Possible'
ans = []
for (i, s) in enumerate(statement):
	if s not in log or group_num[s] == 0:
		log[s] = anchor
		anchor += 1
		group_num[s] = num - s
		total -= group_num[s]
		if total < 0:
			status = 'Impossible'
			break
	ans.append(log[s])
	group_num[s] -= 1
print(status)
if status == 'Possible':
	for i in range(num - 1):
		print(ans[i], end=' ')
	print(ans[num - 1])


n = int(input())
L = [n - int(x) for x in input().split()]
D = {}
for i in L:
	if i in D:
		D[i] += 1
	else:
		D[i] = 1
s = 0
check = True
for i in D.keys():
	if D[i] % i != 0:
		check = False
		break
	else:
		s += D[i]
if s != n:
	print('Impossible')
elif check == False:
	print('Impossible')
else:
	print('Possible')
	small = 1
	D2 = {}
	for i in D:
		D2[i] = list(range(small, small + D[i] // i)) * i
		small += D[i] // i
	for i in L:
		print(D2[i][-1], end=' ')
		D2[i].pop()


n = int(input())
b = list(map(int, input().split()))
a = [[b[i], i] for i in range(n)]
a.sort()
ans = [0] * n
cur = 0
num = 1
while cur < n:
	nec = a[cur][0]
	ng = False
	for i in range(n - nec):
		if cur + i >= n:
			ng = True
			break
		elif a[cur + i][0] != a[cur][0]:
			ng = True
			break
		else:
			ans[a[cur + i][1]] = num
	if ng:
		print('Impossible')
		break
	num += 1
	cur += n - nec
else:
	print('Possible')
	print(*ans)


n = int(input())
l = list(map(int, input().split()))
dict = {}
for i in range(n):
	dict[i] = l[i]
sorted_x = sorted(dict.items(), key=lambda kv: kv[1])
ind = []
for i in sorted_x:
	ind.append(i[0])
l.sort()
c = 1
ch = 0
z = 0
for i in range(0, n):
	if i != z:
		continue
	x = l[i]
	z = n - x
	for j in range(i, i + z):
		if j >= n or l[j] != x:
			print('Impossible')
			ch = 1
			break
		l[j] = c
	if ch:
		break
	c = c + 1
	z = z + i
if ch == 0:
	print('Possible')
	f = [0] * n
	x = 0
	for i in ind:
		f[i] = l[x]
		x = x + 1
	for i in f:
		print(i, end=' ')


import math

def __starting_point():
	n = int(input())
	arr = [int(x) for x in input().split()]
	ans = []
	d = {}
	c = {}
	b = [0] * n
	ind = 0
	for i in range(n):
		if arr[i] in list(d.keys()):
			if d[arr[i]] == 0:
				ind += 1
				c[arr[i]] = ind
				b[i] = ind
				d[arr[i]] = n - arr[i] - 1
			else:
				d[arr[i]] -= 1
				b[i] = c[arr[i]]
		else:
			ind += 1
			c[arr[i]] = ind
			b[i] = ind
			d[arr[i]] = n - arr[i] - 1
	ans = True
	for i in d:
		if d[i] != 0:
			ans = False
	if ans:
		print('Possible')
		print(*b)
	else:
		print('Impossible')
__starting_point()


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = int_array()
for i in range(n):
	a[i] = n - a[i]
dick = {}
for i in a:
	dick[i] = dick.get(i, 0) + 1
f = 1
for i in dick:
	if i == 0:
		continue
	if dick[i] % i != 0:
		f = 0
		break
if not f:
	print('Impossible')
	exit()
kick = {}
this = 1
for i in dick:
	kick[i] = []
for i in dick:
	if i == 0:
		for j in range(dick[i]):
			kick[i].append(this)
			this += 1
	else:
		k = dick[i] // i
		for j in range(k):
			for p in range(i):
				kick[i].append(this)
			this += 1
ans = [kick[i].pop() for i in a]
print('Possible')
print(*ans)


n = int(input())
a = list(map(int, input().split()))
d = {}
l = [[] for i in range(n + 1)]
for i in range(n):
	d[a[i]] = d.get(a[i], 0) + 1
	l[n - a[i]].append(i + 1)
b = list(d.keys())
c = []
for i in b:
	c.append([d[i] // (n - i), n - i])
k = 0
for i in c:
	k += i[0] * i[1]
if k != n:
	print('Impossible')
else:
	print('Possible')
	co = 1
	ans = [0] * (n + 1)
	for i in c:
		for j in range(i[0]):
			for k in range(i[1]):
				x = l[i[1]].pop()
				ans[x] = co
			co += 1
	print(*ans[1:])


n = int(input())
a = list(map(int, input().split(' ')))
same = [n - a[i] for i in range(n)]
color = [-1 for i in range(n)]
assigned = [0 for i in range(n + 1)]
current = dict()
last_color = 1
for i in range(n):
	if same[i] in current and assigned[same[i]] == same[i] or not same[i] in current:
		current[same[i]] = last_color
		last_color += 1
		assigned[same[i]] = 0
	color[i] = current[same[i]]
	assigned[same[i]] += 1
ok = True
for num in range(2, n + 1):
	if assigned[num] % num != 0:
		ok = False
		break
if ok:
	print('Possible')
	print(' '.join(map(str, color)))
else:
	print('Impossible')


def mi():
	return map(int, input().split())
n = int(input())
a = list(mi())
from collections import Counter
c = Counter(a)
b = a.copy()
for i in range(n):
	a[i] = [n - a[i], i, 0]
a.sort()
i = 0
k = 1
while i < n:
	j = 0
	t = a[i][0]
	while i + j < n and a[i][0]:
		a[i + j][2] = k
		a[i][0] -= 1
		j += 1
	k += 1
	i += t
for i in range(n):
	a[i] = [a[i][1], a[i][2]]
a.sort()
for i in range(n):
	a[i] = a[i][1]
d = Counter(a)
for i in range(n):
	if n - d[a[i]] != b[i]:
		print('Impossible')
		exit(0)
print('Possible')
print(*a)


from itertools import combinations
from sys import stdin, stdout

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

def stringListIn():
	return [x for x in stdin.readline().split()]

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

def stringIn():
	return stdin.readline()

def solve(a, n):
	aa = [0] * n
	for i in range(n):
		aa[i] = n - a[i]
	cnt = {}
	pos = {}
	for i in range(n):
		e = aa[i]
		if e not in cnt:
			cnt[e] = 1
			pos[e] = [i + 1]
		else:
			cnt[e] += 1
			pos[e].append(i + 1)
	flag = False
	for ele in cnt:
		if cnt[ele] % ele != 0:
			flag = True
			break
	if flag:
		return 'Impossible'
	else:
		print('Possible')
		ans = [0] * n
		x = 1
		for ele in cnt:
			y = cnt[ele] // ele
			cn = 0
			xx = x
			for p in pos[ele]:
				ans[p - 1] = xx
				cn += 1
				if cn == ele:
					xx += 1
					cn = 0
			x += y
		return ans
n = intIn()
a = listIn()
ans = solve(a, n)
if type(ans) == list:
	print(*ans)
else:
	print(ans)


n = int(input())
a = [int(x) for x in input().split()]
ans = [0] * n
kol = {}
c = {}
x = 0
for i in range(n):
	if a[i] in kol.keys():
		if kol[a[i]] == 0:
			x += 1
			ans[i] = x
			kol[a[i]] = n - a[i] - 1
			c[a[i]] = x
		else:
			kol[a[i]] -= 1
			ans[i] = c[a[i]]
	else:
		x += 1
		ans[i] = x
		kol[a[i]] = n - a[i] - 1
		c[a[i]] = x
for x in kol:
	if kol[x] != 0:
		print('Impossible')
		exit()
print('Possible')
print(*ans)


n = int(input())
l = list(map(int, input().split()))

def f(l, n):
	d = {}
	for i in l:
		if i not in d.keys():
			d[i] = 1
		else:
			d[i] += 1
	c = 1
	for i in d.keys():
		if i + d[i] == n:
			d[i] = str(c) + ' '
			c += 1
		elif d[i] % (n - i) == 0:
			ng = n - i
			nv = d[i] // (n - i)
			d[i] = []
			for j in range(nv):
				d[i].append(c)
				c += 1
			d[i] *= ng
			d[i].append(0)
		else:
			return 'Impossible'
	c = 'Possible\n'
	for i in l:
		if type(d[i]) == str:
			c += d[i]
		else:
			c += str(d[i][d[i][-1]]) + ' '
			d[i][-1] += 1
	c += '\n'
	return c
print(f(l, n))


n = int(input())
gr_to_count = {}
for (i, x) in enumerate([int(x) for x in input().split()]):
	my = n - x
	if my in gr_to_count:
		gr_to_count[my] += [i]
	else:
		gr_to_count[my] = [i]
if all([len(gr) % size == 0 for (size, gr) in gr_to_count.items()]):
	person_to_gr = [0] * n
	i = 0
	for (size, gr) in gr_to_count.items():
		for j in range(0, len(gr), size):
			for k in range(size):
				person_to_gr[gr[j + k]] = i
			i += 1
	print('Possible')
	print(' '.join(map(str, map(lambda x: x + 1, person_to_gr))))
else:
	print('Impossible')


n = int(input())
a = list(map(int, input().split()))
req = []
ans = [0] * n
for i in range(n):
	req.append([n - 1 - a[i], i])
req.sort()
val = 0
i = 0
f = 1
while i < n:
	val += 1
	x = req[i][0]
	if i + x + 1 > n:
		f = 0
		break
	for j in range(i, i + x + 1):
		if req[j][0] != x:
			f = 0
			break
		else:
			ans[req[j][1]] = val
	if f == 0:
		break
	i += x + 1
if f == 0:
	print('Impossible')
else:
	print('Possible')
	print(*ans)


n = int(input())
seq = list(map(int, input().split()))
dseq = {}
for i in range(len(seq)):
	s = seq[i]
	try:
		dseq[s].append(i)
	except KeyError:
		dseq[s] = [i]
impo = False
ans = [0 for x in range(n)]
cur = n
num = 1
for ds in dseq:
	lends = len(dseq[ds])
	i = 0
	while lends > 0:
		lends -= n - ds
		cur -= lends
		for _ in range(n - ds):
			try:
				ans[dseq[ds][i]] = num
			except IndexError:
				impo = True
				break
			i += 1
		num += 1
	if impo or lends < 0:
		impo = True
		break
if impo:
	print('Impossible')
else:
	print('Possible')
	print(' '.join(map(str, ans)))


n = int(input())
a = list(map(int, input().split()))
if 0 in a:
	if len(set(a)) > 1:
		print('Impossible')
	else:
		print('Possible')
		print(*[1] * n)
elif not all((q < n for q in a)):
	print('Impossible')
else:
	s = {}
	answer = [0 for q in range(n)]
	for q in range(len(a)):
		if a[q] in s:
			s[a[q]].append(q)
		else:
			s[a[q]] = [q]
	q2 = 0
	for q in s:
		if len(s[q]) % (n - q) != 0:
			print('Impossible')
			break
		for q1 in range(len(s[q])):
			if q1 % (n - q) == 0:
				q2 += 1
			answer[s[q][q1]] = q2
	else:
		print('Possible')
		print(*answer)


from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
counter = Counter(arr)
flag = 0
f = False
num_group = {}
for (a, b) in counter.items():
	x = a - (n - b)
	if int(b / (b - x)) == b / (b - x):
		num_group[a] = b // (b - x)
	else:
		f = True
		break
if f:
	print('Impossible')
else:
	c = 1
	number = {}
	for x in counter:
		for i in range(num_group[x]):
			for z in range(counter[x] // num_group[x]):
				if x in number:
					number[x].append(c + i)
				else:
					number[x] = [c + i]
		c += num_group[x]
	print('Possible')
	for x in arr:
		print(number[x][0], end=' ')
		del number[x][0]
	print()


from operator import itemgetter
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (n + 1)
ans = [0] * n
for i in range(n):
	a[i] = [a[i], i]
a.sort(key=itemgetter(0))
uk = 0
for i in range(n):
	if cnt[uk] == 0:
		uk += 1
		cnt[uk] = n - a[i][0] - 1
		ans[a[i][1]] = uk
	else:
		if a[i][0] != a[i - 1][0]:
			print('Impossible')
			exit()
		cnt[uk] -= 1
		ans[a[i][1]] = uk
if cnt.count(0) != len(cnt):
	print('Impossible')
else:
	print('Possible')
	for i in range(n):
		print(ans[i], end=' ')


from collections import Counter
n = int(input())
arr = sorted([(n - int(x), i) for (i, x) in enumerate(input().split())])
ls = [0] * n
s = Counter((arr[i][0] for i in range(n)))
if all([size % ele == 0 for (ele, size) in s.items()]):
	var = arr[0][0]
	f = 1
	for i in range(n):
		ls[arr[i][1]] = f
		var -= 1
		if var == 0 and i < n - 1:
			var = arr[i + 1][0]
			f += 1
	print('Possible')
	print(*ls)
else:
	print('Impossible')
	exit()


n = int(input())
a = list(map(int, input().split()))
s = {}
for i in range(n):
	b = []
	if a[i] in s:
		b = s[a[i]]
	else:
		s[a[i]] = b
	b.append(i)
h = 1
o = ['0'] * n
for k in s:
	while len(s[k]) >= n - k > 0:
		for i in range(n - k):
			o[s[k].pop()] = str(h)
		h += 1
	if len(s[k]) != 0:
		print('Impossible')
		exit()
print('Possible')
print(' '.join(o))


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(list)
for j in range(n):
	d[a[j]].append(j)
f = 0
m = 1
for v in d:
	p = n - v
	if len(d[v]) % p != 0:
		f = 1
		break
	else:
		while d[v] != []:
			for j in range(p):
				q = d[v].pop()
				a[q] = m
			m = m + 1
if f == 0:
	print('Possible')
	print(' '.join(map(str, a)))
else:
	print('Impossible')


n = int(input())
a = list(map(int, input().split()))
counts = [0] * n
done = False
for i in range(n):
	counts[a[i]] += 1
for i in range(n):
	if counts[i] % (n - i) != 0:
		print('Impossible')
		done = True
		break
	else:
		counts[i] //= n - i
countsum = [counts[0]]
for i in range(n - 1):
	countsum.append(countsum[-1] + counts[i + 1])
b = []
seen = [0] * n
for i in range(n):
	b.append(countsum[a[i]] - seen[a[i]] // (n - a[i]))
	seen[a[i]] += 1
out = ''
for i in range(n):
	out += str(b[i]) + ' '
if not done:
	print('Possible')
	print(out[:-1])


import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a = [(i, n - a[i]) for i in range(n)]
a.sort(key=lambda k: k[1])
cnt = Counter((t[1] for t in a))
for k in cnt.keys():
	if cnt[k] % k != 0:
		print('Impossible')
		exit()
ans = [-1] * n
cnt = 1
i = 0
while i < n:
	(_, c) = a[i]
	for (j, _) in a[i:i + c]:
		ans[j] = cnt
	i += c
	cnt += 1
print('Possible')
print(*ans)


from collections import Counter
n = int(input())
p = [int(x) for x in input().split()]
d = Counter()
for x in p:
	d[n - x] += 1
can = True
for x in d:
	if d[x] % x != 0:
		can = False
		break
if can:
	print('Possible')
	d = {}
	count = {}
	res = []
	k = 1
	for x in p:
		if x in d and count[x] < n - x:
			res.append(d[x])
			count[x] += 1
		else:
			d[x] = k
			count[x] = 1
			res.append(k)
			k += 1
	print(*res, sep=' ')
else:
	print('Impossible')


n = int(input())
ar = list(map(int, input().split(' ')))
ar1 = [[ar[i], i] for i in range(len(ar))]
ar1.sort()
res = [0] * n
t = 1
ndiff = [0] * (n + 1)
for i in range(n):
	ndiff[ar1[i][0]] += 1
i = 0
t = 1
possible = 1
while i < n:
	x = ndiff[ar1[i][0]]
	k = n - ar1[i][0]
	if x % k != 0:
		print('Impossible')
		exit(0)
	for j in range(k):
		res[ar1[i][1]] = t
		i += 1
	t += 1
print('Possible')
for i in range(n):
	print(res[i], end=' ')


n = int(input())
a = list(map(int, input().split(' ')))
d = {}
for i in range(n):
	if a[i] in d.keys():
		d[a[i]] += 1
	else:
		d[a[i]] = 1
c = 1
for i in d.keys():
	if d[i] % (n - i) != 0:
		print('Impossible')
		c = 0
		break
if c == 1:
	print('Possible')
	k = 1
	e = {}
	for i in d.keys():
		e[i] = []
	for i in d.keys():
		for j in range(d[i] // (n - i)):
			e[i].append(k)
			k += 1
	f = {}
	for i in range(n):
		if a[i] not in f.keys():
			f[a[i]] = 1
		else:
			f[a[i]] += 1
		if f[a[i]] > n - a[i]:
			if f[a[i]] % (n - a[i]) == 0:
				print(e[a[i]][f[a[i]] // (n - a[i]) - 1], end=' ')
			else:
				print(e[a[i]][f[a[i]] // (n - a[i])], end=' ')
		else:
			print(e[a[i]][0], end=' ')


n = int(input())
aa = list(map(int, input().split()))

def cal():
	ncol = [0] * (n + 1)
	ansmap = [0] * n
	ans = [0] * n
	colcnt = [0] * (n + 1)
	colmap = [0] * (n + 1)
	icol = 0
	for (i, a) in enumerate(aa):
		ncol[n - a] += 1
		ansmap[i] = n - a
	for (i, col) in enumerate(ncol[1:], 1):
		if col % i:
			return
	for (i, col) in enumerate(ansmap):
		if not colcnt[col] % col:
			icol += 1
			colmap[col] = icol
		ans[i] = colmap[col]
		colcnt[col] += 1
	return ans
ans = cal()
if ans:
	print('Possible')
	print(' '.join(map(str, ans)))
else:
	print('Impossible')


n = int(input())
lis = list(map(int, input().split()))
ans = [0] * 100001
for i in lis:
	ans[i] += 1
c = 1
aaa = [0] * n
for i in range(n):
	if ans[i] > 0:
		k = n - i
		if ans[i] % k != 0:
			print('Impossible')
			exit()
		if (ans[i] // k - 1) * k + n - ans[i] != i:
			print('Impossible')
			exit()
		else:
			batch = ans[i] // k
			l = 0
			for j in range(batch):
				co = 0
				while l < n and co < k:
					if lis[l] == i:
						aaa[l] = c
						co += 1
					l += 1
				c += 1
print('Possible')
print(*aaa)


n = int(input())
a = list(map(int, input().split()))
a = [n - x for x in a]
groups = {}
for (i, x) in enumerate(a):
	if x not in groups:
		groups[x] = []
	groups[x].append(i)
hats = [0] * n
current_hat = 1
for (count, ids) in groups.items():
	if len(ids) % count != 0:
		print('Impossible')
		exit(0)
	for g in range(len(ids) // count):
		for _id in ids[count * g:count * (g + 1)]:
			hats[_id] = current_hat
		current_hat += 1
print('Possible')
print(*hats)


n = int(input())
a = [int(s) for s in input().split()]
b = [-1 for i in range(n)]
m = {}
nextnum = 1
for i in range(n):
	if b[i] == -1:
		if m.get(a[i]) and m[a[i]][1] > 0:
			b[i] = m[a[i]][0]
			m[a[i]][1] -= 1
			if m[a[i]][1] == 0:
				m.pop(a[i])
		else:
			z = n - a[i] - 1
			b[i] = nextnum
			if z:
				m[a[i]] = [nextnum, z]
			nextnum += 1
if m:
	print('Impossible')
else:
	print('Possible')
	print(*b)


from collections import defaultdict
n = int(input())
b = list(map(int, input().split()))
counts = defaultdict(int)
to_check = set()
hat_type = []
hat_index = dict()
last_index = [0] * n
for bi in b:
	i = last_index[bi]
	key = f'{bi}_{i}'
	if bi == n - counts[key]:
		last_index[bi] += 1
		key = f'{bi}_{i + 1}'
	counts[key] += 1
	to_check.add((bi, key))
	hat_type.append(key)
for (i, key) in to_check:
	if i != n - counts[key]:
		print('Impossible')
		exit(0)
print('Possible')
(arr, j) = ([], 1)
for (i, key) in to_check:
	hat_index[key] = j
	j += 1
for key in hat_type:
	arr.append(hat_index[key])
print(*arr)