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

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

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

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

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

l.z = k
m.r = h
m.q = i
j.x = e
j.u = n
j.p = d
i.x = g
n.x = i
k.r = h
k.q = i
h.r = k
h.q = g
e.x = j
e.u = n
e.p = l
d.z = k
g.x = i
assert h.q.x.x.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

l.z = k
m.r = h
m.q = i
j.x = e
j.u = n
j.p = d
i.x = g
n.x = i
k.r = h
k.q = i
h.r = k
h.q = g
e.x = j
e.u = n
e.p = l
d.z = k
g.x = i
assert h.q.x.x.x.x.x.x.x.x.x.txt == "i"