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

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

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

n = A("n")
k = B("k")
e = C("e")
h = C("h")
g = B("g")
a = C("a")
i = B("i")
c = B("c")
d = A("d")
j = B("j")

n.x = g
n.z = d
k.q = c
k.z = a
e.x = d
e.t = d
h.x = d
h.t = d
g.q = i
g.z = a
a.x = d
a.t = n
i.q = g
i.z = h
c.q = k
c.z = e
d.x = i
d.z = n
j.q = i
j.z = a
assert j.z.t.z.z.x.q.z.t.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: A = None
        self.txt = txt

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

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

n = A("n")
k = B("k")
e = C("e")
h = C("h")
g = B("g")
a = C("a")
i = B("i")
c = B("c")
d = A("d")
j = B("j")

n.x = g
n.z = d
k.q = c
k.z = a
e.x = d
e.t = d
h.x = d
h.t = d
g.q = i
g.z = a
a.x = d
a.t = n
i.q = g
i.z = h
c.q = k
c.z = e
d.x = i
d.z = n
j.q = i
j.z = a
assert j.z.t.z.z.x.q.z.t.x.z.txt == "h"