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

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

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

c = A("c")
m = B("m")
f = C("f")
e = C("e")
g = A("g")
a = A("a")
d = A("d")
k = C("k")

c.s = m
m.s = a
f.q = e
e.q = k
g.s = m
a.s = m
d.s = m
k.q = f
assert e.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

c = A("c")
m = B("m")
f = C("f")
e = C("e")
g = A("g")
a = A("a")
d = A("d")
k = C("k")

c.s = m
m.s = a
f.q = e
e.q = k
g.s = m
a.s = m
d.s = m
k.q = f
assert e.q.q.q.q.q.q.txt == "e"