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

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

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

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

m = A("m")
l = B("l")
g = C("g")
i = D("i")
j = A("j")
a = C("a")
f = A("f")
e = B("e")
h = D("h")
d = B("d")

m.t = i
m.u = a
m.z = d
l.z = h
l.q = a
l.x = f
l.y = d
g.q = a
i.t = h
j.t = h
j.u = a
j.z = d
a.q = g
f.t = h
f.u = g
f.z = d
e.z = i
e.q = g
e.x = f
e.y = d
h.t = i
d.z = h
d.q = g
d.x = f
d.y = e
assert j.z.q.q.q.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
g = C("g")
i = D("i")
j = A("j")
a = C("a")
f = A("f")
e = B("e")
h = D("h")
d = B("d")

m.t = i
m.u = a
m.z = d
l.z = h
l.q = a
l.x = f
l.y = d
g.q = a
i.t = h
j.t = h
j.u = a
j.z = d
a.q = g
f.t = h
f.u = g
f.z = d
e.z = i
e.q = g
e.x = f
e.y = d
h.t = i
d.z = h
d.q = g
d.x = f
d.y = e
assert j.z.q.q.q.q.q.q.q.q.q.txt == "g"