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

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

j = A("j")
k = B("k")
l = B("l")
f = B("f")

j.u = f
k.o = f
k.u = f
l.o = k
l.u = k
f.o = k
f.u = k
assert j.u.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: B = None
        self.u: B = None
        self.txt = txt

j = A("j")
k = B("k")
l = B("l")
f = B("f")

j.u = f
k.o = f
k.u = f
l.o = k
l.u = k
f.o = k
f.u = k
assert j.u.u.o.txt == "f"