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

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

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

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

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

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

k.w = m
e.y = l
e.t = l
d.y = l
d.t = b
i.w = m
l.y = e
l.t = e
a.y = e
a.t = d
h.w = m
f.w = m
m.w = k
b.y = e
b.t = d
assert l.y.t.t.txt == "e"