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

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

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

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

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

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

h.u = n
n.t = e
n.w = k
b.u = a
k.u = n
e.u = a
a.t = e
a.w = b
l.u = n
d.u = n
assert l.u.w.u.txt == "n"