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

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

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

f = A("f")
l = B("l")
i = C("i")
a = B("a")
e = B("e")
m = B("m")
c = C("c")

f.s = c
l.t = f
l.s = a
i.s = f
a.t = f
a.s = e
e.t = f
e.s = m
m.t = f
m.s = l
c.s = f
assert f.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

f = A("f")
l = B("l")
i = C("i")
a = B("a")
e = B("e")
m = B("m")
c = C("c")

f.s = c
l.t = f
l.s = a
i.s = f
a.t = f
a.s = e
e.t = f
e.s = m
m.t = f
m.s = l
c.s = f
assert f.s.s.s.s.s.s.txt == "f"