class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.z: D = None
        self.y: E = None
        self.o: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: E = None
        self.z: D = None
        self.t: D = None
        self.r: C = None
        self.v: D = None
        self.txt = txt

m = A("m")
d = B("d")
e = C("e")
b = D("b")
i = E("i")
a = F("a")

m.x = e
d.o = i
d.q = a
e.r = d
e.v = d
e.o = d
e.z = b
e.y = i
b.z = a
i.t = d
a.u = b
a.z = b
a.t = b
a.v = b
a.x = i
a.r = e
assert b.z.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.z: D = None
        self.y: E = None
        self.o: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: E = None
        self.z: D = None
        self.t: D = None
        self.r: C = None
        self.v: D = None
        self.txt = txt

m = A("m")
d = B("d")
e = C("e")
b = D("b")
i = E("i")
a = F("a")

m.x = e
d.o = i
d.q = a
e.r = d
e.v = d
e.o = d
e.z = b
e.y = i
b.z = a
i.t = d
a.u = b
a.z = b
a.t = b
a.v = b
a.x = i
a.r = e
assert b.z.r.o.txt == "d"