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

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

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

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

a = A("a")
d = B("d")
h = C("h")
n = D("n")
b = D("b")

a.w = h
d.w = h
h.x = d
h.w = d
n.z = a
n.r = h
n.s = h
n.v = b
b.z = a
b.r = h
b.s = h
b.v = n
assert d.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

a = A("a")
d = B("d")
h = C("h")
n = D("n")
b = D("b")

a.w = h
d.w = h
h.x = d
h.w = d
n.z = a
n.r = h
n.s = h
n.v = b
b.z = a
b.r = h
b.s = h
b.v = n
assert d.w.w.w.w.txt == "d"