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

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

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

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

j = A("j")
m = B("m")
n = C("n")
b = D("b")

j.u = m
m.p = b
m.y = b
m.z = b
m.v = n
n.o = j
b.s = n
b.o = n
b.y = n
b.t = j
assert m.y.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

j = A("j")
m = B("m")
n = C("n")
b = D("b")

j.u = m
m.p = b
m.y = b
m.z = b
m.v = n
n.o = j
b.s = n
b.o = n
b.y = n
b.t = j
assert m.y.o.o.txt == "j"