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

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

a = A("a")
l = B("l")
h = B("h")
b = B("b")
i = B("i")
k = A("k")

a.w = h
l.o = k
l.q = h
h.o = a
h.q = l
b.o = k
b.q = i
i.o = k
i.q = l
k.w = b
assert k.w.o.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

a = A("a")
l = B("l")
h = B("h")
b = B("b")
i = B("i")
k = A("k")

a.w = h
l.o = k
l.q = h
h.o = a
h.q = l
b.o = k
b.q = i
i.o = k
i.q = l
k.w = b
assert k.w.o.w.o.w.txt == "b"