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

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

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

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

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

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

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