class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: 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.v: D = None
        self.txt = txt

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

b = A("b")
c = B("c")
g = C("g")
d = D("d")
a = D("a")

b.r = c
b.t = c
c.w = a
g.v = a
d.p = c
d.z = c
d.u = c
a.p = c
a.z = c
a.u = c
assert g.v.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: 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.v: D = None
        self.txt = txt

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

b = A("b")
c = B("c")
g = C("g")
d = D("d")
a = D("a")

b.r = c
b.t = c
c.w = a
g.v = a
d.p = c
d.z = c
d.u = c
a.p = c
a.z = c
a.u = c
assert g.v.u.w.txt == "a"