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

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

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

d = A("d")
k = B("k")
b = C("b")
m = B("m")
i = C("i")
a = A("a")
e = B("e")
h = A("h")
n = A("n")
g = C("g")

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

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

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

d = A("d")
k = B("k")
b = C("b")
m = B("m")
i = C("i")
a = A("a")
e = B("e")
h = A("h")
n = A("n")
g = C("g")

d.t = e
d.p = n
k.x = m
k.z = d
b.r = n
b.v = n
b.z = e
m.x = k
m.z = a
i.r = n
i.v = n
i.z = k
a.t = k
a.p = d
e.x = k
e.z = n
h.t = k
h.p = a
n.t = e
n.p = d
g.r = n
g.v = d
g.z = k
assert a.t.z.p.txt == "n"