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

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

h = A("h")
b = B("b")
a = A("a")

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

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

h = A("h")
b = B("b")
a = A("a")

h.s = a
h.t = a
b.o = h
a.s = h
a.t = h
assert a.s.t.s.txt == "h"