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

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

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

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

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

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

l.w = d
l.t = m
d.o = h
c.w = d
c.t = m
k.w = a
k.t = c
h.o = a
m.w = h
m.t = c
b.o = h
a.o = h
n.o = h
assert c.t.t.t.w.o.o.txt == "h"