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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

n = A("n")
d = B("d")
g = C("g")
k = D("k")
c = B("c")
f = C("f")
e = C("e")
a = A("a")
j = B("j")
m = C("m")

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

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

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

n = A("n")
d = B("d")
g = C("g")
k = D("k")
c = B("c")
f = C("f")
e = C("e")
a = A("a")
j = B("j")
m = C("m")

n.t = d
n.z = j
n.o = a
d.z = n
d.q = a
g.y = k
k.q = f
c.z = n
c.q = a
f.y = k
e.y = k
a.t = d
a.z = j
a.o = n
j.z = a
j.q = n
m.y = k
assert g.y.q.y.q.y.q.y.q.y.txt == "k"