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

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

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

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

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

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

n.u = k
k.o = n
f.o = n
assert f.o.u.o.txt == "n"