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

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

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

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

k.z = i
k.x = a
c.s = j
c.r = i
c.p = a
d.y = k
j.s = c
j.r = d
j.p = a
n.z = i
n.x = a
a.s = j
a.p = j
a.r = i
i.y = n
assert i.y.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: B = None
        self.txt = txt

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

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

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

k.z = i
k.x = a
c.s = j
c.r = i
c.p = a
d.y = k
j.s = c
j.r = d
j.p = a
n.z = i
n.x = a
a.s = j
a.p = j
a.r = i
i.y = n
assert i.y.x.p.txt == "j"