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

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

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

j = A("j")
a = B("a")
l = C("l")
k = B("k")
i = A("i")

j.p = l
j.r = l
j.z = i
a.p = l
l.v = a
k.p = l
i.p = l
i.r = l
i.z = j
assert k.p.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: A = None
        self.r: C = None
        self.txt = txt

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

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

j = A("j")
a = B("a")
l = C("l")
k = B("k")
i = A("i")

j.p = l
j.r = l
j.z = i
a.p = l
l.v = a
k.p = l
i.p = l
i.r = l
i.z = j
assert k.p.v.p.txt == "l"