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

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

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

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

b.x = a
m.p = b
m.z = g
g.u = m
g.q = h
g.s = n
a.u = m
a.q = b
a.s = n
n.u = m
n.q = b
n.s = g
f.u = m
f.q = b
f.s = n
h.x = a
d.u = m
d.q = b
d.s = f
assert n.s.q.x.s.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

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

b.x = a
m.p = b
m.z = g
g.u = m
g.q = h
g.s = n
a.u = m
a.q = b
a.s = n
n.u = m
n.q = b
n.s = g
f.u = m
f.q = b
f.s = n
h.x = a
d.u = m
d.q = b
d.s = f
assert n.s.q.x.s.u.z.u.txt == "m"