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

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

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

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

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

f.w = b
c.w = e
a.v = f
a.q = b
a.o = b
b.z = e
e.w = c
assert b.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

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

f.w = b
c.w = e
a.v = f
a.q = b
a.o = b
b.z = e
e.w = c
assert b.z.w.w.txt == "e"