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

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

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

k.o = n
k.u = n
n.w = k
n.v = b
b.w = k
b.v = n
assert k.o.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: B = None
        self.txt = txt

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

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

k.o = n
k.u = n
n.w = k
n.v = b
b.w = k
b.v = n
assert k.o.w.u.txt == "n"