class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
g = C("g")
m = C("m")
a = B("a")

b.x = g
d.u = a
d.o = a
g.s = d
m.s = a
a.u = d
a.o = d
assert a.o.o.o.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

b = A("b")
d = B("d")
g = C("g")
m = C("m")
a = B("a")

b.x = g
d.u = a
d.o = a
g.s = d
m.s = a
a.u = d
a.o = d
assert a.o.o.o.o.u.txt == "d"