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

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

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

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

i.x = n
i.p = k
i.y = a
k.z = g
n.w = m
n.q = k
n.o = g
c.z = g
m.z = n
d.x = g
d.p = k
d.y = a
g.w = c
g.q = c
g.o = n
a.x = n
a.p = m
a.y = d
assert d.p.z.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: B = None
        self.y: A = None
        self.txt = txt

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

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

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

i.x = n
i.p = k
i.y = a
k.z = g
n.w = m
n.q = k
n.o = g
c.z = g
m.z = n
d.x = g
d.p = k
d.y = a
g.w = c
g.q = c
g.o = n
a.x = n
a.p = m
a.y = d
assert d.p.z.o.o.txt == "g"