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

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

h = A("h")
i = B("i")
l = B("l")
k = A("k")
f = B("f")
b = A("b")
e = B("e")

h.y = k
h.t = k
i.s = k
l.s = k
k.y = b
k.t = b
f.s = h
b.y = h
b.t = k
e.s = b
assert b.t.t.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.t: A = None
        self.txt = txt

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

h = A("h")
i = B("i")
l = B("l")
k = A("k")
f = B("f")
b = A("b")
e = B("e")

h.y = k
h.t = k
i.s = k
l.s = k
k.y = b
k.t = b
f.s = h
b.y = h
b.t = k
e.s = b
assert b.t.t.y.y.txt == "k"