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

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

j = A("j")
h = B("h")
f = A("f")

j.r = f
j.u = f
h.o = f
f.r = j
f.u = j
assert j.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.u: A = None
        self.txt = txt

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

j = A("j")
h = B("h")
f = A("f")

j.r = f
j.u = f
h.o = f
f.r = j
f.u = j
assert j.u.u.u.txt == "f"