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

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

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

k = A("k")
m = B("m")
e = C("e")
c = A("c")
l = C("l")
b = B("b")

k.x = l
k.y = b
k.z = c
m.p = k
m.x = b
m.v = b
e.v = b
e.r = k
c.x = l
c.y = b
c.z = k
l.v = b
l.r = k
b.p = k
b.x = m
b.v = m
assert l.r.x.v.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: B = None
        self.z: A = None
        self.txt = txt

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

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

k = A("k")
m = B("m")
e = C("e")
c = A("c")
l = C("l")
b = B("b")

k.x = l
k.y = b
k.z = c
m.p = k
m.x = b
m.v = b
e.v = b
e.r = k
c.x = l
c.y = b
c.z = k
l.v = b
l.r = k
b.p = k
b.x = m
b.v = m
assert l.r.x.v.v.p.txt == "k"