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

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

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

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

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

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

h.y = a
h.w = f
b.t = h
b.w = a
a.v = h
k.p = a
k.w = a
f.z = k
f.u = k
f.v = k
f.y = h
f.r = a
assert h.w.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: E = None
        self.txt = txt

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

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

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

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

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

h.y = a
h.w = f
b.t = h
b.w = a
a.v = h
k.p = a
k.w = a
f.z = k
f.u = k
f.v = k
f.y = h
f.r = a
assert h.w.r.v.txt == "h"