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

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

m = A("m")
g = B("g")
i = B("i")
l = A("l")
f = B("f")
a = A("a")
c = A("c")

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

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

m = A("m")
g = B("g")
i = B("i")
l = A("l")
f = B("f")
a = A("a")
c = A("c")

m.s = g
g.u = i
i.u = g
l.s = g
f.u = g
a.s = f
c.s = i
assert a.s.u.u.txt == "i"