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

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

h = A("h")
c = B("c")
a = A("a")
f = A("f")
g = A("g")
b = A("b")

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

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

h = A("h")
c = B("c")
a = A("a")
f = A("f")
g = A("g")
b = A("b")

h.u = c
c.s = f
a.u = c
f.u = c
g.u = c
b.u = c
assert a.u.s.u.txt == "c"