PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000061. Giải mã hóa đơn gọi món (Restaurant Orders)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Giải mã hóa đơn gọi món (Restaurant Orders)

Restaurant Orders

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

A restaurant menu has nn types of dishes. Type ii costs cic_i kronor and has index ii (11-based). Customers may order any number of copies of each type; two plates of type 22 count as two copies of item 22.

For each of mm receipts, the waiter remembers only the total cost ss, not the items ordered. Determine whether that total can be formed by no multiset of menu items, exactly one multiset, or more than one multiset.

Two orders are identical when they contain the same multiplicity of each menu type; the ordering of the plates does not matter. Even when two menu items have equal prices, their different indices make them different types.

Print Impossible if no order exists, Ambiguous if at least two distinct orders exist, or list the item indices of the unique order in nondecreasing order. Repeat indices when copies were ordered. Receipt queries are independent and use the same menu.

Input

Line 1 contains nn. Line 2 contains the nn item prices c1,…,cnc_1,\ldots,c_n. Line 3 contains mm. Line 4 contains the mm receipt totals s1,…,sms_1,\ldots,s_m.

Output

Print exactly mm lines. For receipt jj, print Impossible, Ambiguous, or the item indices of the unique order in ascending order, separated by spaces. Do not print any count or explanatory text.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101\le n\le10, 1≤ci≤201\le c_i\le20 for every ii, 1≤m≤151\le m\le15, 1≤sj≤2001\le s_j\le200 for every jj.

  • Subtask 2 (30 points): 1≤n≤451\le n\le45, 1≤ci≤3001\le c_i\le300 for every ii, 1≤m≤1501\le m\le150, 1≤sj≤100001\le s_j\le10000 for every jj.

  • Subtask 3 (50 points): 1≤n≤1001\le n\le100, 1≤ci≤10001\le c_i\le1000 for every ii, 1≤m≤10001\le m\le1000, 1≤sj≤300001\le s_j\le30000 for every jj.

Examples

Input


3
4 5 8
3
11 13 14

Output


Impossible
Ambiguous
1 2 2

Explanation

Menu prices are 4,5,84,5,8. No nonnegative combination sums to 1111, so the first line is Impossible. At 1313, both 5+85+8 and 4+4+54+4+5 are valid, so the answer is Ambiguous. At 1414, only 4+5+54+5+5 is possible, so print the indices 1 2 2.