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

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

l = A("l")
m = B("m")
a = B("a")
f = B("f")
c = B("c")
k = A("k")
d = B("d")
b = A("b")
h = B("h")

l.t = k
m.s = l
a.s = k
f.s = l
c.s = b
k.t = b
d.s = b
b.t = k
h.s = k
assert c.s.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

l = A("l")
m = B("m")
a = B("a")
f = B("f")
c = B("c")
k = A("k")
d = B("d")
b = A("b")
h = B("h")

l.t = k
m.s = l
a.s = k
f.s = l
c.s = b
k.t = b
d.s = b
b.t = k
h.s = k
assert c.s.t.t.t.txt == "k"