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

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

b = A("b")
f = B("f")
i = B("i")
g = B("g")
e = A("e")
j = A("j")

b.t = i
f.s = g
i.s = f
g.s = f
e.t = f
j.t = i
assert f.s.s.s.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: B = None
        self.txt = txt

b = A("b")
f = B("f")
i = B("i")
g = B("g")
e = A("e")
j = A("j")

b.t = i
f.s = g
i.s = f
g.s = f
e.t = f
j.t = i
assert f.s.s.s.s.txt == "f"