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

f = A("f")
g = B("g")
e = B("e")
k = A("k")
b = B("b")

f.t = g
g.s = e
e.s = g
k.t = b
b.s = g
assert k.t.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

f = A("f")
g = B("g")
e = B("e")
k = A("k")
b = B("b")

f.t = g
g.s = e
e.s = g
k.t = b
b.s = g
assert k.t.s.s.s.txt == "g"