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

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

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

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

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

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

f.u = j
f.t = j
i.o = j
i.x = f
j.u = f
j.t = f
assert i.o.u.u.txt == "j"