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")
i = B("i")
g = A("g")
b = B("b")
f = B("f")
a = B("a")
k = A("k")

l.s = g
i.t = g
g.s = l
b.t = k
f.t = g
a.t = k
k.s = g
assert k.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")
i = B("i")
g = A("g")
b = B("b")
f = B("f")
a = B("a")
k = A("k")

l.s = g
i.t = g
g.s = l
b.t = k
f.t = g
a.t = k
k.s = g
assert k.s.s.s.txt == "g"