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

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

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

m = A("m")
d = B("d")
n = C("n")
b = A("b")
g = B("g")
j = B("j")
a = B("a")
f = B("f")
l = B("l")

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

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

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

m = A("m")
d = B("d")
n = C("n")
b = A("b")
g = B("g")
j = B("j")
a = B("a")
f = B("f")
l = B("l")

m.x = g
m.u = b
d.p = m
n.o = f
n.s = j
b.x = f
b.u = m
g.p = b
j.p = m
a.p = b
f.p = b
l.p = b
assert a.p.u.u.x.txt == "f"