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

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

h = A("h")
j = B("j")
l = A("l")
b = A("b")
f = B("f")
m = A("m")

h.w = f
j.o = f
j.q = l
l.w = f
b.w = j
f.o = j
f.q = m
m.w = f
assert l.w.q.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: B = None
        self.q: A = None
        self.txt = txt

h = A("h")
j = B("j")
l = A("l")
b = A("b")
f = B("f")
m = A("m")

h.w = f
j.o = f
j.q = l
l.w = f
b.w = j
f.o = j
f.q = m
m.w = f
assert l.w.q.w.txt == "f"