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

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

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

d = A("d")
c = B("c")
e = C("e")
i = A("i")
k = C("k")
n = B("n")
m = B("m")

d.x = n
c.v = k
c.q = k
c.u = d
e.p = k
e.z = m
i.x = c
k.p = e
k.z = m
n.v = e
n.q = e
n.u = i
m.v = k
m.q = k
m.u = i
assert k.p.z.v.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
e = C("e")
i = A("i")
k = C("k")
n = B("n")
m = B("m")

d.x = n
c.v = k
c.q = k
c.u = d
e.p = k
e.z = m
i.x = c
k.p = e
k.z = m
n.v = e
n.q = e
n.u = i
m.v = k
m.q = k
m.u = i
assert k.p.z.v.p.p.p.p.txt == "k"