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

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

a = A("a")
g = B("g")
b = A("b")
c = B("c")

a.o = b
a.u = b
g.w = c
b.o = a
b.u = a
c.w = g
assert c.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: A = None
        self.txt = txt

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

a = A("a")
g = B("g")
b = A("b")
c = B("c")

a.o = b
a.u = b
g.w = c
b.o = a
b.u = a
c.w = g
assert c.w.w.w.txt == "g"