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: B = None
        self.txt = txt

a = A("a")
i = B("i")
e = A("e")
j = B("j")
b = A("b")

a.u = b
a.t = b
i.o = j
e.u = b
e.t = b
j.o = i
b.u = e
b.t = e
assert e.u.t.t.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: B = None
        self.txt = txt

a = A("a")
i = B("i")
e = A("e")
j = B("j")
b = A("b")

a.u = b
a.t = b
i.o = j
e.u = b
e.t = b
j.o = i
b.u = e
b.t = e
assert e.u.t.t.txt == "b"