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

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

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

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

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

k.x = e
k.o = e
k.q = c
c.p = h
c.u = e
h.u = e
e.o = h
assert h.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.o: D = None
        self.q: B = None
        self.txt = txt

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

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

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

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

k.x = e
k.o = e
k.q = c
c.p = h
c.u = e
h.u = e
e.o = h
assert h.u.o.u.txt == "e"