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

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

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

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

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

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

m.u = i
m.p = g
c.x = i
a.x = c
l.u = i
l.p = i
f.u = g
f.p = i
n.u = a
n.p = a
i.x = c
b.u = a
b.p = g
g.x = c
assert n.p.x.x.x.x.x.txt == "c"