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

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

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

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

d = A("d")
f = B("f")
n = C("n")
a = D("a")

d.p = n
d.u = f
d.z = f
f.w = d
f.x = d
f.o = d
f.r = n
n.w = d
a.t = f
a.o = f
a.z = f
assert d.z.r.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: B = None
        self.z: B = None
        self.txt = txt

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

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

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

d = A("d")
f = B("f")
n = C("n")
a = D("a")

d.p = n
d.u = f
d.z = f
f.w = d
f.x = d
f.o = d
f.r = n
n.w = d
a.t = f
a.o = f
a.z = f
assert d.z.r.w.u.txt == "f"