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

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

g = A("g")
c = B("c")
f = A("f")
b = B("b")
k = B("k")

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

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

g = A("g")
c = B("c")
f = A("f")
b = B("b")
k = B("k")

g.u = c
c.s = b
f.u = c
b.s = k
k.s = b
assert k.s.s.s.txt == "b"