class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

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

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

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

b.x = h
b.t = a
b.v = a
e.r = d
e.t = d
e.w = h
d.v = h
h.s = a
a.r = d
a.t = d
a.w = h
assert e.w.s.w.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

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

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

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

b.x = h
b.t = a
b.v = a
e.r = d
e.t = d
e.w = h
d.v = h
h.s = a
a.r = d
a.t = d
a.w = h
assert e.w.s.w.s.w.txt == "h"