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

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

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

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

g = A("g")
a = B("a")
k = C("k")
f = D("f")

g.u = f
a.z = g
k.t = f
k.x = f
k.z = f
f.z = g
f.o = a
assert g.u.o.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
k = C("k")
f = D("f")

g.u = f
a.z = g
k.t = f
k.x = f
k.z = f
f.z = g
f.o = a
assert g.u.o.z.u.txt == "f"