Mitofey watched the musical “Hamilton” and decided to stage his own rendition with his programmer-actor friends. For this, he needs a stage divided into N rooms with passages between them, with at most one passage between any pair of rooms. To make the rendition true to its name, Mitofey decided to arrange the passages so that any actor could start performing in any room and, moving only along passages, visit every room exactly once and finally return to the starting room. In other words, the stage must contain a Hamiltonian cycle.
Mitofey knows that checking whether a Hamiltonian cycle exists takes a huge amount of time, since there are as many as N rooms. Therefore, he uses Ore’s condition: take any two rooms that have no passage between them; if for every such pair the total number of passages from these two rooms is at least N, then a Hamiltonian cycle exists. In other words, the sum of the degrees of any two non-adjacent rooms is at least the number of rooms.
Zhenya, Mitofey’s programmer-actor friend, reported that the stage is ready. However, Mitofey does not trust either friends, programmers, or actors. Before the first rehearsal, exactly 20 minutes remain, and in this time Mitofey can add only one passage between two rooms that are not connected yet. Help Mitofey determine whether Zhenya prepared the stage according to Ore’s condition. If not, answer whether Mitofey can do something about it. If he can, tell him between which rooms he should add a passage.
Input
The first line contains an integer N — the number of rooms on the stage (3 ≤ N ≤ 3 000).
The next N lines contain N binary strings of length N. The symbol eij in the j-th position of the i-th line is 0 if there is no passage between rooms i and j, or 1 if there is one. It is guaranteed that eij = eji and eii = 0 for all i and j.
Output
Print “Absolute Hamilton!!!” if the stage already satisfies Ore’s condition. Otherwise, if Mitofey cannot add a new passage so that the stage satisfies Ore’s condition, print “No Hamilton:-(”. If Mitofey can do it, print “Build Hamilton!!!”, and then print two different integers u and v — the numbers of the rooms between which Mitofey should add a passage. Note that euv must be 0 in the input. If there are multiple solutions, print any of them.
Samples
| input | output |
|---|
3
001
000
100
| No Hamilton:-(
|
3
011
100
100
| Build Hamilton!!!
2 3
|
3
011
101
110
| Absolute Hamilton!!!
|
Problem Author: Timofey Imaev (prepared by Vadim Barinov)
Problem Source: The 2026 ICPC UrFU Qualification