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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: A = None
        self.t: B = None
        self.u: A = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
f = C("f")
a = D("a")
g = E("g")

k.w = b
k.v = a
b.v = a
f.r = b
f.t = b
f.z = k
f.u = k
a.w = g
g.w = b
assert g.w.v.w.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: A = None
        self.t: B = None
        self.u: A = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
f = C("f")
a = D("a")
g = E("g")

k.w = b
k.v = a
b.v = a
f.r = b
f.t = b
f.z = k
f.u = k
a.w = g
g.w = b
assert g.w.v.w.w.v.txt == "a"