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

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

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

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

c.z = g
a.s = g
a.p = i
d.x = l
d.y = b
d.s = a
l.z = b
g.x = l
g.y = m
g.s = a
i.s = g
i.p = a
n.x = l
n.y = d
n.s = i
m.x = l
m.y = n
m.s = i
b.x = l
b.y = m
b.s = a
assert b.s.s.x.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

c.z = g
a.s = g
a.p = i
d.x = l
d.y = b
d.s = a
l.z = b
g.x = l
g.y = m
g.s = a
i.s = g
i.p = a
n.x = l
n.y = d
n.s = i
m.x = l
m.y = n
m.s = i
b.x = l
b.y = m
b.s = a
assert b.s.s.x.z.s.txt == "a"