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

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

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

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

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

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

c.u = a
c.s = a
h.s = a
a.u = c
a.s = c
assert h.s.s.s.txt == "a"