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

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

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

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

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

m = A("m")
b = B("b")
a = C("a")
i = D("i")
h = E("h")

m.w = a
m.p = b
b.v = m
a.u = i
a.v = i
a.q = i
a.w = m
i.u = h
h.y = a
h.u = i
h.z = i
assert m.w.u.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: B = None
        self.txt = txt

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

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

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

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

m = A("m")
b = B("b")
a = C("a")
i = D("i")
h = E("h")

m.w = a
m.p = b
b.v = m
a.u = i
a.v = i
a.q = i
a.w = m
i.u = h
h.y = a
h.u = i
h.z = i
assert m.w.u.u.y.txt == "a"