class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: D = None
        self.w: C = None
        self.txt = txt

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

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

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

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

a.t = e
a.w = e
a.p = h
g.p = h
g.y = h
e.z = g
e.o = g
h.o = e
h.w = e
h.x = e
h.z = g
assert h.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: D = None
        self.w: C = None
        self.txt = txt

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

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

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

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

a.t = e
a.w = e
a.p = h
g.p = h
g.y = h
e.z = g
e.o = g
h.o = e
h.w = e
h.x = e
h.z = g
assert h.z.y.z.txt == "g"