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

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

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

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

a.z = h
a.x = e
n.v = k
n.q = h
n.r = d
c.q = a
c.z = h
c.s = k
e.z = k
e.x = a
f.q = a
f.z = k
f.s = k
k.q = i
k.z = h
k.s = f
i.z = h
i.x = g
d.v = f
d.q = k
d.r = n
g.z = c
g.x = i
h.q = i
h.z = f
h.s = f
assert g.z.q.z.s.z.z.q.x.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: A = None
        self.txt = txt

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

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

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

a.z = h
a.x = e
n.v = k
n.q = h
n.r = d
c.q = a
c.z = h
c.s = k
e.z = k
e.x = a
f.q = a
f.z = k
f.s = k
k.q = i
k.z = h
k.s = f
i.z = h
i.x = g
d.v = f
d.q = k
d.r = n
g.z = c
g.x = i
h.q = i
h.z = f
h.s = f
assert g.z.q.z.s.z.z.q.x.x.z.txt == "h"