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

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

h = A("h")
l = B("l")
a = A("a")
c = B("c")

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

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

h = A("h")
l = B("l")
a = A("a")
c = B("c")

h.o = c
l.t = c
a.o = c
c.t = l
assert a.o.t.t.txt == "c"