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

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

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

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

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

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

n.z = h
n.s = h
c.r = g
g.o = b
g.z = b
b.v = n
m.q = n
m.u = n
m.z = n
m.r = g
m.s = h
h.r = g
assert m.s.r.z.v.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

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

n.z = h
n.s = h
c.r = g
g.o = b
g.z = b
b.v = n
m.q = n
m.u = n
m.z = n
m.r = g
m.s = h
h.r = g
assert m.s.r.z.v.s.r.txt == "g"