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

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

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

n = A("n")
g = B("g")
d = C("d")
k = A("k")
i = A("i")
f = C("f")
a = B("a")
m = B("m")

n.v = i
n.q = a
g.x = f
d.z = i
d.t = i
d.p = i
k.v = i
k.q = m
i.v = n
i.q = a
f.z = n
f.p = n
f.t = i
a.x = d
m.x = f
assert i.q.x.z.v.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: B = None
        self.txt = txt

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

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

n = A("n")
g = B("g")
d = C("d")
k = A("k")
i = A("i")
f = C("f")
a = B("a")
m = B("m")

n.v = i
n.q = a
g.x = f
d.z = i
d.t = i
d.p = i
k.v = i
k.q = m
i.v = n
i.q = a
f.z = n
f.p = n
f.t = i
a.x = d
m.x = f
assert i.q.x.z.v.v.q.txt == "a"