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

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

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

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

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

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

b.s = a
h.u = j
h.s = a
a.u = h
a.s = h
j.u = h
j.s = h
assert a.s.s.s.u.txt == "j"