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

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

l = A("l")
f = B("f")
m = B("m")
g = B("g")
k = A("k")

l.s = k
f.t = l
m.t = k
g.t = l
k.s = l
assert m.t.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

l = A("l")
f = B("f")
m = B("m")
g = B("g")
k = A("k")

l.s = k
f.t = l
m.t = k
g.t = l
k.s = l
assert m.t.s.s.s.s.txt == "k"