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

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

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

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

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

a.o = c
a.u = m
e.s = b
f.z = b
f.x = b
f.o = c
m.o = b
m.w = e
c.s = b
b.o = e
b.u = m
assert c.s.u.o.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: D = None
        self.txt = txt

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

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

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

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

a.o = c
a.u = m
e.s = b
f.z = b
f.x = b
f.o = c
m.o = b
m.w = e
c.s = b
b.o = e
b.u = m
assert c.s.u.o.u.w.txt == "e"