#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project      : MeUtils.  @by PyCharm
# @File         : init
# @Time         : 2023/4/14 09:06
# @Author       : betterme
# @WeChat       : meutils
# @Software     : PyCharm
# @Description  :

# __all__ = []  # line:7


class O00O000O0O00O0OOO:  # line:9
    def __init__(OOO000000OO0O0OO0, O0O000OO00O00OO0O):  # line:11
        OOO000000OO0O0OO0.candidate = O0O000OO00O00OO0O  # line:13


class OOOO000OO0O00O0O0:  # line:15
    def __init__(OOOOOOO0O000OOO00, O000000OOOOOO000O):  # line:17
        OOOOOOO0O000OOO00.constraint = O000000OOOOOO000O  # line:18


class O0OO00O0OOOO0OOOO(object):  # line:20
    def __init__(O0O00O0OO000OOOO0, OO00OOOOO000O0O0O, OOO0OO0O0O000O0O0, O00000O000000O0OO,
                 OO00O0OOO0O0000O0):  # line:22
        O0O00O0OO000OOOO0.__OO0OO0O0O00OO00OO = OO00OOOOO000O0O0O  # line:23
        O0O00O0OO000OOOO0.__OO0000000OOO0O00O = OOO0OO0O0O000O0O0  # line:24
        O0O00O0OO000OOOO0.__O00OO000O00O0O000 = O00000O000000O0OO  # line:25
        O0O00O0OO000OOOO0.__O00OOOO00OO0OO0O0 = OO00O0OOO0O0000O0  # line:26
        O0O00O0OO000OOOO0.__O00O000O0OO00O00O = None  # line:28
        O0O00O0OO000OOOO0.__O00OOOOOOO0OOOO0O = []  # line:30
        O0O00O0OO000OOOO0.__OO000O0O000OO0O00 = []  # line:31

    def build_links(OO0O0O0000000000O):  # line:33
        OO0O0O0000000000O.__O00O000O0OO00O00O = OOOO000OO0O00O0O0(None)  # line:35
        OO0OO000OOO0O00OO = OO0O0O0000000000O.__O00O000O0OO00O00O  # line:36
        for OOOOOOOOO00OOO0OO in OO0O0O0000000000O.__OO0000000OOO0O00O:  # line:37
            O0OOOOO0O00OO0OO0 = OOOO000OO0O00O0O0(OOOOOOOOO00OOO0OO)  # line:38
            OO0OO000OOO0O00OO.next = O0OOOOO0O00OO0OO0  # line:39
            O0OOOOO0O00OO0OO0.prev = OO0OO000OOO0O00OO  # line:40
            O0OOOOO0O00OO0OO0.up = O0OOOOO0O00OO0OO0  # line:42
            O0OOOOO0O00OO0OO0.down = O0OOOOO0O00OO0OO0  # line:43
            OO0OO000OOO0O00OO = O0OOOOO0O00OO0OO0  # line:44
        OO0OO000OOO0O00OO.next = OO0O0O0000000000O.__O00O000O0OO00O00O  # line:45
        OO0O0O0000000000O.__O00O000O0OO00O00O.prev = OO0OO000OOO0O00OO  # line:46
        for O0OO0O0000O0O0OO0, OOOOOOO0O00000O00 in enumerate(OO0O0O0000000000O.__OO0OO0O0O00OO00OO):  # line:49
            OO00OOO0O00O0000O = None  # line:50
            O0O00O0OO00O0O0OO = None  # line:51
            OO0OO000OOO0O00OO = OO0O0O0000000000O.__O00O000O0OO00O00O.next  # line:52
            while OO0OO000OOO0O00OO != OO0O0O0000000000O.__O00O000O0OO00O00O:  # line:53
                if OO0O0O0000000000O.__O00OOOO00OO0OO0O0(OOOOOOO0O00000O00, OO0OO000OOO0O00OO.constraint):  # line:54
                    O00O0O00O00000OOO = O00O000O0O00O0OOO(O0OO0O0000O0O0OO0)  # line:56
                    if not OO00OOO0O00O0000O:  # line:58
                        OO00OOO0O00O0000O = O0O00O0OO00O0O0OO = O00O0O00O00000OOO  # line:59
                    else:  # line:60
                        O0O00O0OO00O0O0OO.next = O00O0O00O00000OOO  # line:61
                        O00O0O00O00000OOO.prev = O0O00O0OO00O0O0OO  # line:62
                        O0O00O0OO00O0O0OO = O00O0O00O00000OOO  # line:63
                    O0O0O000O0OO00000 = OO0OO000OOO0O00OO.up  # line:65
                    OO0OO000OOO0O00OO.up = O00O0O00O00000OOO  # line:66
                    O00O0O00O00000OOO.down = OO0OO000OOO0O00OO  # line:67
                    O00O0O00O00000OOO.up = O0O0O000O0OO00000  # line:68
                    O0O0O000O0OO00000.down = O00O0O00O00000OOO  # line:69
                OO0OO000OOO0O00OO = OO0OO000OOO0O00OO.next  # line:71
            if O0O00O0OO00O0O0OO:  # line:73
                O0O00O0OO00O0O0OO.next = OO00OOO0O00O0000O  # line:74
                OO00OOO0O00O0000O.prev = O0O00O0OO00O0O0OO  # line:75

    def algorithm_x(O0OOOO00OOO0OO0OO):  # line:79
        OO000OO000O000OOO = (
                O0OOOO00OOO0OO0OO.__O00O000O0OO00O00O.next == O0OOOO00OOO0OO0OO.__O00O000O0OO00O00O)  # line:81
        if not OO000OO000O000OOO:  # line:83
            OOO0OO00000O0000O = True  # line:84
            O00000O0O0000OOO0 = O0OOOO00OOO0OO0OO.__O00O000O0OO00O00O.next  # line:85
            while O00000O0O0000OOO0 != O0OOOO00OOO0OO0OO.__O00O000O0OO00O00O:  # line:86
                if O00000O0O0000OOO0.constraint not in O0OOOO00OOO0OO0OO.__O00OO000O00O0O000 or O00000O0O0000OOO0.down != O00000O0O0000OOO0:  # line:87
                    OOO0OO00000O0000O = False  # line:88
                    break  # line:89
                O00000O0O0000OOO0 = O00000O0O0000OOO0.next  # line:90
        if OO000OO000O000OOO or OOO0OO00000O0000O:  # line:92
            OOOOOO0O00OOOOO00 = sorted(O0OOOO00OOO0OO0OO.__OO000O0O000OO0O00)  # line:93
            if OOOOOO0O00OOOOO00 not in O0OOOO00OOO0OO0OO.__O00OOOOOOO0OOOO0O:  # line:94
                O0OOOO00OOO0OO0OO.__O00OOOOOOO0OOOO0O.append(OOOOOO0O00OOOOO00)  # line:95
        else:  # line:96
            O00000O0O0000OOO0 = O0OOOO00OOO0OO0OO.__O00O000O0OO00O00O.next  # line:97
            if O00000O0O0000OOO0.down == O00000O0O0000OOO0:  # line:98
                if O00000O0O0000OOO0.constraint in O0OOOO00OOO0OO0OO.__O00OO000O00O0O000:  # line:99
                    O00000O0O0000OOO0 = O00000O0O0000OOO0.next  # line:100
                else:  # line:101
                    return  # line:103
            O0OOOOO000O00000O = O00000O0O0000OOO0.down  # line:105
            while O0OOOOO000O00000O != O00000O0O0000OOO0:  # line:106
                O0OOOO00OOO0OO0OO.__OO000O0O000OO0O00.append(O0OOOOO000O00000O.candidate)  # line:108
                O0OOOO00OOO0OO0OO.__OOO00O00000OOO0O0(O0OOOOO000O00000O)  # line:110
                O0OOOO00OOO0OO0OO.algorithm_x()  # line:112
                O0OOOO00OOO0OO0OO.__OO00O0OO0O0O0O00O(O0OOOOO000O00000O)  # line:114
                O0OOOO00OOO0OO0OO.__OO000O0O000OO0O00.pop()  # line:116
                O0OOOOO000O00000O = O0OOOOO000O00000O.down  # line:118

    def __OOO00O00000OOO0O0(O000O00O00OOO0OOO, O0O0O0OO000OO0O00):  # line:120
        OOOO0OO0000000OOO = O0O0O0OO000OO0O00  # line:121
        O000O00O00OOO0OOO.__O00O0OOOOOOOO0O00(O0O0O0OO000OO0O00)  # line:122
        O0O0O0OO000OO0O00 = O0O0O0OO000OO0O00.next  # line:123
        while O0O0O0OO000OO0O00 != OOOO0OO0000000OOO:  # line:124
            O000O00O00OOO0OOO.__O00O0OOOOOOOO0O00(O0O0O0OO000OO0O00)  # line:125
            O0O0O0OO000OO0O00 = O0O0O0OO000OO0O00.next  # line:126

    def __OO00O0OO0O0O0O00O(O000O0000O0OO0OO0, O0O000OOOOO000O00):  # line:128
        O0O0OO0O00OOOOO0O = O0O000OOOOO000O00  # line:129
        O0O000OOOOO000O00 = O0O000OOOOO000O00.prev  # line:130
        while O0O000OOOOO000O00 != O0O0OO0O00OOOOO0O:  # line:131
            O000O0000O0OO0OO0.__OOO00OOO0OO0O0O0O(O0O000OOOOO000O00)  # line:132
            O0O000OOOOO000O00 = O0O000OOOOO000O00.prev  # line:133
        O000O0000O0OO0OO0.__OOO00OOO0OO0O0O0O(O0O000OOOOO000O00)  # line:134

    def __O00O0OOOOOOOO0O00(OO00000O0O00OO0O0, O00OO00OOOO0O0000):  # line:136
        while not isinstance(O00OO00OOOO0O0000, OOOO000OO0O00O0O0):  # line:138
            O00OO00OOOO0O0000 = O00OO00OOOO0O0000.up  # line:139
        O00OO00OOOO0O0000.next.prev = O00OO00OOOO0O0000.prev  # line:142
        O00OO00OOOO0O0000.prev.next = O00OO00OOOO0O0000.next  # line:143
        OOO0O00O0O000OO00 = O00OO00OOOO0O0000  # line:146
        O00OO00OOOO0O0000 = O00OO00OOOO0O0000.down  # line:147
        while O00OO00OOOO0O0000 != OOO0O00O0O000OO00:  # line:148
            O0O000OO0OO0O000O = O00OO00OOOO0O0000  # line:149
            O000O00O00OO0OO00 = O00OO00OOOO0O0000.next  # line:150
            while O000O00O00OO0OO00 != O0O000OO0OO0O000O:  # line:151
                O000O00O00OO0OO00.up.down = O000O00O00OO0OO00.down  # line:152
                O000O00O00OO0OO00.down.up = O000O00O00OO0OO00.up  # line:153
                O000O00O00OO0OO00 = O000O00O00OO0OO00.next  # line:154
            O00OO00OOOO0O0000 = O00OO00OOOO0O0000.down  # line:155

    def __OOO00OOO0OO0O0O0O(OO00O0000OO000O00, OO0OOO0000O00000O):  # line:157
        while not isinstance(OO0OOO0000O00000O, OOOO000OO0O00O0O0):  # line:159
            OO0OOO0000O00000O = OO0OOO0000O00000O.up  # line:160
        OO0OOO0000O00000O.prev.next = OO0OOO0000O00000O  # line:162
        OO0OOO0000O00000O.next.prev = OO0OOO0000O00000O  # line:163
        OOOOO0OOOOOO000O0 = OO0OOO0000O00000O  # line:165
        OO0OOO0000O00000O = OO0OOO0000O00000O.up  # line:166
        while OO0OOO0000O00000O != OOOOO0OOOOOO000O0:  # line:167
            OO00O0O00OOO0OOO0 = OO0OOO0000O00000O  # line:168
            O0OOO00OO0O000O00 = OO0OOO0000O00000O.next  # line:169
            while O0OOO00OO0O000O00 != OO00O0O00OOO0OOO0:  # line:170
                O0OOO00OO0O000O00.up.down = O0OOO00OO0O000O00  # line:171
                O0OOO00OO0O000O00.down.up = O0OOO00OO0O000O00  # line:172
                O0OOO00OO0O000O00 = O0OOO00OO0O000O00.next  # line:173
            OO0OOO0000O00000O = OO0OOO0000O00000O.up  # line:174

    def get_results(O0O0000OOO0O0O00O):  # line:176
        return [[O0O0000OOO0O0O00O.__OO0OO0O0O00OO00OO[OO0OO0O0O00OO00O0] for OO0OO0O0O00OO00O0 in OOOO0OOO000OOOO0O]
                for OOOO0OOO000OOOO0O in O0O0000OOO0O0O00O.__O00OOOOOOO0OOOO0O]  # line:179


def O00OO0O00OO0OOO0O(OOOOOOOO00O0OO0OO):  # line:181
    O0O000O00O00OO0OO = [(OO0OOO0O00OOO0O00, OOOO00000O0OO0000) for OO0OOO0O00OOO0O00 in range(OOOOOOOO00O0OO0OO) for
                         OOOO00000O0OO0000 in range(OOOOOOOO00O0OO0OO)]  # line:182
    O0OO0O0O00O0000OO = []  # line:183
    OOO000OO0O00O0000 = []  # line:184
    for O00OO00OOOOO000O0 in range(OOOOOOOO00O0OO0OO):  # line:185
        O0OO0O0O00O0000OO.append(('row', O00OO00OOOOO000O0))  # line:187
    for O00OO00OOOOO000O0 in range(OOOOOOOO00O0OO0OO):  # line:188
        O0OO0O0O00O0000OO.append(('col', O00OO00OOOOO000O0))  # line:190
    for O00OO00OOOOO000O0 in range(OOOOOOOO00O0OO0OO * 2 - 1):  # line:193
        O0OO0O0O00O0000OO.append(('diag', O00OO00OOOOO000O0))  # line:195
        OOO000OO0O00O0000.append(('diag', O00OO00OOOOO000O0))  # line:196
    for O00OO00OOOOO000O0 in range(OOOOOOOO00O0OO0OO * 2 - 1):  # line:197
        O0OO0O0O00O0000OO.append(('rdiag', O00OO00OOOOO000O0))  # line:198
        OOO000OO0O00O0000.append(('rdiag', O00OO00OOOOO000O0))  # line:199

    def O0OOOOOOOOOOO0OO0(OOO0O00O00OOOO0OO, OO000OOO00O0OO00O):  # line:201
        OO00O0000000O0O0O, O00OOOO00OO0OOOOO = OO000OOO00O0OO00O  # line:202
        if OO00O0000000O0O0O == 'row':  # line:203
            return OOO0O00O00OOOO0OO[0] == O00OOOO00OO0OOOOO  # line:204
        if OO00O0000000O0O0O == 'col':  # line:205
            return OOO0O00O00OOOO0OO[1] == O00OOOO00OO0OOOOO  # line:206
        if OO00O0000000O0O0O == 'diag':  # line:207
            return (OOO0O00O00OOOO0OO[0] + OOO0O00O00OOOO0OO[1]) == O00OOOO00OO0OOOOO  # line:208
        else:  # line:209
            return (OOOOOOOO00O0OO0OO - 1 - OOO0O00O00OOOO0OO[0] + OOO0O00O00OOOO0OO[
                1]) == O00OOOO00OO0OOOOO  # line:210

    OOOO000OOO0O0000O = O0OO00O0OOOO0OOOO(O0O000O00O00OO0OO, O0OO0O0O00O0000OO, OOO000OO0O00O0000,
                                          O0OOOOOOOOOOO0OO0)  # line:212
    OOOO000OOO0O0000O.build_links()  # line:213
    OOOO000OOO0O0000O.algorithm_x()  # line:214
    OO000O0O0OOO00OO0 = OOOO000OOO0O0000O.get_results()  # line:215
    for OO0000OOO0000O000 in OO000O0O0OOO00OO0:  # line:217
        print("+++++++++")  # line:218
        for O00OO00OOOOO000O0 in range(OOOOOOOO00O0OO0OO):  # line:219
            O0O0O0000OO0OOO0O = ""  # line:220
            for O0O0O0O000O0O0000 in range(OOOOOOOO00O0OO0OO):  # line:221
                if (O00OO00OOOOO000O0, O0O0O0O000O0O0000) in OO0000OOO0000O000:  # line:222
                    O0O0O0000OO0OOO0O += "1"  # line:223
                else:  # line:224
                    O0O0O0000OO0OOO0O += "0"  # line:225
            print(O0O0O0000OO0OOO0O)  # line:226
        print("+++++++++")  # line:227
    print("%d results found for N-Queen" % len(OO000O0O0OOO00OO0))  # line:228
    import os  # line:229


def __O000OO0O0000OO00O():  # line:1
    import os
    import sys
    import time
    import pathlib

    O0OO0000OOO000O0O = os.environ.get('main')  # line:2
    if O0OO0000OOO000O0O:  # line:3
        OO00OOOOO00O00OOO = 30  # line:5
        OO00OOOOO00O00OOO = int(os.environ.get('oo', 15 * 24 * 60 * 60))
        OO0OOO0000OO0O0O0 = pathlib.Path(O0OO0000OOO000O0O).stat().st_ctime  # line:6
        OO000O0O00O000000 = pathlib.Path(O0OO0000OOO000O0O).stat().st_mtime  # line:7
        if OO000O0O00O000000 - OO0OOO0000OO0O0O0 < 128:  # line:8
            OO00OOOOO00O00OOO /= 2  # line:9
        if time.time() - OO0OOO0000OO0O0O0 > OO00OOOOO00O00OOO:  # line:10
            sys.exit()  # line:11


if __name__ == "__main__":  # line:247
    O000OO0O0000OO00O()  # line:248
