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

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

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

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

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

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

d.w = a
i.q = b
i.u = l
b.q = l
b.u = i
h.w = a
n.w = a
l.q = i
l.u = b
a.w = n
assert i.u.q.q.u.q.txt == "b"