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

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

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

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

k = A("k")
f = B("f")
b = C("b")
j = D("j")
c = B("c")
e = A("e")

k.u = j
f.p = c
f.w = e
f.y = j
f.o = b
b.y = k
j.z = b
c.p = f
c.w = e
c.y = j
c.o = b
e.u = j
assert j.z.y.u.z.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

k = A("k")
f = B("f")
b = C("b")
j = D("j")
c = B("c")
e = A("e")

k.u = j
f.p = c
f.w = e
f.y = j
f.o = b
b.y = k
j.z = b
c.p = f
c.w = e
c.y = j
c.o = b
e.u = j
assert j.z.y.u.z.y.u.txt == "j"