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

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: A = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
n = C("n")
a = D("a")
d = E("d")
c = C("c")

m.o = a
l.z = d
l.p = m
n.o = d
n.t = a
n.p = l
n.q = c
a.z = l
d.x = m
c.o = d
c.t = a
c.p = l
c.q = n
assert c.o.x.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: A = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
n = C("n")
a = D("a")
d = E("d")
c = C("c")

m.o = a
l.z = d
l.p = m
n.o = d
n.t = a
n.p = l
n.q = c
a.z = l
d.x = m
c.o = d
c.t = a
c.p = l
c.q = n
assert c.o.x.o.z.txt == "l"