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

#GD0000151. Ghép cặp để ước chung lớn nhất lớn hơn một (GCD Compression)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Ghép cặp để ước chung lớn nhất lớn hơn một (GCD Compression)

GCD Compression

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You have an array of 2n2n positive integers. Discard exactly two elements, then partition the remaining 2n−22n-2 elements into n−1n-1 unordered pairs. Let bb consist of the sum of the two values in each pair.

Find a pairing such that gcd⁡(b1,…,bn−1)>1\gcd(b_1,\ldots,b_{n-1})>1. It is guaranteed that a valid pairing exists. Output only the original indices of the pairs; the two discarded indices are omitted.

Input

The first line contains nn. The second line contains 2n2n integers a1,…,a2na_1,\ldots,a_{2n}.

Output

Output exactly n−1n-1 lines. Each line contains two distinct 11-based indices from 11 to 2n2n. Each index may appear at most once, and the GCD of the corresponding pair sums must exceed one.

Subtasks

  • Subtask 1 (20 points): 2≤n≤82\le n\le8; 1≤ai≤10001\le a_i\le1000 for 1≤i≤2n1\le i\le2n.
  • Subtask 2 (30 points): 2≤n≤1802\le n\le180; 1≤ai≤10001\le a_i\le1000 for 1≤i≤2n1\le i\le2n.
  • Subtask 3 (50 points): 2≤n≤10002\le n\le1000; 1≤ai≤10001\le a_i\le1000 for 1≤i≤2n1\le i\le2n.

Examples

Input

3
1 2 3 4 5 6

Output

2 4
1 3

Explanation

Pairing indices (1,3)(1,3) and (2,4)(2,4) gives sums 1+3=41+3=4 and 2+4=62+4=6, whose GCD is 22. Indices 55 and 66 are discarded.