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

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

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

c = A("c")
k = B("k")
g = C("g")
d = A("d")
j = C("j")

c.z = j
c.p = j
c.v = d
k.t = g
k.y = d
g.p = j
g.r = j
g.y = k
d.z = g
d.v = c
d.p = j
j.p = g
j.r = g
j.y = k
assert c.v.z.r.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

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

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

c = A("c")
k = B("k")
g = C("g")
d = A("d")
j = C("j")

c.z = j
c.p = j
c.v = d
k.t = g
k.y = d
g.p = j
g.r = j
g.y = k
d.z = g
d.v = c
d.p = j
j.p = g
j.r = g
j.y = k
assert c.v.z.r.r.p.txt == "j"