While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a_1, a_2, ..., a_{m} of length m, consisting of integers from 1 to n, not necessarily distinct. Then he picked some sequence f_1, f_2, ..., f_{n} of length n and for each number a_{i} got number b_{i} = f_{a}_{i}. To finish the prank he erased the initial sequence a_{i}.

It's hard to express how sad Patrick was when he returned home from shopping! We will just say that Spongebob immediately got really sorry about what he has done and he is now trying to restore the original sequence. Help him do this or determine that this is impossible.


-----Input-----

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the lengths of sequences f_{i} and b_{i} respectively.

The second line contains n integers, determining sequence f_1, f_2, ..., f_{n} (1 ≤ f_{i} ≤ n).

The last line contains m integers, determining sequence b_1, b_2, ..., b_{m} (1 ≤ b_{i} ≤ n).


-----Output-----

Print "Possible" if there is exactly one sequence a_{i}, such that b_{i} = f_{a}_{i} for all i from 1 to m. Then print m integers a_1, a_2, ..., a_{m}.

If there are multiple suitable sequences a_{i}, print "Ambiguity".

If Spongebob has made a mistake in his calculations and no suitable sequence a_{i} exists, print "Impossible".


-----Examples-----
Input
3 3
3 2 1
1 2 3

Output
Possible
3 2 1 

Input
3 3
1 1 1
1 1 1

Output
Ambiguity

Input
3 3
1 2 1
3 3 3

Output
Impossible



-----Note-----

In the first sample 3 is replaced by 1 and vice versa, while 2 never changes. The answer exists and is unique.

In the second sample all numbers are replaced by 1, so it is impossible to unambiguously restore the original sequence.

In the third sample f_{i} ≠ 3 for all i, so no sequence a_{i} transforms into such b_{i} and we can say for sure that Spongebob has made a mistake.

Difficulty: interview

Starter code:

Solutions:
n, m = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = [-1] * 100001
for i in range(n):
	if a[f[i]] != -1:
		a[f[i]] = -2
	else:
		a[f[i]] = i
for i in b:
	if a[i] == -1:
		print('Impossible')
		return
for i in b:
	if a[i] == -2:
		print('Ambiguity')
		return
print('Possible')
for i in b:
	print(a[i] + 1, end=' ')

#!/usr/bin/env python3

from collections import defaultdict

try:
    while True:
        n, m = list(map(int, input().split()))
        f = list(map(int, input().split()))
        b = list(map(int, input().split()))
        d = [[ ] for i in range(n + 1)]
        for i, x in enumerate(f, 1):
            d[x].append(i)
        a = [None] * m
        ambigious = False
        for i in range(m):
            x = d[b[i]]
            if not x:
                print("Impossible")
                break
            if len(x) != 1:
                ambigious = True
            else:
                a[i] = x[0]
        else:
            if ambigious:
                print("Ambiguity")
            else:
                print("Possible")
                print(' '.join(map(str, a)))
except EOFError:
    pass


import collections

n, m = map(int, input().split())
fs = list(map(int, input().split()))
bs = list(map(int, input().split()))

def solve(n, m, fs, bs):
    if not is_possible(n, m, fs, bs):
        print('Impossible')
        return
    ans = solve2(n, m, fs, bs)
    if not ans:
        print('Ambiguity')
    else:
        print('Possible')
        print(*ans)
        
def is_possible(n, m, fs, bs):
    setf = set(fs)
    setb = set(bs)
    return setb <= setf


def solve2(n, m, fs, bs):
    finv = collections.defaultdict(set)
    for i, f in enumerate(fs):
        finv[f].add(i)
    As = []
    for b in bs:
        fb = finv[b]
        if len(fb) > 1:
            return False
        for a in fb:
            As.append(a + 1)
    return As
    


solve(n, m, fs, bs)

def main():
    n, m = [int(i) for i in input().split()]
    f = [-1] + [int(i) for i in input().split()]
    b = [-1] + [int(i) for i in input().split()]
    
    d = [-1] * (n + 1)
    cnt = [0] * (n + 1)
    for i in range(1, n + 1):
        cnt[f[i]] += 1
        d[f[i]] = i
   
    a = [-1] * (m + 1)
    for i in range(1, m + 1):
        a[i] = d[b[i]]
        if d[b[i]] == -1:
            print("Impossible")
            return
    for i in range(1, m + 1):
        if cnt[b[i]] > 1:
            print("Ambiguity")
            return
    print("Possible")
    print(' '.join(str(i) for i in a[1:]))
    

main()

__author__ = 'MoonBall'

import sys
# sys.stdin = open('data/B.in', 'r')
T = 1

def process():
    N, M = list(map(int, input().split()))
    f = list(map(int, input().split()))
    b = list(map(int, input().split()))

    fc = {}
    for idx, fv in enumerate(f): fc[fv] = (1, idx) if not fc.get(fv) else (fc[fv][0] + 1, idx)

    a = []
    failed = False
    multi = False
    for bv in b:
        if not fc.get(bv):
            failed = True
            continue
        if fc[bv][0] > 1:
            multi = True
            continue
        a.append(fc[bv][1] + 1)

    if failed:
        print('Impossible')
    elif multi:
        print('Ambiguity')
    else:
        print('Possible')
        print(' '.join(map(str, a)))







for _ in range(T):
    process()


n, m = map(int, input().split())
f = list(map(int, input().split()))
b = list(map(int, input().split()))
s1 = set(f)
s2 = set(b)
ans = []
if s2 <= s1:
    d = {}
    for i in range(len(f)):
        if f[i] in d:
            d[f[i]].append(i + 1)
        else:
            d[f[i]] = [i + 1]
    for u in b:
        if u in d and len(d[u]) > 1:
            print('Ambiguity')
            break
        elif u in d:
            ans.append(d[u][0])
    else:
        print('Possible')
        print(' '.join(map(str, ans)))
else:
    print('Impossible')

#n = int(input())
from collections import defaultdict
god = defaultdict(int)
n, m = [int(i) for i in input().split(" ")]
fuck = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
for i in fuck:
    god[i] += 1
ans = []
f = dict( zip(fuck, range(1, n+1)) )
s = set( fuck )
answ = "Possible"
for i in b:
    if not i in s:
        answ = "Impossible"
        break
    elif god[i] > 1:
        answ = "Ambiguity"
    else:
        ans.append(f[i])

print(answ)
if answ == "Possible":
    for i in ans:
        print(i, end=' ')


n, m = map(int, input().split())
f = list(map(int, input().split()))
b = list(map(int, input().split()))
f_back = dict()
keys = set()
for i in range(n):
    if f[i] in keys:
        f_back[f[i]] = -1
    else:
        f_back[f[i]] = i
        keys.add(f[i])
state = 1
a = [0] * m
for i in range(m):
    if b[i] in keys:
        if state == 1:
            if f_back[b[i]] == -1:
                state = 2
            else:
                a[i] = f_back[b[i]] + 1
    else:
        state = 0
        break
if state == 1:
    print('Possible')
    print(' '.join(map(str, a)))
elif state == 2:
    print('Ambiguity')
else:
    print('Impossible')

n,m = map(int, input().split())
f = []
b = []
x = []
y = []
f = list(map(int, input().split()))
for i in range(n):
	x.append(0)
	y.append(0)
for i in range(n):
	x[f[i]-1] = x[f[i]-1] + 1
	y[f[i]-1] = i + 1
b = list(map(int, input().split()))
amb = 0
imp = 0
for i in range(m):
	if x[b[i]-1] > 1:
		amb = 1
	elif x[b[i]-1] == 0:
		imp = 1

if imp > 0:
	print("Impossible")	
elif amb > 0:
	print("Ambiguity")
elif 1 == 1:
	print("Possible")	
	for i in range(m):
		print( str(y[b[i]-1]) + " ", end="")		

n, m = [int(x) for x in input().split()]
f = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(n):
    f[i] = [f[i], i]
for i in range(m):
    b[i] = [b[i], i]
f.sort()
b.sort()
ans = [0] * m
j = 0
i = 0
flag = 0
while i < m and j < n:
    if b[i][0] < f[j][0]:
        flag = 1
        print('Impossible')
        break
    elif b[i][0] == f[j][0]:
        ans[b[i][1]] = f[j][1] + 1
        i += 1
        if j < n - 1 and f[j + 1][0] == f[j][0]:
            flag = 2
    else:
        j += 1
if i < m and flag != 1 :
    print('Impossible')
elif flag == 2:
    print('Ambiguity')
elif flag == 0:
    print('Possible')
    print(*ans)

n, m = map(int, input().split())

f = list(map(int, input().split()))
b = list(map(int, input().split()))

f_count = [0 for i in range(n + 1)]
f_pos = [0 for i in range(n + 1)]

for i in range(n):
    f_pos[f[i]] = i + 1
    f_count[f[i]] += 1
ans = []
Ambiguity = False
Impossible = False
for i in range(m):
    if f_count[b[i]] == 1:
        ans.append(f_pos[b[i]])
    elif f_count[b[i]] == 0:
        Impossible = True
        break
    else:
        Ambiguity = True

if Impossible:
    print('Impossible')
elif Ambiguity:
    print('Ambiguity')
else:
    print('Possible')
    print(*ans)

"""
Codeforces Round #332

Problem 599 B. Spongebob and Joke

@author yamaton
@date 2015-11-20
"""


def solve(fs, bs, n, m):
    set_fs = set(fs)
    set_bs = set(bs)
    if not all(b in set_fs for b in bs):
        return ('Impossible', )

    # if len(bs) != len(set_bs):
    #     return ('Ambiguity', )

    ys = [f for f in fs if f in set_bs]
    if len(ys) != len(set(ys)):
        return ('Ambiguity',)

    d = {f: i for (i, f) in enumerate(fs, 1) if f in set_bs}
    return ('Possible', [d[b] for b in bs])


# def p(*args, **kwargs):
#     return print(*args, file=sys.stderr, **kwargs)


def main():
    [n, m] = list(map(int, input().strip().split()))
    fs = [int(_c) for _c in input().strip().split()]
    bs = [int(_c) for _c in input().strip().split()]
    assert len(fs) == n
    assert len(bs) == m

    result = solve(fs, bs, n, m)

    if len(result) == 1:
        print(result[0])
    else:
        print(result[0])
        print(*result[1])


def __starting_point():
    main()

__starting_point()

from collections import Counter
n, m = list(map(int, input().split()))
f = list(map(int, input().split()))
b = list(map(int, input().split()))

ctf, ctb = Counter(f), Counter(b)
possible = True
ambiguous = False
for k, v in list(ctb.items()):
    if k not in ctf:
        possible = False
    if ctf[k] >= 2:
        ambiguous = True
idx = {}
for i, v in enumerate(f):
    idx[v] = i + 1
if not possible:
    print('Impossible')
elif ambiguous:
    print('Ambiguity')
else:
    print('Possible')
    a = []
    for v in b:
        a.append(idx[v])
    print(' '.join(map(str, a)))


from collections import Counter

def solve(n, m, f, b):
    d1 = Counter(f)
    d2 = Counter(b)
    flag1, flag2 = True, False
    for k, v in d2.items():
        if k not in d1:
            flag1 = False
            break
    if not flag1:
        print('Impossible')
        return
    for k, v in d2.items():
        if d1[k] > 1:
            flag2 = True
            break
    if flag2:
        print('Ambiguity')
        return
    d = {k : pos for pos, k in enumerate(f, start = 1)}
    print('Possible')
    for value in b:
        print(d[value], end=' ')

n, m = map(int, input().split())

f = list(map(int, input().split()))
b = list(map(int, input().split()))

solve(n, m, f, b)


#!/usr/bin/env python3
# 599B_sponge.py - Codeforces.com/problemset/problem/599/B by Sergey 2015

import unittest
import sys

###############################################################################
# Sponge Class (Main Program)
###############################################################################


class Sponge:
    """ Sponge representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else sys.stdin.readline().rstrip()

        # Reading single elements
        [self.n, self.m] = list(map(int, uinput().split()))

        # Reading a single line of multiple elements
        self.numf = list(map(int, uinput().split()))

        # Reading a single line of multiple elements
        self.numb = list(map(int, uinput().split()))

        self.fd = {}
        self.fdn = {}
        for (i, n) in enumerate(self.numf):
            self.fd[n] = self.fd.setdefault(n, 0) + 1
            self.fdn[n] = i + 1
        self.bd = {}
        for (i, n) in enumerate(self.numb):
            self.bd[n] = self.bd.setdefault(n, 0) + 1

    def calculate(self):
        """ Main calcualtion function of the class """

        result = []
        for n in self.numb:
            if n not in self.fd:
                return "Impossible"
        for n in self.numb:
            if self.fd[n] > 1:
                return "Ambiguity"
            result.append(self.fdn[n])

        return "Possible\n" + " ".join(map(str, result))

###############################################################################
# Unit Tests
###############################################################################


class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Sponge class testing """

        # Constructor test
        test = "3 3\n3 2 1\n1 2 3"
        d = Sponge(test)
        self.assertEqual(d.n, 3)
        self.assertEqual(d.m, 3)
        self.assertEqual(d.numf, [3, 2, 1])
        self.assertEqual(d.numb, [1, 2, 3])

        # Sample test
        self.assertEqual(Sponge(test).calculate(), "Possible\n3 2 1")

        # Sample test
        test = "3 3\n1 1 3\n1 2"
        self.assertEqual(Sponge(test).calculate(), "Impossible")

        # Sample test
        test = "3 3\n1 1 1\n1 1 1"
        self.assertEqual(Sponge(test).calculate(), "Ambiguity")

        # My tests
        test = ""
        # self.assertEqual(Sponge(test).calculate(), "0")

        # Time limit test
        # self.time_limit_test(5000)

    def time_limit_test(self, nmax):
        """ Timelimit testing """
        import random
        import timeit

        # Random inputs
        test = str(nmax) + " " + str(nmax) + "\n"
        numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
        test += "\n".join(numnums) + "\n"
        nums = [random.randint(1, 10000) for i in range(nmax)]
        test += " ".join(map(str, nums)) + "\n"

        # Run the test
        start = timeit.default_timer()
        d = Sponge(test)
        calc = timeit.default_timer()
        d.calculate()
        stop = timeit.default_timer()
        print(("\nTimelimit Test: " +
              "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
              format(stop-start, calc-start, stop-calc)))

def __starting_point():

    # Avoiding recursion limitaions
    sys.setrecursionlimit(100000)

    if sys.argv[-1] == "-ut":
        unittest.main(argv=[" "])

    # Print the result string
    sys.stdout.write(Sponge().calculate())

__starting_point()

#!/usr/bin/env python3
# 599B_sponge.py - Codeforces.com/problemset/problem/599/B by Sergey 2015

import unittest
import sys

###############################################################################
# Sponge Class (Main Program)
###############################################################################


class Sponge:
    """ Sponge representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else sys.stdin.readline().rstrip()

        # Reading single elements
        [self.n, self.m] = list(map(int, uinput().split()))

        # Reading a single line of multiple elements
        self.numf = list(map(int, uinput().split()))

        # Reading a single line of multiple elements
        self.numb = list(map(int, uinput().split()))

        self.fd = {}
        self.fdn = {}
        for (i, n) in enumerate(self.numf):
            self.fd[n] = self.fd.setdefault(n, 0) + 1
            self.fdn[n] = i + 1

    def calculate(self):
        """ Main calcualtion function of the class """

        result = []
        for n in self.numb:
            if n not in self.fd:
                return "Impossible"
            result.append(self.fdn[n])
        for n in self.numb:
            if self.fd[n] > 1:
                return "Ambiguity"

        return "Possible\n" + " ".join(map(str, result))

###############################################################################
# Unit Tests
###############################################################################


class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Sponge class testing """

        # Constructor test
        test = "3 3\n3 2 1\n1 2 3"
        d = Sponge(test)
        self.assertEqual(d.n, 3)
        self.assertEqual(d.m, 3)
        self.assertEqual(d.numf, [3, 2, 1])
        self.assertEqual(d.numb, [1, 2, 3])

        # Sample test
        self.assertEqual(Sponge(test).calculate(), "Possible\n3 2 1")

        # Sample test
        test = "3 3\n1 1 3\n1 2"
        self.assertEqual(Sponge(test).calculate(), "Impossible")

        # Sample test
        test = "3 3\n1 1 1\n1 1 1"
        self.assertEqual(Sponge(test).calculate(), "Ambiguity")

        # My tests
        test = ""
        # self.assertEqual(Sponge(test).calculate(), "0")

        # Time limit test
        # self.time_limit_test(5000)

    def time_limit_test(self, nmax):
        """ Timelimit testing """
        import random
        import timeit

        # Random inputs
        test = str(nmax) + " " + str(nmax) + "\n"
        numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
        test += "\n".join(numnums) + "\n"
        nums = [random.randint(1, 10000) for i in range(nmax)]
        test += " ".join(map(str, nums)) + "\n"

        # Run the test
        start = timeit.default_timer()
        d = Sponge(test)
        calc = timeit.default_timer()
        d.calculate()
        stop = timeit.default_timer()
        print(("\nTimelimit Test: " +
              "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
              format(stop-start, calc-start, stop-calc)))

def __starting_point():

    # Avoiding recursion limitaions
    sys.setrecursionlimit(100000)

    if sys.argv[-1] == "-ut":
        unittest.main(argv=[" "])

    # Print the result string
    sys.stdout.write(Sponge().calculate())

__starting_point()

input()
f, b = [list(map(int, input().split())) for _ in range(2)]
d = {}
z = []
for i in range(len(f)):
    if f[i] in d:
        z.append(f[i])
    d[f[i]] = i + 1
ans = 2
for it in b:
    if it not in d:
        ans = 0
if ans != 0:
    if len(d) < len(f):
        for it in z:
            if it in b:
                ans = 1
                break
if ans == 2:
    print('Possible')
    print(' '.join(str(d[i]) for i in b))
elif ans == 1:
    print('Ambiguity')
else:
    print('Impossible')




ans=[]
def func(f,b):
    nonlocal ans
    dic={}
    k=0
    for i in range(len(f)):
        dic[f[i]]=-1
    for i in range(len(f)):
        if dic[f[i]]!=-1:
            dic[f[i]]=-10
        else:
            dic[f[i]]=i+1
    for i in b:
        if i in dic:
            if dic[i]==-10:
                k=1
            ans.append(dic[i])
        else:
            return 3
    if k:
        return 2
    return 1


q=list(map(int,input().split()))
n,m=q[0],q[1]
f=list(map(int,input().split()))
b=list(map(int,input().split()))
p=func(f,b)
if p==1:
    print("Possible")
    for i in ans:
        print(i,end=' ')
elif p==2:
    print("Ambiguity")
else:
    print("Impossible")

def __starting_point():

    n , m = [ int(x) for x in input().split() ]
    f = [ int(x) for x in input().split() ]
    b = [ int(x) for x in input().split() ]

    fdict = dict()
    for i , fi in enumerate(f):
        if fi in fdict:
            fdict[ fi ].append( i )
        else:
            fdict[ fi ] = [ i ]

    a = []
    res = "Possible"
    for i,bi in enumerate(b):
        if bi in fdict:
            a_options = fdict[bi]
            a.append( a_options[0] )
            if len( a_options ) > 1:
                res = "Ambiguity"
        else:
            res = "Impossible"
            break

    print(res)
    if res == "Possible":

        if len(a) != m:
            print( "len(a) != m , len(a) =" , len(a) )

        print(" ".join([str(x+1) for x in a]))
    elif res == "Ambiguity":

        if len(a) != m:
            print( "len(a) != m , len(a) =" , len(a) )
__starting_point()

#n,m = map(int,input().split())
#f = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#list = [0]*100001

#for i in range(n):
#    list[f[i]] = i+1

#for item in b:
#    if list[item] == 0:
#        print('Impossible')
#        return

#for item in b:
#    if f.count(item) != 1:
#        print('Ambiguity')
#        return

#output=[list[i] for i in b]

#print('Possible')
#print(' '.join([str(x) for x in output]))

n, m = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = [-1] * 100001
for i in range(n):
	if a[f[i]] != -1:
		a[f[i]] = -2
	else:
		a[f[i]] = i
for i in b:
	if a[i] == -1:
		print('Impossible')
		return
for i in b:
	if a[i] == -2:
		print('Ambiguity')
		return
print('Possible')
for i in b:
	print(a[i] + 1, end=' ')

#n,m = map(int,input().split())
#f = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#list = [0]*100001

#for i in range(n):
#    list[f[i]] = i+1

#for item in b:
#    if list[item] == 0:
#        print('Impossible')
#        return

#for item in b:
#    if f.count(item) != 1:
#        print('Ambiguity')
#        return

#output=[list[i] for i in b]

#print('Possible')
#print(' '.join([str(x) for x in output]))

n, m = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = [-1] * 100001
for i in range(n):
	if a[f[i]] != -1:
		a[f[i]] = -2
	else:
		a[f[i]] = i
for i in b:
	if a[i] == -1:
		print('Impossible')
		return
for i in b:
	if a[i] == -2:
		print('Ambiguity')
		return
#print('Possible')
#for i in b:
#	print(a[i] + 1, end=' ')

output=[a[i]+1 for i in b]

print('Possible')
print(' '.join([str(x) for x in output]))

#n,m = map(int,input().split())
#f = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#list = [0]*100001

#for i in range(n):
#    list[f[i]] = i+1

#for item in b:
#    if list[item] == 0:
#        print('Impossible')
#        return

#for item in b:
#    if f.count(item) != 1:
#        print('Ambiguity')
#        return

#output=[list[i] for i in b]

#print('Possible')
#print(' '.join([str(x) for x in output]))


n,m = map(int,input().split())
#n, m = [int(i) for i in input().split()]
f = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = [-1] * 100001
for i in range(n):
	if a[f[i]] != -1:
		a[f[i]] = -2
	else:
		a[f[i]] = i
for i in b:
	if a[i] == -1:
		print('Impossible')
		return
for i in b:
	if a[i] == -2:
		print('Ambiguity')
		return
#print('Possible')
#for i in b:
#	print(a[i] + 1, end=' ')

output=[a[i]+1 for i in b]

print('Possible')
print(' '.join([str(x) for x in output]))

n,m = map(int,input().split())
f = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
list = [0]*100001

for i in range(n):
    if list[f[i]] != 0:
        list[f[i]] = -1
    else:
        list[f[i]] = i+1

for item in b:
    if list[item] == 0:
        print('Impossible')
        return

for item in b:
    if list[item] == -1:
        print('Ambiguity')
        return

output=[list[i] for i in b]

print('Possible')
print(' '.join([str(x) for x in output]))

# import sys
# sys.stdin = open('cf599b.in')

from collections import Counter

n, m = map(int, input().split())

ff = list(map(int, input().split()))
df = {int(v) : i for i, v in enumerate(ff, 1)}
cnt = Counter(ff)

bb = list(map(int, input().split()))

try:
	ans = ' '.join(str(df[b]) for b in bb)
	if any(cnt[b] > 1 for b in bb):
		print('Ambiguity')
	else:
		print('Possible')
		print(ans)
except KeyError:
	print('Impossible')