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.txt = txt

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

f.u = g
k.o = g
g.o = k
j.u = k
assert f.u.o.o.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.txt = txt

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

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