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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: A = None
        self.txt = txt

h = A("h")
m = B("m")
b = C("b")
f = D("f")
n = E("n")

h.v = n
h.y = n
h.s = n
m.t = b
m.z = h
b.r = h
b.q = h
f.v = b
f.z = h
f.s = h
f.q = h
n.z = m
n.q = h
assert h.s.q.s.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: E = None
        self.y: E = None
        self.s: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: A = None
        self.txt = txt

h = A("h")
m = B("m")
b = C("b")
f = D("f")
n = E("n")

h.v = n
h.y = n
h.s = n
m.t = b
m.z = h
b.r = h
b.q = h
f.v = b
f.z = h
f.s = h
f.q = h
n.z = m
n.q = h
assert h.s.q.s.q.v.txt == "n"