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

n = A("n")
i = B("i")
g = B("g")

n.u = i
i.s = g
g.s = i
assert n.u.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

n = A("n")
i = B("i")
g = B("g")

n.u = i
i.s = g
g.s = i
assert n.u.s.s.txt == "i"