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

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
l = C("l")
g = D("g")
b = B("b")
n = C("n")
m = D("m")
a = A("a")
i = B("i")

c.s = n
d.y = g
l.z = n
g.o = m
b.y = g
n.z = l
m.o = g
a.s = n
i.y = g
assert a.s.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
l = C("l")
g = D("g")
b = B("b")
n = C("n")
m = D("m")
a = A("a")
i = B("i")

c.s = n
d.y = g
l.z = n
g.o = m
b.y = g
n.z = l
m.o = g
a.s = n
i.y = g
assert a.s.z.z.z.z.z.z.txt == "n"