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

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

l = A("l")
h = B("h")
a = B("a")

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

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

l = A("l")
h = B("h")
a = B("a")

l.o = h
l.q = h
h.r = a
h.w = a
a.r = h
a.w = h
assert l.o.r.w.txt == "h"