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

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

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

n = A("n")
a = B("a")
e = C("e")
f = C("f")
m = B("m")

n.p = e
a.r = f
a.x = f
e.u = f
e.q = a
f.u = e
f.q = m
m.r = e
m.x = f
assert n.p.u.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

n = A("n")
a = B("a")
e = C("e")
f = C("f")
m = B("m")

n.p = e
a.r = f
a.x = f
e.u = f
e.q = a
f.u = e
f.q = m
m.r = e
m.x = f
assert n.p.u.q.x.txt == "f"