class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: F = None
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: E = None
        self.q: C = None
        self.u: D = None
        self.y: F = None
        self.r: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: F = None
        self.z: D = None
        self.t: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: C = None
        self.q: D = None
        self.txt = txt

n = A("n")
b = B("b")
d = C("d")
g = D("g")
m = E("m")
i = F("i")

n.x = g
n.y = i
n.w = b
b.o = d
b.q = d
b.p = m
b.u = g
b.y = i
b.r = i
d.p = m
g.o = n
g.s = n
g.u = m
m.p = n
m.o = i
m.z = g
m.t = g
i.z = b
i.w = d
i.q = g
assert b.u.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: F = None
        self.w: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.p: E = None
        self.q: C = None
        self.u: D = None
        self.y: F = None
        self.r: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: A = None
        self.u: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: F = None
        self.z: D = None
        self.t: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: C = None
        self.q: D = None
        self.txt = txt

n = A("n")
b = B("b")
d = C("d")
g = D("g")
m = E("m")
i = F("i")

n.x = g
n.y = i
n.w = b
b.o = d
b.q = d
b.p = m
b.u = g
b.y = i
b.r = i
d.p = m
g.o = n
g.s = n
g.u = m
m.p = n
m.o = i
m.z = g
m.t = g
i.z = b
i.w = d
i.q = g
assert b.u.s.x.s.txt == "n"