class A:
    def __init__(self, txt: str):
        self.z: A = 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: A = None
        self.z: B = None
        self.txt = txt

e = A("e")
k = B("k")
a = C("a")
d = B("d")
i = C("i")
f = C("f")
g = A("g")
b = C("b")

e.z = g
k.s = f
a.o = e
a.z = d
d.s = i
i.o = g
i.z = d
f.o = g
f.z = d
g.z = e
b.o = e
b.z = k
assert d.s.o.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = 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: A = None
        self.z: B = None
        self.txt = txt

e = A("e")
k = B("k")
a = C("a")
d = B("d")
i = C("i")
f = C("f")
g = A("g")
b = C("b")

e.z = g
k.s = f
a.o = e
a.z = d
d.s = i
i.o = g
i.z = d
f.o = g
f.z = d
g.z = e
b.o = e
b.z = k
assert d.s.o.z.z.z.z.txt == "g"