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

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

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

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

e = A("e")
h = B("h")
a = C("a")
c = D("c")

e.z = a
h.p = a
h.o = e
a.u = h
a.t = h
a.q = e
c.s = a
assert e.z.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

e = A("e")
h = B("h")
a = C("a")
c = D("c")

e.z = a
h.p = a
h.o = e
a.u = h
a.t = h
a.q = e
c.s = a
assert e.z.u.p.txt == "a"