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

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

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

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

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

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

g.z = n
h.w = g
l.q = g
m.x = n
n.t = g
n.r = h
n.z = h
assert h.w.z.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

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

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

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

g.z = n
h.w = g
l.q = g
m.x = n
n.t = g
n.r = h
n.z = h
assert h.w.z.z.w.z.txt == "n"