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

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

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

c = A("c")
n = B("n")
g = C("g")
l = B("l")
j = B("j")
k = A("k")

c.z = j
n.r = k
n.p = k
n.x = g
g.x = j
l.r = c
l.x = g
l.p = k
j.r = k
j.p = k
j.x = g
k.z = n
assert k.z.x.x.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

c = A("c")
n = B("n")
g = C("g")
l = B("l")
j = B("j")
k = A("k")

c.z = j
n.r = k
n.p = k
n.x = g
g.x = j
l.r = c
l.x = g
l.p = k
j.r = k
j.p = k
j.x = g
k.z = n
assert k.z.x.x.r.z.txt == "n"