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

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

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

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

j = A("j")
b = B("b")
f = C("f")
k = D("k")
d = B("d")
a = C("a")

j.t = a
b.u = f
b.z = j
f.z = j
k.o = d
k.p = a
d.u = f
d.z = j
a.z = j
assert j.t.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
f = C("f")
k = D("k")
d = B("d")
a = C("a")

j.t = a
b.u = f
b.z = j
f.z = j
k.o = d
k.p = a
d.u = f
d.z = j
a.z = j
assert j.t.z.t.txt == "a"