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

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

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

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

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

f = A("f")
m = B("m")
j = C("j")
k = D("k")
g = E("g")

f.z = m
m.s = j
j.o = m
j.v = k
k.w = f
g.r = k
g.s = k
g.p = f
g.y = f
assert m.s.v.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

f = A("f")
m = B("m")
j = C("j")
k = D("k")
g = E("g")

f.z = m
m.s = j
j.o = m
j.v = k
k.w = f
g.r = k
g.s = k
g.p = f
g.y = f
assert m.s.v.w.z.txt == "m"