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

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

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

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

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

e.u = m
f.w = j
b.x = e
b.o = e
b.y = f
b.t = f
j.v = b
m.w = j
assert e.u.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

e.u = m
f.w = j
b.x = e
b.o = e
b.y = f
b.t = f
j.v = b
m.w = j
assert e.u.w.v.txt == "b"