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

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

b = A("b")
l = B("l")
i = A("i")
f = B("f")
j = A("j")
a = B("a")

b.w = f
b.u = l
l.q = a
i.w = l
i.u = l
f.q = l
j.w = l
j.u = a
a.q = l
assert a.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: B = None
        self.txt = txt

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

b = A("b")
l = B("l")
i = A("i")
f = B("f")
j = A("j")
a = B("a")

b.w = f
b.u = l
l.q = a
i.w = l
i.u = l
f.q = l
j.w = l
j.u = a
a.q = l
assert a.q.q.q.txt == "l"