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

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

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

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

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

d.u = i
d.x = b
d.y = b
d.o = b
f.w = i
f.p = b
b.r = j
i.o = j
i.z = j
j.u = i
j.x = b
j.y = b
j.o = b
assert b.r.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: C = None
        self.y: C = None
        self.o: C = None
        self.txt = txt

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

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

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

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

d.u = i
d.x = b
d.y = b
d.o = b
f.w = i
f.p = b
b.r = j
i.o = j
i.z = j
j.u = i
j.x = b
j.y = b
j.o = b
assert b.r.u.z.u.txt == "i"