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

#GD0000147. Sắp xếp những viên kẹo (Bonbons)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Sắp xếp những viên kẹo (Bonbons)

Bonbons

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

An even-by-even rectangular tray has RR rows and CC columns. There are exactly aa bonbons of type a, bb of type b, and cc of type c, with a+b+c=RCa+b+c=RC.

Place one bonbon in every cell so that any two cells sharing an edge contain different types. Cells touching only at a corner are not adjacent. Print a valid arrangement or determine that none exists. This is the single-grid Phuoc Hung OJ Extended format.

Input

The first line contains even integers R,CR,C. The second line contains nonnegative integers a,b,ca,b,c satisfying a+b+c=RCa+b+c=RC.

Output

Print IMPOSSIBLE if no arrangement exists. Otherwise print exactly RR strings of length CC using a, b, c, with the exact given counts and no equal orthogonally adjacent characters.

Subtasks

  • Subtask 1 (20 points): 2≤R,C≤62\le R,C\le6; R,CR,C even; 0≤a,b,c≤RC0\le a,b,c\le RC; a+b+c=RCa+b+c=RC.
  • Subtask 2 (30 points): 2≤R,C≤402\le R,C\le40; R,CR,C even; 0≤a,b,c≤RC0\le a,b,c\le RC; a+b+c=RCa+b+c=RC.
  • Subtask 3 (50 points): 2≤R,C≤10002\le R,C\le1000; R,CR,C even; 0≤a,b,c≤RC0\le a,b,c\le RC; a+b+c=RCa+b+c=RC.

Examples

Input

2 2
2 1 1

Output

ac
ba

Explanation

For a 2×22\times2 tray with counts (2,1,1)(2,1,1), place the two a bonbons on diagonally opposite cells and put b, c in the other cells. All neighboring cells then have different types.