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

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

l = A("l")
i = B("i")
h = A("h")
j = A("j")
c = B("c")

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

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

l = A("l")
i = B("i")
h = A("h")
j = A("j")
c = B("c")

l.u = h
i.t = c
i.o = j
h.u = j
j.u = h
c.t = i
c.o = l
assert i.t.o.u.txt == "h"