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

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

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

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

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

a.s = c
a.z = h
d.r = f
d.w = n
d.x = n
m.r = e
h.o = a
h.t = n
g.r = f
g.w = h
g.x = h
c.r = m
f.s = e
f.z = n
l.r = a
l.w = h
l.x = h
n.o = f
n.t = h
e.r = c
assert e.r.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.z: D = None
        self.txt = txt

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

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

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

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

a.s = c
a.z = h
d.r = f
d.w = n
d.x = n
m.r = e
h.o = a
h.t = n
g.r = f
g.w = h
g.x = h
c.r = m
f.s = e
f.z = n
l.r = a
l.w = h
l.x = h
n.o = f
n.t = h
e.r = c
assert e.r.r.r.r.r.r.r.r.txt == "m"