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

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

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

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

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

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

d.o = l
h.s = c
h.p = c
l.t = c
l.q = h
c.z = l
c.r = l
c.y = m
m.t = l
assert h.p.z.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

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

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

d.o = l
h.s = c
h.p = c
l.t = c
l.q = h
c.z = l
c.r = l
c.y = m
m.t = l
assert h.p.z.t.z.t.txt == "c"