아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Bonbons

시간 제한2초메모리 제한512 MB

요약
짝수 행과 짝수 열로 이루어진 격자에 세 맛 사탕 a, b, c개를 가로나 세로로 같은 글자가 닿지 않게 배치하고, 불가능하면 불가능을 출력한다.
난이도

보통10점 중 7점

유형
그리디, 구현, 수학, 행렬
정답자
아직 제출이 없습니다

문제

Ylva loves bonbons, probably more than anything else on this planet. She loves them so much that she made a large plate of R⋅CR \cdot C bonbons for her fikaraster ("Fikarast" is a Swedish word, meaning to take a break from work while enjoying coffee and pastries together with your colleagues.).

Ylva has a large wooden tray which can fit RR rows of CC bonbons per row, that she will put the bonbons on. Her bonbons have three different fillings: Nutella Buttercream, Red Wine Chocolate Ganache, and Strawberry Whipped Cream. Since Ylva is a master chocolatier, she knows that presentation is 9090\\% of the execution. In particular, it looks very bad if two bonbons of the same color are adjacent to each other within a row or a column on the tray. We call an arrangement of bonbons where this is never the case a good arrangement.

Given the number of bonbons of each flavour, and the size of Ylva's tray, can you help her find a good arrangement of the bonbons, or determine that no such arrangement exists?

입력

The first line of input contains the two space-separated integers 2≤R,C≤10002 \le R, C \le 1000. The next line contains three non-negative space-separated integers a,b,ca, b, c -- the number of bonbons of the three flavours which Ylva has baked. It is guaranteed that a+b+c=R⋅Ca + b + c = R \cdot C. Both RR and CC will be even.

출력

If no good arrangement can be found, output impossible. Otherwise, output RR lines, each containing CC characters, representing a good arrangement. Each row should contain only characters A, B, C, depending on which flavour should be placed on a certain position. The number of A bonbons placed must be equal to AA, and so on.

예제2

  1. 예제 1

    입력
    4 4
    10 3 3
    
    예상 출력
    impossible
    
  2. 예제 2

    입력
    4 4
    6 5 5
    
    예상 출력
    ABCA
    BCAB
    CABC
    ABCA