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

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

m = A("m")
k = B("k")
b = B("b")

m.z = k
m.o = b
k.u = b
k.x = b
b.u = k
b.x = k
assert b.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: B = None
        self.txt = txt

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

m = A("m")
k = B("k")
b = B("b")

m.z = k
m.o = b
k.u = b
k.x = b
b.u = k
b.x = k
assert b.u.u.u.txt == "k"